Evert Smit
Evert Smit

Reputation: 13

Angular/NodeJS Getstream.io Build follow/unfollow button

I am building a social network for photography, and want users to follow other users to catch new photos when they are uploaded. This is build using node.JS as backend, and Angular5 on the front.

each User has two feeds available. Their personal feed that contains all their activities user:userId and their timeline which should contain everything they follow timeline:userId.

To follow a user feed I have two functions in my backend available that can be called as API.

const feed = streamClient.feed ('timeline',actor);

feed.follow('user',followFeedId).then(function(results) {
        res.send(results);
    },function(err) {
        // Handle or raise the Error.
        console.log(err);
        return res.status(500).send({message: err.message});
    });

To unfollow a userfeed do the same

const feed = streamClient.feed ('timeline',actor);

feed.unfollow('user',followFeedId).then(function(results) {
        res.send(results);
    },function(err) {
        // Handle or raise the Error.
        console.log(err);
        return res.status(500).send({message: err.message});
    });

What i struggle with is to determine when someone is already following a users feed.

According to documentation I can user

user_feed_1.followers(0, 10)

to understand who is following this feed. it returns at max 100 results. With my mini application at this point,this is no issue, but what when i get more than 100 followers to a feed.

So my question is, is there a more elegant option to determine if a timline:userId is following a user:userId feed? I could not find any answer to that in the documentation.

Upvotes: 1

Views: 226

Answers (1)

Dwight Gunning
Dwight Gunning

Reputation: 2525

You can use the alternative 'read followed feeds' API, as it can be filtered:

feed.following({filter:['timeline:1']})

Upvotes: 0

Related Questions