Search code examples
javascriptnode.jsgetstream-io

GetStream.io - Delete a feed nodejs


I am using Getstream.io nodejs module.

I am creating feeds at run time and want to know if there is a way to delete a feed through code?.

I see in the code base that there is a delete interface but when I looked in to RESTFul API documentation, I did not find any end point to delete a feed.

But when I look at Ruby documentation, I see that there is way to delete a feed.

Please let me know how can I achieve deleting a feed in getstream.io from nodejs


Solution

  • I was able to delete a feed using nodejs. It is just a hack but it will work.

    But remember that deleting a feed means, it deletes all the activities from the feed. The feed still exists and can be seen through databrowser. The follow/following relationship still exists.

    DeleteFeed = function(params,callback){
      if (params.feedId) {
         var feed = client.feed(params.feedType, params.feedId);
         //remove followings
         feed.following({limit:25,offset:0},function(err,r){
            if (!err) {
               for (var i = 0; i < r.body.results.length; i++) {
                 var tempFeed = r.body.results[i].target_id.split(':');
                 feed.unfollow(tempFeed[0], tempFeed[1]);
               }
            }
         });
         // do something similar as followings for followers 
         //(I did not have to worry about it hence did not write any code)
         client.delete({
           url: "feed/" + params.feedType  + "/" + params.feedId + "/",
           signature: feed.signature
         }, function (e, r) {
            //DO NOTHING
            //console.log("Error -- " + e);
            //console.log("Result -- " + JSON.stringify(r,null,2));
         });
      }
    };