summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2019-10-01 09:54:40 +0200
committerJoas Schilling <coding@schilljs.com>2019-10-01 09:54:40 +0200
commit733da0c4c24207fbb5084db781af81775cdf96cd (patch)
tree5252277cb07dd2c33aee3cd6907075524990b5af /lib
parentbdb9b52cbfc2896b8e27884b6ea4f70f6665e420 (diff)
Correctly set the unread counter when readding a user to a one-to-one conversation
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Manager.php11
-rw-r--r--lib/Room.php11
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/Manager.php b/lib/Manager.php
index f9aa8acd8..8623e9235 100644
--- a/lib/Manager.php
+++ b/lib/Manager.php
@@ -28,6 +28,8 @@ use OCA\Talk\Chat\CommentsManager;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\RoomNotFoundException;
use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\Comments\IComment;
+use OCP\Comments\NotFoundException;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IConfig;
use OCP\IDBConnection;
@@ -152,6 +154,7 @@ class Manager {
(int) $row['active_guests'],
$activeSince,
$lastActivity,
+ (int) $row['last_message'],
$lastMessage,
$lobbyTimer,
(string) $row['object_type'],
@@ -187,6 +190,14 @@ class Manager {
);
}
+ public function loadLastCommentInfo(int $id): ?IComment {
+ try {
+ return $this->commentsManager->get((string)$id);
+ } catch (NotFoundException $e) {
+ return null;
+ }
+ }
+
/**
* @param string $participant
* @param bool $includeLastMessage
diff --git a/lib/Room.php b/lib/Room.php
index c0fcb8b77..08ee9b506 100644
--- a/lib/Room.php
+++ b/lib/Room.php
@@ -91,6 +91,8 @@ class Room {
private $activeSince;
/** @var \DateTime|null */
private $lastActivity;
+ /** @var int */
+ private $lastMessageId;
/** @var IComment|null */
private $lastMessage;
/** @var string */
@@ -119,6 +121,7 @@ class Room {
int $activeGuests,
\DateTime $activeSince = null,
\DateTime $lastActivity = null,
+ int $lastMessageId,
IComment $lastMessage = null,
\DateTime $lobbyTimer = null,
string $objectType = '',
@@ -139,6 +142,7 @@ class Room {
$this->activeGuests = $activeGuests;
$this->activeSince = $activeSince;
$this->lastActivity = $lastActivity;
+ $this->lastMessageId = $lastMessageId;
$this->lastMessage = $lastMessage;
$this->lobbyTimer = $lobbyTimer;
$this->objectType = $objectType;
@@ -198,6 +202,13 @@ class Room {
}
public function getLastMessage(): ?IComment {
+ if ($this->lastMessageId && $this->lastMessage === null) {
+ $this->lastMessage = $this->manager->loadLastCommentInfo($this->lastMessageId);
+ if ($this->lastMessage === null) {
+ $this->lastMessageId = 0;
+ }
+ }
+
return $this->lastMessage;
}