Adding feature #21345

This commit is contained in:
Luca Frosini 2021-06-21 17:09:49 +02:00
parent 73db422373
commit eb27d67845
4 changed files with 33 additions and 3 deletions

View File

@ -4,9 +4,9 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
## [v2.1.0-SNAPSHOT]
-
- Added query parameter social_post_notification to override default VRE behaviour [#21345]
- Users are created/references in the form <Surname Name> and not vice-versa [#21479]
- Starting to add support for moderation [#21342]
## [v2.0.0]

View File

@ -52,7 +52,7 @@ public class CKANInstance {
protected String ckanURL;
protected String sysAdminToken;
protected boolean socialPostEnabled;
protected boolean notificationToUsersEnabled;
protected Boolean notificationToUsersEnabled;
protected String uriResolverURL;
protected boolean moderationEnabled;

View File

@ -593,6 +593,17 @@ public class CKANPackage extends CKAN {
socialPost.setItemURL(catalogueItemURL);
socialPost.setTags(arrayNode);
socialPost.setItemTitle(title);
Boolean notification = null;
try {
MultivaluedMap<String,String> queryParameters = uriInfo.getQueryParameters();
if(queryParameters.containsKey(GCatConstants.SOCIAL_POST_NOTIFICATION_QUERY_PARAMETER)) {
notification = Boolean.parseBoolean(queryParameters.getFirst(GCatConstants.SOCIAL_POST_NOTIFICATION_QUERY_PARAMETER));
}
} catch(Exception e) {
}
socialPost.setNotification(notification);
socialPost.start();
} else {
logger.info("The request explicitly disabled the Social Post.");

View File

@ -49,6 +49,7 @@ public class SocialPost extends Thread {
protected String itemURL;
protected String itemTitle;
protected List<String> tags;
protected Boolean notification;
public SocialPost() throws Exception {
super();
@ -103,6 +104,14 @@ public class SocialPost extends Thread {
}
}
public Boolean isNotification() {
return notification;
}
public void setNotification(Boolean notification) {
this.notification = notification;
}
@Override
public void run() {
@ -117,6 +126,15 @@ public class SocialPost extends Thread {
logger.info("Going to send Social Post about the Item {} available at {}", itemID, itemURL);
boolean notifyUsers = instance.isNotificationToUsersEnabled();
if(notification != null) {
if(notifyUsers) {
notifyUsers = notifyUsers && notification;
}else {
notifyUsers = notification;
}
}
// write notification post
sendSocialPost(notifyUsers);
@ -182,4 +200,5 @@ public class SocialPost extends Thread {
}
}
}