Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions apps/contactsinteraction/lib/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
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;
Expand Down Expand Up @@ -130,8 +129,8 @@ public function childExists($name) {
/**
* @inheritDoc
*/
public function getLastModified() {
throw new NotImplemented();
public function getLastModified(): ?int {
return $this->mapper->findLastUpdatedForUserId($this->getUid());
}

/**
Expand All @@ -149,6 +148,7 @@ public function getProperties($properties) {
'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),
];
}

Expand Down
2 changes: 1 addition & 1 deletion apps/contactsinteraction/lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function getContentType(): ?string {
* @inheritDoc
*/
public function getETag(): ?string {
return null;
return '"' . md5((string) $this->getLastModified()) . '"';
}

/**
Expand Down
24 changes: 24 additions & 0 deletions apps/contactsinteraction/lib/Db/RecentContactMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,30 @@ public function findMatch(IUser $user,
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();

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/lib/CardDAV/Integration/ExternalAddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
abstract class ExternalAddressBook implements IAddressBook, DAV\IProperties {

/** @var string */
private const PREFIX = 'app-generated';
private const PREFIX = 'z-app-generated';

/**
* @var string
Expand Down