2

I want to setup several categorized feeds to segment content being posted. I have 4 feeds setup for testing:

  • user
  • flat
  • sports
  • football

The user and flat feeds are working as expected from the docs using the Java API. I can post to the user feed and am able to retrieve items for that user from it. I can also follow a user and am seeing those be reflected in the flat feed.

The challenge I have is in segmenting content based on some simple tagging. I basically want to setup some public feeds and copy posts to those based on tag values. This is working and I am seeing posts duplicated across the sports and football feeds as expected. (Not using To becuase that seemed to break through the Java wrapper).

My issue is how to use the API to read everything in the feed and not just posts by a specific user?

Code to add the item to a categorized feed:

//Post this to the categorized feed
SimpleActivity activity = new SimpleActivity();
activity.setActor(item.getOwnerId());
activity.setObject(item.getId());
activity.setVerb(POST_VERB);
activity.setForeignId(item.getId());
Feed theFeed = this.streamClient.newFeed(theCategory, item.getOwnerId());
//Create an activity service
FlatActivityServiceImpl<SimpleActivity> flatActivityService = theFeed.newFlatActivityService(SimpleActivity.class);
//Add an activity to the feed, where actor, object and target are references to objects
try {
    SimpleActivity response = flatActivityService.addActivity(activity);
    //Lets log some info on this!
    LOG.debug("Item added " + response.getForeignId());
} catch (IOException e) {
    LOG.warn("IOException in StreamService", e);
} catch (StreamClientException e) {
    LOG.warn("StreamClientException in StreamService", e);
}     

And then reading it back

    Feed theFeed = this.streamClient.newFeed(theFeedCategory.getFeedId(), userId);
    FeedFilter filter = new FeedFilter.Builder().withLimit(pageSize).withOffset(start).build();
    FlatActivityServiceImpl<SimpleActivity> flatActivityService = theFeed.newFlatActivityService(SimpleActivity.class);
    try {
        List<SimpleActivity> activities = flatActivityService.getActivities(filter).getResults();
        for (SimpleActivity activity : activities) {
            response.add(activity.getForeignId());
        }
    } catch (IOException e) {
        LOG.warn("IOException in StreamService", e);
    } catch (StreamClientException e) {
        LOG.warn("StreamClientException in StreamService", e);
    }

Is there a way I can go through the java API to get everything in a feed by any user OR is there a way to segment the feeds so they pivot on a category?

Thanks

Andrew Rutter
  • 1,257
  • 2
  • 18
  • 34
  • I do not understand your question, if you are looking for a way to filter activities you get from a feed this is not [supported yet](http://stackoverflow.com/questions/34788681/is-it-possible-to-filter-on-a-feed). If you are asking for something else please clarify, especially the following part: "is there a way to segment the feeds so they pivot on a category" – Matthisk Jan 19 '16 at 08:40
  • I wanted to setup feeds that will just organize posts under specific categories but ignoring the need for users to follow. I ended up using fake users for these feeds that mapped back to the categories of interest, for example a sports feed would be posted to using a fake user sports and read using that same fake user. – Andrew Rutter Jan 19 '16 at 23:46
  • 1
    What do you mean by "fake user", stream doesn't have a concept of users, feed != user. Thus in your usecase you can have a feed group named categories with a feed with id "categories:sports" and you could publish activities to this feed that are related to the category sport. – Matthisk Jan 22 '16 at 08:14
  • @Matthisk could explain `feed != user`? And also the meaning of the comma in "categories:sports"? The examples often use `const user1 = client.feed('user', '1');`, which induces me to think that feed and users are close concepts. From what you said, my assumption is wrong – Besart Hoxhaj Dec 17 '20 at 12:11

0 Answers0