Skip to content
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

Merged
merged 3 commits into from
Dec 11, 2017
Merged

Remove avatar on user deletion #6668

merged 3 commits into from
Dec 11, 2017

Conversation

rullzer
Copy link
Member

@rullzer rullzer commented Sep 27, 2017

Fixes #6621

Basically I added a new event to the event dispatcher: OCP\IUser::preDelete
And then connected this to remove the avatar.

@rullzer rullzer added this to the Nextcloud 13 milestone Sep 27, 2017
$avatar = $manager->getAvatar($user->getUID());
$avatar->remove();
} catch (\Exception $e) {
// Ignore exceptions
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

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 🙊

Copy link
Member Author

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
Copy link

codecov bot commented Oct 30, 2017

Codecov Report

Merging #6668 into master will decrease coverage by 1.57%.
The diff coverage is 84.21%.

@@             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
Impacted Files Coverage Δ Complexity Δ
lib/private/Files/View.php 84.38% <100%> (+0.16%) 373 <0> (+2) ⬆️
lib/private/Server.php 81.93% <80%> (-0.06%) 133 <6> (+5)
.../tests/Unit/Collaboration/CommentersSorterTest.php 25.55% <0%> (-66.45%) 6% <0%> (ø)
apps/sharebymail/tests/SettingsTest.php 52.17% <0%> (-47.83%) 3% <0%> (ø)
lib/private/Security/RateLimiting/Limiter.php 55.55% <0%> (-44.45%) 5% <0%> (ø)
settings/Controller/EncryptionController.php 54.71% <0%> (-38.84%) 8% <0%> (ø)
settings/Controller/GroupsController.php 64.61% <0%> (-35.39%) 9% <0%> (ø)
...ps/comments/tests/Unit/AppInfo/ApplicationTest.php 69.56% <0%> (-30.44%) 4% <0%> (ø)
apps/user_ldap/lib/Configuration.php 42.02% <0%> (-27.86%) 87% <0%> (ø)
apps/encryption/lib/Command/EnableMasterKey.php 75% <0%> (-25%) 5% <0%> (ø)
... and 342 more

Copy link
Member

@ChristophWurst ChristophWurst left a 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) {
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 :)

Copy link
Member

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.

https://laravel.com/docs/5.5/providers

Copy link
Member Author

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

Copy link
Member

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

@blizzz
Copy link
Member

blizzz commented Nov 3, 2017

tests are failing

@MorrisJobke MorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Nov 9, 2017
@MorrisJobke
Copy link
Member

@rullzer Ping

@rullzer
Copy link
Member Author

rullzer commented Nov 27, 2017

@icewind1991 the errors happen in UpdaterLegacyTest because we try to access storage that isn't there. I'm not sure but it seems those tests to evil stuff. Can you have a look?

@MorrisJobke
Copy link
Member

@icewind1991 the errors happen in UpdaterLegacyTest because we try to access storage that isn't there. I'm not sure but it seems those tests to evil stuff. Can you have a look?

🏓

@MorrisJobke MorrisJobke mentioned this pull request Dec 8, 2017
28 tasks
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
@MorrisJobke
Copy link
Member

@icewind1991 Still failing: PHP Fatal error: Call to a member function getStorage() on null in /drone/src/github.com/nextcloud/server/lib/private/Files/View.php on line 1365

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
Copy link
Member

all fixed

Copy link
Member

@MorrisJobke MorrisJobke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works 👍

@MorrisJobke MorrisJobke added 4. to release Ready to be released and/or waiting for tests to finish and removed 2. developing Work in progress labels Dec 11, 2017
@MorrisJobke MorrisJobke merged commit 4597187 into master Dec 11, 2017
@MorrisJobke MorrisJobke deleted the fix_6621 branch December 11, 2017 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4. to release Ready to be released and/or waiting for tests to finish bug enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants