File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3535use OC \User \Manager ;
3636use OCP \Files \IAppData ;
3737use OCP \Files \NotFoundException ;
38+ use OCP \Files \NotPermittedException ;
3839use OCP \IAvatar ;
3940use OCP \IAvatarManager ;
4041use OCP \IConfig ;
@@ -125,6 +126,20 @@ public function clearCachedAvatars() {
125126 }
126127 }
127128
129+ /**
130+ * @param string $userId
131+ * @throws NotPermittedException
132+ */
133+ public function deleteUserAvatar (string $ userId ) {
134+ try {
135+ $ folder = $ this ->appData ->getFolder ($ userId );
136+ $ folder ->delete ();
137+ } catch (NotFoundException $ e ) {
138+ $ this ->logger ->debug ("No cache for the user $ userId. Ignoring... " );
139+ }
140+ $ this ->config ->deleteUserValue ($ userId , 'avatar ' , 'generated ' );
141+ }
142+
128143 /**
129144 * Returns a GuestAvatar.
130145 *
Original file line number Diff line number Diff line change 3535namespace OC \User ;
3636
3737use OC \Accounts \AccountManager ;
38+ use OC \Avatar \AvatarManager ;
3839use OC \Files \Cache \Storage ;
3940use OC \Hooks \Emitter ;
4041use OC_Helper ;
@@ -237,6 +238,10 @@ public function delete() {
237238 \OC ::$ server ->getCommentsManager ()->deleteReferencesOfActor ('users ' , $ this ->uid );
238239 \OC ::$ server ->getCommentsManager ()->deleteReadMarksFromUser ($ this );
239240
241+ /** @var IAvatarManager $avatarManager */
242+ $ avatarManager = \OC ::$ server ->query (AvatarManager::class);
243+ $ avatarManager ->deleteUserAvatar ($ this ->uid );
244+
240245 $ notification = \OC ::$ server ->getNotificationManager ()->createNotification ();
241246 $ notification ->setUser ($ this ->uid );
242247 \OC ::$ server ->getNotificationManager ()->markProcessed ($ notification );
You can’t perform that action at this time.
0 commit comments