summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorGeorg Ehrke <georgehrke@users.noreply.github.com>2020-05-08 12:03:25 +0200
committerGitHub <noreply@github.com>2020-05-08 12:03:25 +0200
commita45f4035e62bb509918398e1d3f1f6ed251d9236 (patch)
treea592b3d7b9117947dbce0ad42cafaa1cbcaabdd5 /apps
parent131b1fa45876a6e11a60ed60a24bb2b3becf637f (diff)
parentcbbe11fa1f40b366491915ae831b7be6a15f8387 (diff)
downloadnextcloud-server-a45f4035e62bb509918398e1d3f1f6ed251d9236.tar.gz
nextcloud-server-a45f4035e62bb509918398e1d3f1f6ed251d9236.zip
Merge pull request #20860 from nextcloud/bugfix/noid/macos_contacts_sync_prefer_personal_over_app-generated
macOS contacts: prefer personal over app generated
Diffstat (limited to 'apps')
-rw-r--r--apps/contactsinteraction/lib/AddressBook.php6
-rw-r--r--apps/contactsinteraction/lib/Card.php2
-rw-r--r--apps/contactsinteraction/lib/Db/RecentContactMapper.php24
-rw-r--r--apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php2
4 files changed, 29 insertions, 5 deletions
diff --git a/apps/contactsinteraction/lib/AddressBook.php b/apps/contactsinteraction/lib/AddressBook.php
index e8479cb186a..55819380b9a 100644
--- a/apps/contactsinteraction/lib/AddressBook.php
+++ b/apps/contactsinteraction/lib/AddressBook.php
@@ -34,7 +34,6 @@ use OCA\DAV\DAV\Sharing\Plugin;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\IL10N;
use Sabre\DAV\Exception\NotFound;
-use Sabre\DAV\Exception\NotImplemented;
use Sabre\DAV\PropPatch;
use Sabre\DAVACL\ACLTrait;
use Sabre\DAVACL\IACL;
@@ -130,8 +129,8 @@ class AddressBook extends ExternalAddressBook implements IACL {
/**
* @inheritDoc
*/
- public function getLastModified() {
- throw new NotImplemented();
+ public function getLastModified(): ?int {
+ return $this->mapper->findLastUpdatedForUserId($this->getUid());
}
/**
@@ -149,6 +148,7 @@ class AddressBook extends ExternalAddressBook implements IACL {
'principaluri' => $this->principalUri,
'{DAV:}displayname' => $this->l10n->t('Recently contacted'),
'{' . Plugin::NS_OWNCLOUD . '}read-only' => true,
+ '{' . \OCA\DAV\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($this->getLastModified() ?? 0),
];
}
diff --git a/apps/contactsinteraction/lib/Card.php b/apps/contactsinteraction/lib/Card.php
index 6285025f1eb..2cacd7ad546 100644
--- a/apps/contactsinteraction/lib/Card.php
+++ b/apps/contactsinteraction/lib/Card.php
@@ -95,7 +95,7 @@ class Card implements ICard, IACL {
* @inheritDoc
*/
public function getETag(): ?string {
- return null;
+ return '"' . md5((string) $this->getLastModified()) . '"';
}
/**
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();
diff --git a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
index 0bd01184eba..ac52a446306 100644
--- a/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
+++ b/apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
@@ -34,7 +34,7 @@ use Sabre\DAV;
abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
/** @var string */
- private const PREFIX = 'app-generated';
+ private const PREFIX = 'z-app-generated';
/**
* @var string