You are looking at documentation for an older release. Not what you want? See the current release documentation.
Here is the full version of Activity JSON returned by GET /v1/social/activities
or
GET /v1/social/activities/{activity_id}
:
{ "id": "213a1e3f7f0001014783354eccc0f0c9", "title": "123 jump <a href=\"http://localhost:8080/portal/intranet/profile/root\">Root Root</a>", "body": null, "link": null, "type": "DEFAULT_ACTIVITY", "href": "http://localhost:8080/rest/v1/social/activities/213a1e3f7f0001014783354eccc0f0c9", "identity": "http://localhost:8080/rest/v1/social/identities/13aeecb67f00010129539a6cc03b84fe", "owner": { "id": "13aeecb67f00010129539a6cc03b84fe", "href": "http://localhost:8080/rest/v1/social/users/john" }, "mentions": [ { "id": "041e08bb7f000101003098264987225d", "href": "http://localhost:8080/rest/v1/social/users/root" } ], "attachments": [], "comments": "http://localhost:8080/rest/v1/social/activities/213a1e3f7f0001014783354eccc0f0c9/comments", "likes": "http://localhost:8080//v1/social/activities/213a1e3f7f0001014783354eccc0f0c9/likers", "createDate": "2015-10-01T09:27:48.413+07:00", "updateDate": "2015-10-01T09:27:48.413+07:00", "activityStream": { "type": "user", "id": "john" } }
The /activities
endpoint allows getting activities, reading/updating/deleting an activity. For Create, you
need to use either /users/{user_id}/activities
or /spaces/{space_id}/activities
.
Social allows many types of activities, but via the Rest API it makes sense to post a simple message. So an effective JSON should contain only one field "title". See the following examples:
Create an activity in authenticated user's activity stream (though it has username as a path param, it is not allowed to post to another user's stream).
POST /v1/social/users/john/activities { "title":"hey hallo" }
Create an activity in a space activity stream by the space Id.
POST /v1/social/spaces/3cb997397f0001012108b43dfecbcf85/activities { "title":"hey hallo" }
Edit an activity by its Id:
PUT /v1/social/activities/5f08dee67f00010122e15db3c2d75a31 { "title":"hey hallo" }
Delete an activity by its Id:
DELETE /v1/social/activities/5f08dee67f00010122e15db3c2d75a31
To like or comment on an activity, use the following endpoints:
/v1/social/activities/{activity_id}/likes
/v1/social/activities/{activity_id}/comments
Like
Likes of an activity are indeed a list of users. See the JSON returned by GET /v1/social/activities/{activity_id}/likes
:
{ "likes": [ { "id": "13aeed257f0001010aaff03a9f71d0a4", "href": "http://localhost:8080/rest/v1/social/users/john", "identity": "http://localhost:8080/rest/v1/social/identities/13aeecb67f00010129539a6cc03b84fe", "username": "john", "firstname": "John", "lastname": "Smith", "fullname": "John Smith", "gender": null, "position": null, "email": "john@gatein.com", "avatar": null, "phones": [], "experiences": [], "ims": [], "urls": [], "deleted": false }, {...} ], "offset": 0, "limit": 20 }
Therefore, in Create and Delete (Unlike) you do not need to send a JSON, a username is used instead. There is no Update method for a like.
To like an activity (as the authenticated user):
POST /v1/social/activities/{activity_id}/likes
To unlike an activity (An administrator can delete any like. For the normal user, to delete their like, you need to set the username parameter to the authenticated user.):
DELETE /v1/social/activities/{activity_id}/likes/{username}
Comment
The Comment(s) JSON is returned by GET /v1/social/activities/{activity_id}/comments
or
GET /v1/social/comments/{comment_id}
.
{ "comments": [ { "id": "3cb99a787f0001014ea5ca7b1e5aa3a2", "href": "http://localhost:8080/rest/v1/social/activities/3cb99a787f0001014ea5ca7b1e5aa3a2", "identity": "http://localhost:8080/rest/v1/social/identities/041e08bb7f000101003098264987225d", "poster": "root", "body": "Has joined the space.", "mentions": [], "createDate": "2015-10-06T17:36:48.120+07:00", "updateDate": "2015-10-06T17:36:48.120+07:00" }, { "id": "3cd134557f0001012d08eabf33a0cb12", "href": "http://localhost:8080/rest/v1/social/activities/3cd134557f0001012d08eabf33a0cb12", "identity": "http://localhost:8080/rest/v1/social/identities/13979f2b7f0001012c0a9eab6606475f", "poster": "mary", "body": "Has joined the space.", "mentions": [], "createDate": "2015-10-06T18:02:34.834+07:00", "updateDate": "2015-10-06T18:02:34.834+07:00" }, { "id": "3cf2aefd7f00010109e1ded62fe5102f", "href": "http://localhost:8080/rest/v1/social/activities/3cf2aefd7f00010109e1ded62fe5102f", "identity": "http://localhost:8080/rest/v1/social/identities/13aeecb67f00010129539a6cc03b84fe", "poster": "john", "body": "Has joined the space.", "mentions": [], "createDate": "2015-10-06T18:39:08.922+07:00", "updateDate": "2015-10-06T18:39:08.922+07:00" } ], "offset": 0, "limit": 20 }
In Create and Update you can use an effective version that contains only "body" field. See the following examples:
Create a comment by the activity Id:
POST /v1/social/activities/{activity_id}/comments { "body":"this is a comment" }
Edit a comment by the comment Id:
PUT /v1/social/comments/{comment_id} { "body":"this is a comment" }
Delete a comment by the comment Id:
DELETE /v1/social/comments/{comment_id}