|
|
|
@ -34,6 +34,7 @@ import org.gcube.applicationsupportlayer.social.mailing.AppType;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.mailing.SocialMailingUtil;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
|
|
|
|
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
|
|
|
|
import org.gcube.common.authorization.library.provider.UserInfo;
|
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
|
import org.gcube.common.scope.api.ScopeProvider;
|
|
|
|
@ -258,13 +259,23 @@ public class PeriodicTask implements Runnable {
|
|
|
|
|
|
|
|
|
|
_log.debug("Found message reply, subject: " + subject + " body: " + messageText);
|
|
|
|
|
String newMessageId = null;
|
|
|
|
|
List<String> recipientIds = null;
|
|
|
|
|
List<String> recipientIds = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
setAuthorizationToken(fakeSession);
|
|
|
|
|
String username = fakeSession.getUsername();
|
|
|
|
|
String scope = fakeSession.getScope();
|
|
|
|
|
ScopeProvider.instance.set(scope);
|
|
|
|
|
_log.debug("calling service token on scope " + scope);
|
|
|
|
|
List<String> userRoles = new ArrayList<>();
|
|
|
|
|
userRoles.add(DEFAULT_ROLE);
|
|
|
|
|
fakeSession.setSecurityToken(null);
|
|
|
|
|
String token = authorizationService().generateUserToken(new UserInfo(username, userRoles), scope);
|
|
|
|
|
SecurityTokenProvider.instance.set(token);
|
|
|
|
|
MessageManagerClient mmClient = AbstractPlugin.messages().build();
|
|
|
|
|
org.gcube.common.storagehub.model.messages.Message theMessage = mmClient.get(messageId);
|
|
|
|
|
|
|
|
|
|
recipientIds = Arrays.asList(theMessage.getAddresses());
|
|
|
|
|
String[] addresses = theMessage.getAddresses();
|
|
|
|
|
for (int i = 0; i < addresses.length; i++) {
|
|
|
|
|
recipientIds.add(addresses[i]);
|
|
|
|
|
}
|
|
|
|
|
//add the sender and remove the person who is replying from the recipients
|
|
|
|
|
String sender = theMessage.getSender().getUserName();
|
|
|
|
|
String originalText = theMessage.getBody();
|
|
|
|
|