4 Replies Latest reply on Sep 6, 2017 2:58 PM by Helen Chen

    How to force a user to follow/unfollow a space via REST API

    Jeff Shurtliff

      Hi everyone,

       

      We are going to be publishing a large amount of content into one of our spaces next week and we want to temporarily force the users currently following that space to unfollow it while we publish, and then force them to re-follow it when the process is complete.  This way they won't get spammed with hundreds of notification emails.

       

      But I'm having a hard time determining which stream association I would need to destroy, since I can't seem to figure out what ties a space to a stream when someone clicks the "Follow" button.

       

      During my research, I created a brand new test user (which was given the User ID 19869) and ran a GET https://community.rsa.com/api/core/v3/people/19869/streams query against it, which showed two streams (38447 and 38448) as shown below.

      {
        "itemsPerPage": 10,
        "list": [
          {
            "id": "38447",
            "resources": {
              "associations": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38447/associations"
              },
              "activity": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38447/activities"
              },
              "self": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38447"
              },
              "html": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/news?streamSource=communications&streamID=38447"
              }
            },
            "name": "",
            "published": "2016-08-13T00:25:34.089+0000",
            "receiveEmails": true,
            "source": "communications",
            "updated": "2016-08-13T00:25:34.089+0000",
            "type": "stream"
          },
          {
            "id": "38448",
            "resources": {
              "associations": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38448/associations"
              },
              "activity": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38448/activities"
              },
              "self": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/api/core/v3/streams/38448"
              },
              "html": {
                "allowed": [
                  "GET"
                ],
                "ref": "https://community.rsa.com/news?streamSource=connections&streamID=38448"
              }
            },
            "name": "",
            "published": "2016-08-13T00:25:34.094+0000",
            "receiveEmails": false,
            "source": "connections",
            "updated": "2016-08-13T00:25:34.094+0000",
            "type": "stream"
          }
        ],
        "startIndex": 0
      }
      

       

      I then had the user follow a single space (Place ID: 27229) and ran the query again, expecting to see a third stream appear, but I still only see the same two from before.

       

      So my question is, how can I find where on the back-end the user is following Place ID 27229 and destroy that association so that the user will temporarily stop following the space until I can create a new association for the user to follow it again?