diff options
author | Joas Schilling <coding@schilljs.com> | 2022-07-22 11:02:37 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2022-07-22 11:02:37 +0200 |
commit | 9a9db2802b56d63137122bfaf97da2cc8e11bc7d (patch) | |
tree | 49ad24aad42b4b1f68f77940eb3b2096140c8f86 /apps/user_status/lib | |
parent | 7e05efd3529f39bf5480fd2d954d04b9c49ca301 (diff) | |
download | nextcloud-server-9a9db2802b56d63137122bfaf97da2cc8e11bc7d.tar.gz nextcloud-server-9a9db2802b56d63137122bfaf97da2cc8e11bc7d.zip |
Reset user status based on message ID only
Since some statuses (call) can occure with different status
(away and dnd) we need to reset only based on the message id.
But as it can not be set by the user this is still save and okay.
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/user_status/lib')
-rw-r--r-- | apps/user_status/lib/Connector/UserStatusProvider.php | 4 | ||||
-rw-r--r-- | apps/user_status/lib/Db/UserStatusMapper.php | 4 | ||||
-rw-r--r-- | apps/user_status/lib/Service/StatusService.php | 9 |
3 files changed, 7 insertions, 10 deletions
diff --git a/apps/user_status/lib/Connector/UserStatusProvider.php b/apps/user_status/lib/Connector/UserStatusProvider.php index 46b89739f7c..cc674c9967e 100644 --- a/apps/user_status/lib/Connector/UserStatusProvider.php +++ b/apps/user_status/lib/Connector/UserStatusProvider.php @@ -62,10 +62,10 @@ class UserStatusProvider implements IProvider, ISettableProvider { } public function revertUserStatus(string $userId, string $messageId, string $status): void { - $this->service->revertUserStatus($userId, $messageId, $status); + $this->service->revertUserStatus($userId, $messageId); } public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { - $this->service->revertMultipleUserStatus($userIds, $messageId, $status); + $this->service->revertMultipleUserStatus($userIds, $messageId); } } diff --git a/apps/user_status/lib/Db/UserStatusMapper.php b/apps/user_status/lib/Db/UserStatusMapper.php index 10939116a53..4f48ea46818 100644 --- a/apps/user_status/lib/Db/UserStatusMapper.php +++ b/apps/user_status/lib/Db/UserStatusMapper.php @@ -160,15 +160,13 @@ class UserStatusMapper extends QBMapper { * * @param string $userId * @param string $messageId - * @param string $status * @return bool True if an entry was deleted */ - public function deleteCurrentStatusToRestoreBackup(string $userId, string $messageId, string $status): bool { + public function deleteCurrentStatusToRestoreBackup(string $userId, string $messageId): bool { $qb = $this->db->getQueryBuilder(); $qb->delete($this->tableName) ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))) ->andWhere($qb->expr()->eq('message_id', $qb->createNamedParameter($messageId))) - ->andWhere($qb->expr()->eq('status', $qb->createNamedParameter($status))) ->andWhere($qb->expr()->eq('is_backup', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL))); return $qb->executeStatement() > 0; } diff --git a/apps/user_status/lib/Service/StatusService.php b/apps/user_status/lib/Service/StatusService.php index 858db48f31f..1b7b44d95d3 100644 --- a/apps/user_status/lib/Service/StatusService.php +++ b/apps/user_status/lib/Service/StatusService.php @@ -496,7 +496,7 @@ class StatusService { } } - public function revertUserStatus(string $userId, string $messageId, string $status): void { + public function revertUserStatus(string $userId, string $messageId): void { try { /** @var UserStatus $userStatus */ $backupUserStatus = $this->mapper->findByUserId($userId, true); @@ -505,7 +505,7 @@ class StatusService { return; } - $deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId, $status); + $deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId); if (!$deleted) { // Another status is set automatically or no status, do nothing return; @@ -517,7 +517,7 @@ class StatusService { $this->mapper->update($backupUserStatus); } - public function revertMultipleUserStatus(array $userIds, string $messageId, string $status): void { + public function revertMultipleUserStatus(array $userIds, string $messageId): void { // Get all user statuses and the backups $findById = $userIds; foreach ($userIds as $userId) { @@ -528,8 +528,7 @@ class StatusService { $backups = $restoreIds = $statuesToDelete = []; foreach ($userStatuses as $userStatus) { if (!$userStatus->getIsBackup() - && $userStatus->getMessageId() === $messageId - && $userStatus->getStatus() === $status) { + && $userStatus->getMessageId() === $messageId) { $statuesToDelete[$userStatus->getUserId()] = $userStatus->getId(); } else if ($userStatus->getIsBackup()) { $backups[$userStatus->getUserId()] = $userStatus->getId(); |