Skip to content

Commit ac43cf6

Browse files
committed
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 <[email protected]>
1 parent 339dfb8 commit ac43cf6

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

apps/user_status/lib/Connector/UserStatusProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ public function setUserStatus(string $userId, string $messageId, string $status,
6262
}
6363

6464
public function revertUserStatus(string $userId, string $messageId, string $status): void {
65-
$this->service->revertUserStatus($userId, $messageId, $status);
65+
$this->service->revertUserStatus($userId, $messageId);
6666
}
6767
}

apps/user_status/lib/Db/UserStatusMapper.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,13 @@ public function clearMessagesOlderThan(int $timestamp): void {
172172
*
173173
* @param string $userId
174174
* @param string $messageId
175-
* @param string $status
176175
* @return bool True if an entry was deleted
177176
*/
178-
public function deleteCurrentStatusToRestoreBackup(string $userId, string $messageId, string $status): bool {
177+
public function deleteCurrentStatusToRestoreBackup(string $userId, string $messageId): bool {
179178
$qb = $this->db->getQueryBuilder();
180179
$qb->delete($this->tableName)
181180
->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId)))
182181
->andWhere($qb->expr()->eq('message_id', $qb->createNamedParameter($messageId)))
183-
->andWhere($qb->expr()->eq('status', $qb->createNamedParameter($status)))
184182
->andWhere($qb->expr()->eq('is_backup', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)));
185183
return $qb->executeStatement() > 0;
186184
}

apps/user_status/lib/Service/StatusService.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ public function backupCurrentStatus(string $userId): bool {
504504
}
505505
}
506506

507-
public function revertUserStatus(string $userId, ?string $messageId, string $status): void {
507+
public function revertUserStatus(string $userId, ?string $messageId): void {
508508
try {
509509
/** @var UserStatus $userStatus */
510510
$backupUserStatus = $this->mapper->findByUserId($userId, true);
@@ -513,7 +513,7 @@ public function revertUserStatus(string $userId, ?string $messageId, string $sta
513513
return;
514514
}
515515

516-
$deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId ?? '', $status);
516+
$deleted = $this->mapper->deleteCurrentStatusToRestoreBackup($userId, $messageId ?? '');
517517
if (!$deleted) {
518518
// Another status is set automatically or no status, do nothing
519519
return;

0 commit comments

Comments
 (0)