Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/user_ldap/lib/User_Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public function setDisplayName($uid, $displayName) {
* @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);
}

/**
Expand Down
8 changes: 5 additions & 3 deletions lib/private/Avatar/UserAvatar.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function set($data) {

$this->validateAvatar($img);

$this->remove();
$this->remove(true);
$type = $this->getAvatarImageType($img);
$file = $this->folder->newFile('avatar.' . $type);
$file->putContent($data);
Expand Down Expand Up @@ -193,7 +193,7 @@ private function validateAvatar(IImage $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',
Expand All @@ -203,7 +203,9 @@ public function remove() {
$avatar->delete();
}
$this->config->setUserValue($this->user->getUID(), 'avatar', 'generated', 'true');
$this->user->triggerChange('avatar', '');
if(!$silent) {
$this->user->triggerChange('avatar', '');
}
}

/**
Expand Down
3 changes: 1 addition & 2 deletions tests/lib/Avatar/UserAvatarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,7 @@ public function testSetAvatar() {
$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());
}
Expand Down