]> source.dussan.org Git - nextcloud-server.git/commitdiff
Reset user status based on message ID only 33351/head
authorJoas Schilling <coding@schilljs.com>
Fri, 22 Jul 2022 09:02:37 +0000 (11:02 +0200)
committerJoas Schilling <coding@schilljs.com>
Tue, 26 Jul 2022 09:31:10 +0000 (11:31 +0200)
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>
apps/user_status/lib/Connector/UserStatusProvider.php
apps/user_status/lib/Db/UserStatusMapper.php
apps/user_status/lib/Service/StatusService.php

index da0a6c635ce46b14c516239036c6709144d1a433..a37d299e74eae987f5378a9f173e11421c7ce6f1 100644 (file)
@@ -62,6 +62,6 @@ 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);
        }
 }
index 1ef327a21f4b8521a68ab1f9910fcad22b1fdeff..12d0be657b2f9b94ebc86659d4b02283c19a4e69 100644 (file)
@@ -172,15 +172,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;
        }
index efe05e10395f5afa03ddb72a37347439d75c9ba9..f2805ae9ae458cef70a1c8be606a7c877df06d31 100644 (file)
@@ -504,7 +504,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);
@@ -513,7 +513,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;