Сreate a comment on behalf of the system user

plugin-sdk
comment
api
plugin-development
plugin

#1

I created a plugin that adds comments to the pool request when it is created. This comment is created on behalf of the user who created the pool request .

Can I specify an account from which to create these comments?


#2

You can use SecurityService.impersonating( ... )

Cheers - Ulrich
https://www.izymes.com


#3

Thanks.
Yeap, already find this code. Working in Bitbucket 4.11.1

ApplicationUser user = userService.getUserBySlug("username");

securityService.impersonating(user, "reason").call(new Operation<Object, RuntimeException>() {
    @Override
    public Object perform() throws RuntimeException {
        //you code
        return null;
    }
});