Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(CardDAV): Add Sabre\DAV\IMoveTarget support to OCA\DAV\CardDAV\AddressBook #37326

Merged
merged 1 commit into from
May 16, 2023

Conversation

tcitworld
Copy link
Member

Summary

This allows to just UPDATE the card row instead of deleting it and reinsert it. It's very similar to #30120 for calendars. It's in a transaction as well since there are multiple operations.

As we need the addressbookid exposed, this introduces OCA\DAV\CardDAV\Card that extends Sabre's.

I chose specifically NOT to auto-inject LoggerInterface in Addressbook like in #30120 because the chain of DI is huge just for ONE simple call and it would break an existing dirty call (OCA\Contacts calling OCA\DAV) of ContactsManager in Contacts: nextcloud/contacts#1722 (in SocialApiService), but this is debatable (and we can prioritize making the public interfaces correct first).

Checklist

@tcitworld tcitworld added 3. to review Waiting for reviews feature: carddav Related to CardDAV internals labels Mar 21, 2023
@tcitworld tcitworld added this to the Nextcloud 27 milestone Mar 21, 2023
@tcitworld tcitworld requested a review from a team March 21, 2023 17:40
apps/dav/lib/CardDAV/CardDavBackend.php Fixed Show fixed Hide fixed
apps/dav/lib/CardDAV/AddressBook.php Fixed Show fixed Hide fixed
}

try {
return $this->carddavBackend->moveCard($sourceNode->getAddressbookId(), (int)$this->addressBookInfo['id'], $sourceNode->getUri(), $sourceNode->getOwner());

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 4 of OCA\DAV\CardDAV\CardDavBackend::moveCard cannot be null, possibly null value provided
$sourceShares = $this->getShares($sourceAddressBookId);
$targetShares = $this->getShares($targetAddressBookId);
$sourceAddressBookRow = $this->getAddressBookById($sourceAddressBookId);
$this->dispatcher->dispatchTyped(new CardMovedEvent($sourceAddressBookId, $sourceAddressBookRow, $targetAddressBookId, $targetAddressBookRow, $sourceShares, $targetShares, $object));

Check notice

Code scanning / Psalm

PossiblyNullArgument

Argument 2 of OCA\DAV\Events\CardMovedEvent::__construct cannot be null, possibly null value provided
@tcitworld tcitworld force-pushed the add-IMoveTarget-support-to-addressbooks branch from 7ac0d9a to b4520e9 Compare March 21, 2023 18:03
@miaulalala
Copy link
Contributor

/rebase

@nextcloud-command nextcloud-command force-pushed the add-IMoveTarget-support-to-addressbooks branch from b4520e9 to 7011490 Compare April 24, 2023 12:12
@miaulalala
Copy link
Contributor

Psalm isn't happy

Error: 3rdparty/sabre/dav/lib/CardDAV/Card.php:85:25: MoreSpecificImplementedParamType: Argument 1 of  
 Sabre\CardDAV\Card::put has the more specific type 'string', expecting 'resource|string' as defined by  
 Sabre\DAV\IFile::put (see https://psalm.dev/140)

Drone failure is contacts-menu as usual

@tcitworld tcitworld force-pushed the add-IMoveTarget-support-to-addressbooks branch from 7011490 to 92f90dc Compare April 26, 2023 15:03
@tcitworld
Copy link
Member Author

For the psalm issue, I guess I need to update the baseline to add this. Done.

For the contacts menu test failure, this time it might be related. Does it fails elsewhere currently?

@tcitworld tcitworld force-pushed the add-IMoveTarget-support-to-addressbooks branch from 92f90dc to 50b652d Compare April 26, 2023 15:04
apps/dav/lib/CardDAV/Card.php Outdated Show resolved Hide resolved
@tcitworld tcitworld force-pushed the add-IMoveTarget-support-to-addressbooks branch from 50b652d to a252526 Compare April 27, 2023 15:01
@ChristophWurst ChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Apr 27, 2023
This was referenced May 3, 2023
@szaimen
Copy link
Contributor

szaimen commented May 16, 2023

conflicts

@szaimen szaimen added 2. developing Work in progress and removed 4. to release Ready to be released and/or waiting for tests to finish labels May 16, 2023
…ddressBook

This allows to just UPDATE the card row instead of deleting it and reinsert it. It's very similar to #30120 for calendars.

As we need the addressbookid exposed, this introduces OCA\DAV\CardDAV\Card that extends Sabre's.

I chose specifically NOT to auto-inject LoggerInterface in Addressbook like in #30120 because the chain of DI is huge just for ONE simple call and it would break an existing dirty call (OCA\Contacts calling OCA\DAV) of ContactsManager in Contacts: nextcloud/contacts#1722 (in SocialApiService), but this is debatable.

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
@tcitworld tcitworld force-pushed the add-IMoveTarget-support-to-addressbooks branch from a252526 to 13a3ebd Compare May 16, 2023 09:42
@szaimen szaimen enabled auto-merge May 16, 2023 09:44
@szaimen szaimen added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels May 16, 2023
@nextcloud nextcloud deleted a comment from miaulalala May 16, 2023
@szaimen
Copy link
Contributor

szaimen commented May 16, 2023

CI failure unrelated afaics

@szaimen szaimen disabled auto-merge May 16, 2023 17:01
@szaimen szaimen merged commit dc1b68c into master May 16, 2023
@szaimen szaimen deleted the add-IMoveTarget-support-to-addressbooks branch May 16, 2023 17:01
@blizzz blizzz mentioned this pull request May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish feature: carddav Related to CardDAV internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants