summaryrefslogtreecommitdiffstats
path: root/lib/private/Server.php
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2017-12-13 20:21:00 +0100
committerJulius Härtl <jus@bitgrid.net>2017-12-19 18:49:26 +0100
commita4ca92f29a24de2868c7149c2cff8550bc0ca55e (patch)
treef4c423bd022417c1e034e5b30caffa92f67b29f4 /lib/private/Server.php
parent6371b765984a8dc9201f37ca89ce2dcf5d6fb78c (diff)
downloadnextcloud-server-a4ca92f29a24de2868c7149c2cff8550bc0ca55e.tar.gz
nextcloud-server-a4ca92f29a24de2868c7149c2cff8550bc0ca55e.zip
Remove generated avatar on displayname change
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Server.php')
-rw-r--r--lib/private/Server.php19
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 44f5ea80cb7..4a851d67226 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -394,9 +394,10 @@ class Server extends ServerContainer implements IServerContainer {
$userSession->listen('\OC\User', 'logout', function () {
\OC_Hook::emit('OC_User', 'logout', array());
});
- $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) {
+ $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value, $oldValue) use ($dispatcher) {
/** @var $user \OC\User\User */
\OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value, 'old_value' => $oldValue));
+ $dispatcher->dispatch('OCP\IUser::changeUser', new GenericEvent($user, ['feature' => $feature, 'oldValue' => $oldValue, 'value' => $value]));
});
return $userSession;
});
@@ -1175,6 +1176,22 @@ class Server extends ServerContainer implements IServerContainer {
$logger->info('Could not cleanup avatar of ' . $user->getUID());
}
});
+
+ $dispatcher->addListener('OCP\IUser::changeUser', function (GenericEvent $e) {
+ $manager = $this->getAvatarManager();
+ /** @var IUser $user */
+ $user = $e->getSubject();
+ $feature = $e->getArgument('feature');
+ $oldValue = $e->getArgument('oldValue');
+ $value = $e->getArgument('value');
+
+ try {
+ $avatar = $manager->getAvatar($user->getUID());
+ $avatar->userChanged($feature, $oldValue, $value);
+ } catch (NotFoundException $e) {
+ // no avatar to remove
+ }
+ });
}
/**