Hi,
Is there a way to delete or change the user avatar by using script runner?
With the EU GDPR / EU DSVGO we must remove personal user data after a employee left the company.
Some users upload own pictures into JIRA and I need to remove or change it to a default avatar when a user is set to inactive by LDAP.
As far as I know the avatar is saved as base64 in the database. But we don't want to change something direct in the database.
I should get the users with a change of this example script: https://www.adaptavist.com/doco/display/SFJ/Automatically+deactivate+inactive+JIRA+users
I found a script (https://community.atlassian.com/t5/Adaptavist-questions/uploading-a-user-avatar-with-scriptrunner/qaq-p/831020) that is doing some avatar upload but isn't working as expected.
Has anybody created a script that is working?
Best Regards
Manuel
import com.atlassian.jira.avatar.Avatar import com.atlassian.jira.avatar.AvatarManager import com.atlassian.jira.avatar.AvatarService import com.atlassian.jira.user.ApplicationUser import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.bc.user.search.UserSearchParams import com.atlassian.jira.bc.user.search.UserSearchService AvatarService avatarService = ComponentAccessor.getAvatarService() UserSearchService userSearchService = ComponentAccessor.getUserSearchService() AvatarManager avatarManager = ComponentAccessor.getAvatarManager() //Query to get inactive Users UserSearchParams userSearchParams = (new UserSearchParams.Builder()).allowEmptyQuery(true).includeActive(false).includeInactive(true).maxResults(10000).build() for (ApplicationUser appUser : userSearchService.findUsers("", userSearchParams)) { /* This will reset the Avatar, but we need to DELETE own Avatars on the Filesystem too. avatarService.setCustomUserAvatar(appUser,appUser,0) */ if (avatarService.hasCustomUserAvatar(appUser, appUser)) { def a = avatarManager.getCustomAvatarsForOwner(Avatar.Type.USER, appUser.getKey()) a.each { b -> avatarManager.delete(b.getId(), true) log.warn("Deleted Avatar " + b.id + " " + b.fileName + " for " + appUser.displayName) } } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
its not hard. Please note that "setCustomerAvatar" is not enough here, since you have to delete them to fulfill the GDPR Requirments.
Basically you use the "userSearcherService" to get all inactive users, loop over them and use AvatarManager to delete the CustomAvatars.
We've configured this as a Service so it runs every month. If you still need help - i can share you my code as soon as im back in the office.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manuel,
i've pushed my code to github: https://github.com/prohrberg/jira-snippet/blob/master/Common/deleteInactiveUsersAvatar.groovy
Regards,
Patrick
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Patrick - Do you still have this code?
I have 2.5 GB of avatars, that I need to delete :-)
Thanks
Morten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
Have you tried setCustomUserAvatar method?
From JIRA API https://docs.atlassian.com/software/jira/docs/api/7.6.1/com/atlassian/jira/avatar/AvatarService.html it sets a custom avatar for a given user.
setCustomUserAvatar(ApplicationUser remoteUser, ApplicationUser user, Long avatarId)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.