Hello All,
I am trying to extend OOTB notifications. I see that on click of "Notifications" under "Following" as shown in image, the call "http://localhost:6503/content/usergenerated/asi/mongo/content/we-retail/community/en/blog/jcr:conten...subscriptions.social.json" is made. I see the social operation as "social:updatesubscriptions". In my custom blog post that uses OOTB comments component (extended) I do not have the click on the notifications. Rather I am looking to subscribe the user to notifications once the user adds first comment.
I am looking to know how I can trigger "social:updatesubscriptions" operation when a comment is made. Does anyone has any idea regarding this?
{
"_id" : "377619aad2e22b3aee28404ebbc9778c9dd472a0",
"type_s" : "notification",
"endid_s" : "/content/usergenerated/asi/mongo/content/path/blog/a-post",
"rel_type_s" : "RESOURCE",
"parent_id_s" : "/content/usergenerated/asi/mongo/content/sites/social/relationships",
"provider_id" : "/content/usergenerated/asi/mongo/content/sites/social/relationships/e499d8b9-7161-4049-9781-2ca46afe413d",
"report_suite" : "mongo",
"id" : "/content/usergenerated/asi/mongo/content/sites/social/relationships/e499d8b9-7161-4049-9781-2ca46afe413d",
"startid_s" : "testuser",
"timestamp" : NumberLong("1491498857673")
}
Any other actions I might be missing?
Note: Using AEM 6.2 SP1, FP2
Solved! Go to Solution.
Views
Replies
Total Likes
You can use either of the approaches you identified
Only issue with later approach is that it would be little less flexible in terms of adding your custom checks and logic. But with advantage of having no server side custom code.
Views
Replies
Total Likes
You can use either of the approaches you identified
Only issue with later approach is that it would be little less flexible in terms of adding your custom checks and logic. But with advantage of having no server side custom code.
Views
Replies
Total Likes
ashokkumar wrote...
You can use either of the approaches you identified
By using performBeforeActions of your custom comment social component operation extension and insert a relationship between current_user_id (as start node) and subscribed resource node (as end node) as per your required type (notification/email-subscription). only suggestion is to use appropriate SocialGraph and Relationship (Edge/Vertex) APIs in order to save your relationship in SRP. avoid creating content nodes directly with lower level of jcr apis or SRP API calls.
Another method is exploiting javascript and post operation you already identified, where you can intercept the “addReply” success callback for a comment (OOTB) or your own callback for custom comment component. make another ajax post call to “subscriptions.social.json” endpoint with operation = "social:updatesubscriptions", pass appropriate params to make notification set on that specific resource.
Only issue with later approach is that it would be little less flexible in terms of adding your custom checks and logic. But with advantage of having no server side custom code.
Thanks a lot Ashok for the response. I had
Talking about approach 1., wanted to double check something. I have been using an extension class that extends CommentOperationExtension and doing other pre actions in the beforeAction(). Is this the same method you are talking about above "performBeforeActions of your custom comment social component operation extension"?
"only suggestion is to use appropriate SocialGraph and Relationship (Edge/Vertex) APIs in order to save your relationship in SRP. avoid creating content nodes directly with lower level of jcr apis or SRP API calls. "
For above, I believe I am directly inserting an entry to MSRP like below
{ "_id" : "377619aad2e22b3aee28404ebbc9778c9dd472a0", "type_s" : "notification", "endid_s" : "/content/usergenerated/asi/mongo/content/myproj/en/home/comm/news/a-post", "rel_type_s" : "RESOURCE", "parent_id_s" : "/content/usergenerated/asi/mongo/content/sites/social/relationships", "provider_id" : "/content/usergenerated/asi/mongo/content/sites/social/relationships/e499d8b9-7161-4049-9781-2ca46afe413d", "report_suite" : "mongo", "id" : "/content/usergenerated/asi/mongo/content/sites/social/relationships/e499d8b9-7161-4049-9781-2ca46afe413d", "startid_s" : "testuser", "timestamp" : NumberLong("1491498857673") }
using code like below:
Map<String, Object> props = new HashMap<>(); props.put(Subscription.PROP_TYPE, "notification"); props.put(Subscription.PROP_ENDID, srp.getASIPath() + postPageResPath); props.put(Subscription.PROP_REL_TYPE, "RESOURCE"); props.put(Subscription.PROP_STARTID, userId); props.put(InternalSocialResourceUtilities.PN_PARENTID, parentPath); //Doing srp.create after this..
Is there any doc I could refer for calling SRP api to make entries other than what I am doing?
Thanks again, really appreciate the response.
Views
Replies
Total Likes
@Ashok,
Update: For my question "Is there any doc I could refer for calling SRP api to make entries other than what I am doing?"I found this Following Interface and SocialGraph and Vertex.
So to change the question a bit , is there an example code you could add based on my previous comment's details? Please let me know if any more details required..
yes you are extending right class and when I say perform beforeaction that points to this [0]
Views
Replies
Total Likes
Thanks Ashok. Currently I am not using the SocialGraph and Relationship (Edge/Vertex) APIs but rather just catching at the beforeAction() and persisting the expected entry as shown in previous comment. I will looking into utilizing the SocialGraph API, since at the moment I do not have an idea how to use it. I request for a sample implementation if possible, meanwhile will spend more time into that.
Thanks again :)
Views
Replies
Total Likes
There is some basic documentation aside from javadocs :
Communities Notifications : setup information
Server-side Customization : overview of APIs
Storage Resource Provider Overview
Coding Guidelines, including Accessing UGC with SRP
- JK
Views
Replies
Total Likes
I have a similar requirement, where I have to extend the Following for notification/subscription/activity and create relationships. Could please share information as how you have used the SocialGraph/Vertex/Edge APIs to create and save relationship. A sample code would be helpful.
Views
Replies
Total Likes
Hi, I had followed Extend Comments Component (three steps) for extending the notifications component at "/libs/social/notifications/components/hbs/notifications" I did not use SocialGraph/Vertex/Edge APIs for implementing this. I did not use any backend extension for this. Any changes that were made were in notifications.hbs and notification.hbs. When you have extended your component and the user is following particular blog or post for notifications, the notification entries should get created and displayed in the component render.
the .hbs changes will control the look and feel changes plus any other formatting changes of the verbiage.
Views
Replies
Total Likes