Merge pull request #17001 from nextcloud/fix/noid/addressbookchanges-avatar
reduce adressbook change events and handling
This commit is contained in:
commit
47ab961aa7
|
@ -253,7 +253,7 @@ class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface,
|
||||||
* @return boolean either the user can or cannot
|
* @return boolean either the user can or cannot
|
||||||
*/
|
*/
|
||||||
public function canChangeAvatar($uid) {
|
public function canChangeAvatar($uid) {
|
||||||
return $this->handleRequest($uid, 'canChangeAvatar', array($uid));
|
return $this->handleRequest($uid, 'canChangeAvatar', [$uid], true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -97,7 +97,7 @@ class UserAvatar extends Avatar {
|
||||||
|
|
||||||
$this->validateAvatar($img);
|
$this->validateAvatar($img);
|
||||||
|
|
||||||
$this->remove();
|
$this->remove(true);
|
||||||
$type = $this->getAvatarImageType($img);
|
$type = $this->getAvatarImageType($img);
|
||||||
$file = $this->folder->newFile('avatar.' . $type);
|
$file = $this->folder->newFile('avatar.' . $type);
|
||||||
$file->putContent($data);
|
$file->putContent($data);
|
||||||
|
@ -193,7 +193,7 @@ class UserAvatar extends Avatar {
|
||||||
* @throws \OCP\Files\NotPermittedException
|
* @throws \OCP\Files\NotPermittedException
|
||||||
* @throws \OCP\PreConditionNotMetException
|
* @throws \OCP\PreConditionNotMetException
|
||||||
*/
|
*/
|
||||||
public function remove() {
|
public function remove(bool $silent = false) {
|
||||||
$avatars = $this->folder->getDirectoryListing();
|
$avatars = $this->folder->getDirectoryListing();
|
||||||
|
|
||||||
$this->config->setUserValue($this->user->getUID(), 'avatar', 'version',
|
$this->config->setUserValue($this->user->getUID(), 'avatar', 'version',
|
||||||
|
@ -203,7 +203,9 @@ class UserAvatar extends Avatar {
|
||||||
$avatar->delete();
|
$avatar->delete();
|
||||||
}
|
}
|
||||||
$this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
|
$this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
|
||||||
$this->user->triggerChange('avatar', '');
|
if(!$silent) {
|
||||||
|
$this->user->triggerChange('avatar', '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -223,8 +223,7 @@ class UserAvatarTest extends \Test\TestCase {
|
||||||
$this->config->expects($this->once())
|
$this->config->expects($this->once())
|
||||||
->method('getUserValue');
|
->method('getUserValue');
|
||||||
|
|
||||||
// One on remove and once on setting the new avatar
|
$this->user->expects($this->exactly(1))->method('triggerChange');
|
||||||
$this->user->expects($this->exactly(2))->method('triggerChange');
|
|
||||||
|
|
||||||
$this->avatar->set($image->data());
|
$this->avatar->set($image->data());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue