I am trying to add an activity to many user feeds which aren't following the activity actor. I was thinking about using the "to" field, but GetStream only allows to target up to 100 feeds.
In my application I have a "promotion" activity which should be seen on every user feed, but sometimes we also want to target a "promotion" to a specific group of users, filtered by a property on them.
A promotion has a user as an actor, but the promotion should still appear on another user's feed even if that user doesn't follow the actor.
Sometimes I want to send out a promotion to 80k users.
How could I solve this?
I am using the Ruby library, and the Rails integration.
答案 0 :(得分:2)
正确指出to
目标不适合您的用例。您可以在请求中包含的目标数量限制为100.幸运的是,Stream的API会公开a batch operation以向多个Feed添加相同的活动。
这是一个可以在API客户端中使用的高级功能,因为您使用的是Rails集成,您可以执行以下操作:
client = StreamRails.client
activity = self.create_activity
client.add_to_many(activity, ["flat:1", "flat:2", "flat:3"])
请注意,代码示例中的self
是您的活动模型的实例。