-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove avatar on user deletion #6668
Conversation
lib/private/Server.php
Outdated
$avatar = $manager->getAvatar($user->getUID()); | ||
$avatar->remove(); | ||
} catch (\Exception $e) { | ||
// Ignore exceptions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO would still make sense to log this, even if it's just level debug
or info
but if this code ever triggers errors nobody would notice and it makes this feature useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough, let me do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could have removed the comment 🙊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still kind of ignore it. We just also log it :P
Codecov Report
@@ Coverage Diff @@
## master #6668 +/- ##
============================================
- Coverage 52.66% 51.09% -1.57%
- Complexity 23542 24865 +1323
============================================
Files 1439 1596 +157
Lines 80218 94608 +14390
Branches 0 1367 +1367
============================================
+ Hits 42246 48339 +6093
- Misses 37972 46269 +8297
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
$dispatcher = $this->getEventDispatcher(); | ||
|
||
// Delete avatar on user deletion | ||
$dispatcher->addListener('OCP\IUser::preDelete', function(GenericEvent $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Server container is not the proper place to put place this imho. Rather the AvatarManager.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't put it in the avatarmanager as that is only called once we need the avatarmanager.
Like if you delete a user via the provisioning API. The avatarManager is never initialised. And as such there is nothing listening in there as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, rights, that's why all the other listeners are registered in base.php :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: a service provider, as the Laravel framework calls them, would be nice in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :P But a bit out of scope. I moved it for this to the server as base.php is a long huge list of code and functions. IMO this has more of a place in Server.php to link everything together than in base.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes :P But a bit out of scope
I know. But well, maybe you feel highly motivated during a late night hacking session at the hackweek and want to integrate that :P
tests are failing |
@rullzer Ping |
@icewind1991 the errors happen in |
🏓 |
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
f0c291e
to
10aa287
Compare
@icewind1991 Still failing: |
Signed-off-by: Robin Appelman <robin@icewind.nl>
76c74a9
to
05d2f61
Compare
all fixed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👍
Fixes #6621
Basically I added a new event to the event dispatcher:
OCP\IUser::preDelete
And then connected this to remove the avatar.