Skip to content

enh(contacts): show/hide addressbooks for all - #38397

Merged
kesselb merged 1 commit into
masterfrom
enh/contacts/hide-adressbook-option
Jul 18, 2023
Merged

enh(contacts): show/hide addressbooks for all#38397
kesselb merged 1 commit into
masterfrom
enh/contacts/hide-adressbook-option

Conversation

@JohannesGGE

@JohannesGGEJohannesGGE commented May 22, 2023

Copy link
Copy Markdown
Contributor

Summary

TODO

  • ...

Checklist

@JohannesGGE

Copy link
Copy Markdown
ContributorAuthor

Due to the different implementation of the recently contacted addressbook, the call for changing the enabled property can't be executed, and an "addressbook is immutable" is thrown in apps/contactsinteraction/lib/AddressBook.php::propPatch().

Other addressbooks call apps/dav/lib/CardDAV/AddressBook.php::propPatch()

As far as I can tell the only needed code is the DB update of apps/dav/lib/DAV/CustomPropertiesBackend.php::updateProperties() to have a working enable/disable for the recently contacted addressbook.

@JohannesGGE

Copy link
Copy Markdown
ContributorAuthor

Recently contacted address book will be tackled in another issue.

}

public function propPatch(PropPatch $propPatch) {
if (isset($this->addressBookInfo['{http://owncloud.org/ns}owner-principal'])) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this dropped?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

owner-principal seems to be set if the address book is shared, system or recently contacted. Own address books don't have this prop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change also surprised me.

Apparently, this was added before the CustomPropertiesBackend: 95e218b

If we throw forbidden here, the CustomPropertiesBackend::propPatch is not executed?

Comment threadapps/dav/lib/CardDAV/AddressBook.php Outdated
]
],
[
'privilege' => '{DAV:}write-properties',

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this means users are now allowed to update properties of all address books, right? are there any property changes we might not want? e.g. rename.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just tested it with renaming, and it turns out the change of the name is not stored as a user prop but changes the real name, so the owner sees the change as well. I'll have a look in the code again to check where the distinction between the props is made.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tcitworld As far as I understand it, the propPatch() in CustomPropertiesBackend.php is just called if the prop is a user prop. So the distinction is done somewhere before

@ChristophWurstChristophWurst added feature: dav feature: caldav Related to CalDAV internals labels May 24, 2023
@JohannesGGEJohannesGGE added 2. developing Work in progress and removed 3. to review Waiting for reviews labels May 24, 2023
@JohannesGGE
JohannesGGE marked this pull request as draft May 25, 2023 10:24
@JohannesGGE

Copy link
Copy Markdown
ContributorAuthor

The addressbook is now checked for sharing. If it is shared the props will be saved as userProps. So even if the addressbook is renamed by user that is not the owner (not possible in the contacts app yet), the owners addressbook name isn't changed. For the case the addressbook has a userProp name, this name is shown now.

Comment on lines +179 to +193
// substr of addressbooks/ => path is inside the CardDAV component
// three '/' => this a addressbook (no addressbook-home nor contact object)
if (substr($path, 0, 13) === 'addressbooks/' && substr_count($path, '/') === 3) {
$allRequestedProps = $propFind->getRequestedProperties();
$customPropertiesForShares = [
'{DAV:}displayname',
];

foreach ($customPropertiesForShares as $customPropertyForShares) {
if (in_array($customPropertyForShares, $allRequestedProps)) {
$requestedProps[] = $customPropertyForShares;
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: I think there's a way to factorize this block with the block above in a single function which takes calendars and addressbooks specifics as parameters.

@JohannesGGEJohannesGGE added 3. to review Waiting for reviews and removed 2. developing Work in progress labels Jun 13, 2023
@JohannesGGE
JohannesGGE marked this pull request as ready for review June 13, 2023 08:49
@JohannesGGE
JohannesGGEforce-pushed the enh/contacts/hide-adressbook-option branch from 556aa6b to 60c9eb5CompareJune 23, 2023 15:03
Comment threadapps/dav/lib/DAV/CustomPropertiesBackend.php Outdated
Comment threadapps/dav/lib/DAV/CustomPropertiesBackend.php Outdated
@JohannesGGE
JohannesGGEforce-pushed the enh/contacts/hide-adressbook-option branch from 60c9eb5 to 7594644CompareJuly 7, 2023 07:44
@JohannesGGE
JohannesGGEforce-pushed the enh/contacts/hide-adressbook-option branch from 7594644 to dbb174aCompareJuly 10, 2023 11:38
Signed-off-by: Johannes Merkel <mail@johannesgge.de>
@JohannesGGE
JohannesGGEforce-pushed the enh/contacts/hide-adressbook-option branch from dbb174a to bb80295CompareJuly 10, 2023 11:39
@kesselb

Copy link
Copy Markdown
Contributor

nitpick: enh(contacts) should be feat(contacts) according to https://www.conventionalcommits.org/en/v1.0.0/

@kesselbkesselb added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Jul 18, 2023

@kesselbkesselb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done 🎉

@miaulalala

Copy link
Copy Markdown
Contributor

/backport to stable27

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishenhancementfeature: caldavRelated to CalDAV internalsfeature: dav

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new option to hide an address book's contacts without disabling the address book

5 participants

@JohannesGGE@kesselb@miaulalala@ChristophWurst@tcitworld