|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* @copyright Copyright (c) 2020, Georg Ehrke |
|
7
|
|
|
* |
|
8
|
|
|
* @author Georg Ehrke <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @license AGPL-3.0 |
|
11
|
|
|
* |
|
12
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
13
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
14
|
|
|
* as published by the Free Software Foundation. |
|
15
|
|
|
* |
|
16
|
|
|
* This program is distributed in the hope that it will be useful, |
|
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
19
|
|
|
* GNU Affero General Public License for more details. |
|
20
|
|
|
* |
|
21
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
namespace OCA\UserStatus\Connector; |
|
26
|
|
|
|
|
27
|
|
|
use DateTimeImmutable; |
|
28
|
|
|
use OCP\UserStatus\IUserStatus; |
|
29
|
|
|
use OCA\UserStatus\Db; |
|
30
|
|
|
|
|
31
|
|
|
class UserStatus implements IUserStatus { |
|
32
|
|
|
|
|
33
|
|
|
/** @var string */ |
|
34
|
|
|
private $userId; |
|
35
|
|
|
|
|
36
|
|
|
/** @var string */ |
|
37
|
|
|
private $status; |
|
38
|
|
|
|
|
39
|
|
|
/** @var string|null */ |
|
40
|
|
|
private $message; |
|
41
|
|
|
|
|
42
|
|
|
/** @var string|null */ |
|
43
|
|
|
private $icon; |
|
44
|
|
|
|
|
45
|
|
|
/** @var DateTimeImmutable|null */ |
|
46
|
|
|
private $clearAt; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* UserStatus constructor. |
|
50
|
|
|
* |
|
51
|
|
|
* @param Db\UserStatus $status |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct(Db\UserStatus $status) { |
|
54
|
|
|
$this->userId = $status->getUserId(); |
|
55
|
|
|
$this->status = $status->getStatus(); |
|
56
|
|
|
$this->message = $status->getCustomMessage(); |
|
57
|
|
|
$this->icon = $status->getCustomIcon(); |
|
58
|
|
|
|
|
59
|
|
|
if ($status->getStatus() === 'invisible') { |
|
60
|
|
|
$this->status = 'offline'; |
|
61
|
|
|
} |
|
62
|
|
|
if ($status->getClearAt() !== null) { |
|
|
|
|
|
|
63
|
|
|
$this->clearAt = DateTimeImmutable::createFromFormat('U', (string)$status->getClearAt()); |
|
|
|
|
|
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* @inheritDoc |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getUserId(): string { |
|
71
|
|
|
return $this->userId; |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @inheritDoc |
|
76
|
|
|
*/ |
|
77
|
|
|
public function getStatus(): string { |
|
78
|
|
|
return $this->status; |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @inheritDoc |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getMessage(): ?string { |
|
85
|
|
|
return $this->message; |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* @inheritDoc |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getIcon(): ?string { |
|
92
|
|
|
return $this->icon; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
/** |
|
96
|
|
|
* @inheritDoc |
|
97
|
|
|
*/ |
|
98
|
|
|
public function getClearAt(): ?DateTimeImmutable { |
|
99
|
|
|
return $this->clearAt; |
|
100
|
|
|
} |
|
101
|
|
|
} |
|
102
|
|
|
|