diff options
author | Joas Schilling <coding@schilljs.com> | 2018-08-31 11:37:22 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2019-07-24 16:14:00 +0300 |
commit | 54692ebac3e55846ee91291f81e0d9192a06a138 (patch) | |
tree | a150c8e5916461f6f766c24c7c834f4f4d1041b0 /lib/Participant.php | |
parent | e1e62a59b1025056baf658f0ebfadc123d72557f (diff) |
Change read marker to work on the comment id isntead of datetime
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Participant.php')
-rw-r--r-- | lib/Participant.php | 59 |
1 files changed, 48 insertions, 11 deletions
diff --git a/lib/Participant.php b/lib/Participant.php index da7170234..8b8b431ca 100644 --- a/lib/Participant.php +++ b/lib/Participant.php @@ -63,8 +63,10 @@ class Participant { protected $notificationLevel; /** @var bool */ private $isFavorite; - /** @var \DateTime|null */ - private $lastMention; + /** @var int */ + private $lastReadMessage; + /** @var int */ + private $lastMentionMessage; /** @var \DateTime|null */ private $lastJoinedCall; @@ -77,7 +79,8 @@ class Participant { int $inCall, int $notificationLevel, bool $isFavorite, - \DateTime $lastMention = null, + int $lastReadMessage, + int $lastMentionMessage, \DateTime $lastJoinedCall = null) { $this->db = $db; $this->room = $room; @@ -88,7 +91,8 @@ class Participant { $this->inCall = $inCall; $this->notificationLevel = $notificationLevel; $this->isFavorite = $isFavorite; - $this->lastMention = $lastMention; + $this->lastReadMessage = $lastReadMessage; + $this->lastMentionMessage = $lastMentionMessage; $this->lastJoinedCall = $lastJoinedCall; } @@ -127,13 +131,6 @@ class Participant { /** * @return \DateTime|null */ - public function getLastMention(): ?\DateTime { - return $this->lastMention; - } - - /** - * @return \DateTime|null - */ public function getJoinedCall(): ?\DateTime { return $this->lastJoinedCall; } @@ -185,4 +182,44 @@ class Participant { $this->notificationLevel = $notificationLevel; return true; } + + public function getLastReadMessage(): int { + return $this->lastReadMessage; + } + + public function setLastReadMessage(int $messageId): bool { + if (!$this->user) { + return false; + } + + $query = $this->db->getQueryBuilder(); + $query->update('talk_participants') + ->set('last_read_message', $query->createNamedParameter($messageId, IQueryBuilder::PARAM_INT)) + ->where($query->expr()->eq('user_id', $query->createNamedParameter($this->user))) + ->andWhere($query->expr()->eq('room_id', $query->createNamedParameter($this->room->getId()))); + $query->execute(); + + $this->lastReadMessage = $messageId; + return true; + } + + public function getLastMentionMessage(): int { + return $this->lastMentionMessage; + } + + public function setLastMentionMessage(int $messageId): bool { + if (!$this->user) { + return false; + } + + $query = $this->db->getQueryBuilder(); + $query->update('talk_participants') + ->set('last_mention_message', $query->createNamedParameter($messageId, IQueryBuilder::PARAM_INT)) + ->where($query->expr()->eq('user_id', $query->createNamedParameter($this->user))) + ->andWhere($query->expr()->eq('room_id', $query->createNamedParameter($this->room->getId()))); + $query->execute(); + + $this->lastMentionMessage = $messageId; + return true; + } } |