aboutsummaryrefslogtreecommitdiffstats
path: root/apps/contactsinteraction/lib/Db/RecentContactMapper.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/contactsinteraction/lib/Db/RecentContactMapper.php')
-rw-r--r--apps/contactsinteraction/lib/Db/RecentContactMapper.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/apps/contactsinteraction/lib/Db/RecentContactMapper.php b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
index 18a5bf6cedc..19cd30ea701 100644
--- a/apps/contactsinteraction/lib/Db/RecentContactMapper.php
+++ b/apps/contactsinteraction/lib/Db/RecentContactMapper.php
@@ -104,6 +104,30 @@ class RecentContactMapper extends QBMapper {
return $this->findEntities($select);
}
+ /**
+ * @param string $uid
+ * @return int|null
+ */
+ public function findLastUpdatedForUserId(string $uid):?int {
+ $qb = $this->db->getQueryBuilder();
+
+ $select = $qb
+ ->select('last_contact')
+ ->from($this->getTableName())
+ ->where($qb->expr()->eq('actor_uid', $qb->createNamedParameter($uid)))
+ ->orderBy('last_contact', 'DESC')
+ ->setMaxResults(1);
+
+ $cursor = $select->execute();
+ $row = $cursor->fetch();
+
+ if ($row === false) {
+ return null;
+ }
+
+ return (int)$row['last_contact'];
+ }
+
public function cleanUp(int $olderThan): void {
$qb = $this->db->getQueryBuilder();