10.4.3.1.3. Activity, like and comment

Warning

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:

To like or comment on an activity, use the following endpoints:

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.

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:

Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus