summaryrefslogtreecommitdiffstats
path: root/apps/user_status/lib/Service
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2020-09-02 12:25:02 +0200
committerGeorg Ehrke <developer@georgehrke.com>2020-09-07 09:22:38 +0200
commit7fedd33825dc9eb2f3f9bddbc1b3f4301859206f (patch)
tree2a9bb8c11f53d3bfdb8911a25d03cc5ae88d01ee /apps/user_status/lib/Service
parent10df7198fe5a1318afaaf6396b64627f70245070 (diff)
downloadnextcloud-server-7fedd33825dc9eb2f3f9bddbc1b3f4301859206f.tar.gz
nextcloud-server-7fedd33825dc9eb2f3f9bddbc1b3f4301859206f.zip
Better cleanup routine for statuses
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'apps/user_status/lib/Service')
-rw-r--r--apps/user_status/lib/Service/StatusService.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/apps/user_status/lib/Service/StatusService.php b/apps/user_status/lib/Service/StatusService.php
index 06441f60059..1e1e5b1fcc5 100644
--- a/apps/user_status/lib/Service/StatusService.php
+++ b/apps/user_status/lib/Service/StatusService.php
@@ -341,6 +341,11 @@ class StatusService {
*/
private function processStatus(UserStatus $status): UserStatus {
$clearAt = $status->getClearAt();
+
+ if ($status->getStatusTimestamp() < $this->timeFactory->getTime() - self::INVALIDATE_STATUS_THRESHOLD
+ && (!$status->getIsUserDefined() || $status->getStatus() === self::ONLINE)) {
+ $this->cleanStatus($status);
+ }
if ($clearAt !== null && $clearAt < $this->timeFactory->getTime()) {
$this->cleanStatusMessage($status);
}
@@ -354,6 +359,17 @@ class StatusService {
/**
* @param UserStatus $status
*/
+ private function cleanStatus(UserStatus $status): void {
+ $status->setStatus(self::OFFLINE);
+ $status->setStatusTimestamp($this->timeFactory->getTime());
+ $status->setIsUserDefined(false);
+
+ $this->mapper->update($status);
+ }
+
+ /**
+ * @param UserStatus $status
+ */
private function cleanStatusMessage(UserStatus $status): void {
$status->setMessageId(null);
$status->setCustomIcon(null);