mirror of
https://github.com/nextcloud/server.git
synced 2026-05-15 01:49:53 -04:00
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>
This commit is contained in:
parent
339dfb8712
commit
ac43cf60c0
3 changed files with 4 additions and 6 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue