Event-listener is not triggered for DAV Card Events

Hello all,

I’ve started writing an app to propagate new or changed Contact-cards to some external REST API.

in lib/appinfo/Application.php I defined a listener which should create a log-entry when triggered by\OCA\DAV\Events\CardUpdateEvent:

 $dispatcher->addListener(CardUpdatedEvent::class   , function($e){
      $this->mylog("DAV card updated");

This does not work. However the 2 listeners below, added immediately below the first, do work fine:

$dispatcher->addListener(CardCreatedEvent::class, function($card){
      $card = $card->getCard();
      $cid = $card->getId();
      $this->mylog("deck-card $cid created \n");
$dispatcher->addListener(BeforeUserLoggedInEvent::class, function($usr){
      $uname = $usr->getUsername();
      $this->mylog("user $uname logged in \n");

Does anyone have a clue what could be the problem? The dev-manual says the DAV CardUpdateEvent should be available in v20. My Nextcloud version is 21.0.2.

Greetings, Michiel

The event is emitted in \OCA\DAV\CardDAV\CardDavBackend::updateCard. If that code is reached then your listener should get invoked.

Aha, I see. And that method updateCard is called whenever the user makes a change to one of the Contact cards, e.g. change the email-address, is that correct?

Do you have an IDE that shows you the usage of a method? Otherwise use string search for updateCard to find out when/where this called :slight_smile: