diff options
author | blizzz <blizzz@arthur-schiwon.de> | 2019-10-01 12:17:35 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-01 12:17:35 +0200 |
commit | 47ab961aa79f8b03cefe41ce000628e076cb2484 (patch) | |
tree | d39c9e22b4483002d8ea735e43e01db345d80713 | |
parent | d68f30e72550ff2ce79e916142915c240458bbc5 (diff) | |
parent | d33e0be2f1e2b276fc99b7f22cd5496cfc6c18a4 (diff) | |
download | nextcloud-server-47ab961aa79f8b03cefe41ce000628e076cb2484.tar.gz nextcloud-server-47ab961aa79f8b03cefe41ce000628e076cb2484.zip |
Merge pull request #17001 from nextcloud/fix/noid/addressbookchanges-avatar
reduce adressbook change events and handling
-rw-r--r-- | apps/user_ldap/lib/User_Proxy.php | 2 | ||||
-rw-r--r-- | lib/private/Avatar/UserAvatar.php | 8 | ||||
-rw-r--r-- | tests/lib/Avatar/UserAvatarTest.php | 3 |
3 files changed, 7 insertions, 6 deletions
diff --git a/apps/user_ldap/lib/User_Proxy.php b/apps/user_ldap/lib/User_Proxy.php index ccc82760b02..a3f9e67764e 100644 --- a/apps/user_ldap/lib/User_Proxy.php +++ b/apps/user_ldap/lib/User_Proxy.php @@ -253,7 +253,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, * @return boolean either the user can or cannot */ public function canChangeAvatar($uid) { - return $this->handleRequest($uid, 'canChangeAvatar', array($uid)); + return $this->handleRequest($uid, 'canChangeAvatar', [$uid], true); } /** diff --git a/lib/private/Avatar/UserAvatar.php b/lib/private/Avatar/UserAvatar.php index 2db65634e8c..f96ec93d5d0 100644 --- a/lib/private/Avatar/UserAvatar.php +++ b/lib/private/Avatar/UserAvatar.php @@ -97,7 +97,7 @@ class UserAvatar extends Avatar { $this->validateAvatar($img); - $this->remove(); + $this->remove(true); $type = $this->getAvatarImageType($img); $file = $this->folder->newFile('avatar.' . $type); $file->putContent($data); @@ -193,7 +193,7 @@ class UserAvatar extends Avatar { * @throws \OCP\Files\NotPermittedException * @throws \OCP\PreConditionNotMetException */ - public function remove() { + public function remove(bool $silent = false) { $avatars = $this->folder->getDirectoryListing(); $this->config->setUserValue($this->user->getUID(), 'avatar', 'version', @@ -203,7 +203,9 @@ class UserAvatar extends Avatar { $avatar->delete(); } $this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true'); - $this->user->triggerChange('avatar', ''); + if(!$silent) { + $this->user->triggerChange('avatar', ''); + } } /** diff --git a/tests/lib/Avatar/UserAvatarTest.php b/tests/lib/Avatar/UserAvatarTest.php index 061866bedb0..2ce9266cf4d 100644 --- a/tests/lib/Avatar/UserAvatarTest.php +++ b/tests/lib/Avatar/UserAvatarTest.php @@ -223,8 +223,7 @@ class UserAvatarTest extends \Test\TestCase { $this->config->expects($this->once()) ->method('getUserValue'); - // One on remove and once on setting the new avatar - $this->user->expects($this->exactly(2))->method('triggerChange'); + $this->user->expects($this->exactly(1))->method('triggerChange'); $this->avatar->set($image->data()); } |