allow IAM to send Workspace notifications
This commit is contained in:
parent
ff33c24f7c
commit
3f78a78926
|
@ -499,11 +499,27 @@ public class Notifications {
|
|||
Status status = Status.OK;
|
||||
boolean deliveryResult = false;
|
||||
try {
|
||||
GCubeUser senderUser = null;
|
||||
SocialNetworkingUser user = null;
|
||||
// check if the token belongs to an application token. In this case use J.A.R.V.I.S (the username used to communicate with Liferay)
|
||||
String username = null;
|
||||
String fullName = "";
|
||||
logger.debug("workspace notifications type is " + event.getType());
|
||||
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
||||
UserManager um = UserManagerWSBuilder.getInstance().getUserManager();
|
||||
GCubeUser senderUser = um.getUserByUsername(username);
|
||||
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
||||
logger.debug("Workspace Notification called by " + caller.getClient().getId() + " isUser?"+TokensUtils.isUserToken(caller));
|
||||
if(!TokensUtils.isUserToken(caller)){
|
||||
GCubeUser jarvis = UserManagerWSBuilder.getInstance().getUserManager().getUserByEmail(LiferayJSONWsCredentials.getSingleton().getUser());
|
||||
SecurityTokenProvider.instance.set(LiferayJSONWsCredentials.getSingleton().getNotifierUserToken());
|
||||
username = jarvis.getUsername();
|
||||
fullName = caller.getClient().getId().replace("service-account-", ""); // the actual name of the IAM Client
|
||||
senderUser = um.getUserByUsername(username);
|
||||
user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), fullName, senderUser.getUserAvatarURL());
|
||||
}else{
|
||||
username = caller.getClient().getId();
|
||||
senderUser = um.getUserByUsername(username);
|
||||
user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
||||
}
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
||||
|
||||
String[] idsToNotify = event.getIdsToNotify();
|
||||
|
|
Loading…
Reference in New Issue