Skip to content
Snippets Groups Projects
Unverified Commit a45f4035 authored by Georg Ehrke's avatar Georg Ehrke Committed by GitHub
Browse files

Merge pull request #20860 from...

Merge pull request #20860 from nextcloud/bugfix/noid/macos_contacts_sync_prefer_personal_over_app-generated

macOS contacts: prefer personal over app generated
parents 131b1fa4 cbbe11fa
No related branches found
No related tags found
No related merge requests found
...@@ -34,7 +34,6 @@ use OCA\DAV\DAV\Sharing\Plugin; ...@@ -34,7 +34,6 @@ use OCA\DAV\DAV\Sharing\Plugin;
use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Db\DoesNotExistException;
use OCP\IL10N; use OCP\IL10N;
use Sabre\DAV\Exception\NotFound; use Sabre\DAV\Exception\NotFound;
use Sabre\DAV\Exception\NotImplemented;
use Sabre\DAV\PropPatch; use Sabre\DAV\PropPatch;
use Sabre\DAVACL\ACLTrait; use Sabre\DAVACL\ACLTrait;
use Sabre\DAVACL\IACL; use Sabre\DAVACL\IACL;
...@@ -130,8 +129,8 @@ class AddressBook extends ExternalAddressBook implements IACL { ...@@ -130,8 +129,8 @@ class AddressBook extends ExternalAddressBook implements IACL {
/** /**
* @inheritDoc * @inheritDoc
*/ */
public function getLastModified() { public function getLastModified(): ?int {
throw new NotImplemented(); return $this->mapper->findLastUpdatedForUserId($this->getUid());
} }
/** /**
...@@ -149,6 +148,7 @@ class AddressBook extends ExternalAddressBook implements IACL { ...@@ -149,6 +148,7 @@ class AddressBook extends ExternalAddressBook implements IACL {
'principaluri' => $this->principalUri, 'principaluri' => $this->principalUri,
'{DAV:}displayname' => $this->l10n->t('Recently contacted'), '{DAV:}displayname' => $this->l10n->t('Recently contacted'),
'{' . Plugin::NS_OWNCLOUD . '}read-only' => true, '{' . Plugin::NS_OWNCLOUD . '}read-only' => true,
'{' . \OCA\DAV\CalDAV\Plugin::NS_CALENDARSERVER . '}getctag' => 'http://sabre.io/ns/sync/' . ($this->getLastModified() ?? 0),
]; ];
} }
......
...@@ -95,7 +95,7 @@ class Card implements ICard, IACL { ...@@ -95,7 +95,7 @@ class Card implements ICard, IACL {
* @inheritDoc * @inheritDoc
*/ */
public function getETag(): ?string { public function getETag(): ?string {
return null; return '"' . md5((string) $this->getLastModified()) . '"';
} }
/** /**
......
...@@ -104,6 +104,30 @@ class RecentContactMapper extends QBMapper { ...@@ -104,6 +104,30 @@ class RecentContactMapper extends QBMapper {
return $this->findEntities($select); 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 { public function cleanUp(int $olderThan): void {
$qb = $this->db->getQueryBuilder(); $qb = $this->db->getQueryBuilder();
......
...@@ -34,7 +34,7 @@ use Sabre\DAV; ...@@ -34,7 +34,7 @@ use Sabre\DAV;
abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties { abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {
/** @var string */ /** @var string */
private const PREFIX = 'app-generated'; private const PREFIX = 'z-app-generated';
/** /**
* @var string * @var string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment