Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
673267cd
Unverified
Commit
673267cd
authored
4 years ago
by
Morris Jobke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #19929 from nextcloud/bugfix/user-delete-avatar
Delete avatar if a user is deleted
parents
1738e17e
d74e9045
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/private/Avatar/AvatarManager.php
+16
-0
16 additions, 0 deletions
lib/private/Avatar/AvatarManager.php
lib/private/User/User.php
+5
-0
5 additions, 0 deletions
lib/private/User/User.php
with
21 additions
and
0 deletions
lib/private/Avatar/AvatarManager.php
+
16
−
0
View file @
673267cd
...
...
@@ -33,8 +33,10 @@ declare(strict_types=1);
namespace
OC\Avatar
;
use
OC\User\Manager
;
use
OC\User\NoUserException
;
use
OCP\Files\IAppData
;
use
OCP\Files\NotFoundException
;
use
OCP\Files\NotPermittedException
;
use
OCP\IAvatar
;
use
OCP\IAvatarManager
;
use
OCP\IConfig
;
...
...
@@ -125,6 +127,20 @@ class AvatarManager implements IAvatarManager {
}
}
public
function
deleteUserAvatar
(
string
$userId
):
void
{
try
{
$folder
=
$this
->
appData
->
getFolder
(
$userId
);
$folder
->
delete
();
}
catch
(
NotFoundException
$e
)
{
$this
->
logger
->
debug
(
"No cache for the user
$userId
. Ignoring avatar deletion"
);
}
catch
(
NotPermittedException
$e
)
{
$this
->
logger
->
error
(
"Unable to delete user avatars for
$userId
. gnoring avatar deletion"
);
}
catch
(
NoUserException
$e
)
{
$this
->
logger
->
debug
(
"User
$userId
not found. gnoring avatar deletion"
);
}
$this
->
config
->
deleteUserValue
(
$userId
,
'avatar'
,
'generated'
);
}
/**
* Returns a GuestAvatar.
*
...
...
This diff is collapsed.
Click to expand it.
lib/private/User/User.php
+
5
−
0
View file @
673267cd
...
...
@@ -36,6 +36,7 @@
namespace
OC\User
;
use
OC\Accounts\AccountManager
;
use
OC\Avatar\AvatarManager
;
use
OC\Files\Cache\Storage
;
use
OC\Hooks\Emitter
;
use
OC_Helper
;
...
...
@@ -238,6 +239,10 @@ class User implements IUser {
\OC
::
$server
->
getCommentsManager
()
->
deleteReferencesOfActor
(
'users'
,
$this
->
uid
);
\OC
::
$server
->
getCommentsManager
()
->
deleteReadMarksFromUser
(
$this
);
/** @var IAvatarManager $avatarManager */
$avatarManager
=
\OC
::
$server
->
query
(
AvatarManager
::
class
);
$avatarManager
->
deleteUserAvatar
(
$this
->
uid
);
$notification
=
\OC
::
$server
->
getNotificationManager
()
->
createNotification
();
$notification
->
setUser
(
$this
->
uid
);
\OC
::
$server
->
getNotificationManager
()
->
markProcessed
(
$notification
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment