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;
|
Status status = Status.OK;
|
||||||
boolean deliveryResult = false;
|
boolean deliveryResult = false;
|
||||||
try {
|
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());
|
logger.debug("workspace notifications type is " + event.getType());
|
||||||
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
SocialNetworkingSite site = SocialNetworkingSiteFinder.getSocialNetworkingSiteFromScope(context);
|
||||||
UserManager um = UserManagerWSBuilder.getInstance().getUserManager();
|
UserManager um = UserManagerWSBuilder.getInstance().getUserManager();
|
||||||
GCubeUser senderUser = um.getUserByUsername(username);
|
logger.debug("Workspace Notification called by " + caller.getClient().getId() + " isUser?"+TokensUtils.isUserToken(caller));
|
||||||
SocialNetworkingUser user = new SocialNetworkingUser(senderUser.getUsername(), senderUser.getEmail(), senderUser.getFullname(), senderUser.getUserAvatarURL());
|
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);
|
NotificationsManager nm = new ApplicationNotificationsManager(UserManagerWSBuilder.getInstance().getUserManager(), site, context, user);
|
||||||
|
|
||||||
String[] idsToNotify = event.getIdsToNotify();
|
String[] idsToNotify = event.getIdsToNotify();
|
||||||
|
|
Loading…
Reference in New Issue