我使用的是Stream Java客户端1.3.2版。
我有三个平面customer提要:customer:101、customer:102和customer103。
还有一个平面timeline提要timeline:201,它位于上述三个customer提要之后。
我在customer:101中添加了一个活动。该活动的to字段设置为customer:102和customer:103。
该活动现在应该在三个customer提要和timeline提要中。
未为该活动设置foreignId和time字段。我应该期望相同的活动在不同的提要中有不同的id吗?
我的印象是,如果我不在一个活动上设置foreignId和time字段,同一个活动在不同提要上会有不同的ids,但从我到目前为止运行的情况来看,情况似乎并非如此。
下面是我的代码片段:
Feed feedOne = streamClient.newFeed("customer", "101");
FlatActivityServiceImpl<SimpleActivity> feedOneService =
feedOne.newFlatActivityService(SimpleActivity.class);
Feed feedTwo = streamClient.newFeed("customer", "102");
FlatActivityServiceImpl<SimpleActivity> feedTwoService =
feedTwo.newFlatActivityService(SimpleActivity.class);
Feed feedThree = streamClient.newFeed("customer", "103");
FlatActivityServiceImpl<SimpleActivity> feedThreeService =
feedThree.newFlatActivityService(SimpleActivity.class);
Feed timeline = streamClient.newFeed("timeline", "201");
FlatActivityServiceImpl<SimpleActivity> timelineService =
timeline.newFlatActivityService(SimpleActivity.class);
timeline.follow("customer", "101", 0);
timeline.follow("customer", "102", 0);
timeline.follow("customer", "103", 0);
// Create a new activity
SimpleActivity activity = new SimpleActivity();
activity.setActor("customer:101");
activity.setObject("tweet:1");
activity.setVerb("tweet");
activity.setTo(Arrays.asList("customer:102", "customer:103"));
feedOneService.addActivity(activity);
System.out.println("Feed one activities:");
feedOneService.getActivities().getResults().forEach(System.out::println);
System.out.println("Feed two activities:");
feedTwoService.getActivities().getResults().forEach(System.out::println);
System.out.println("Feed Three activities:");
feedThreeService.getActivities().getResults().forEach(System.out::println);
System.out.println("Timeline activities:");
timelineService.getActivities().getResults().forEach(System.out::println);我得到了以下输出:
13:34:11.835 [main] DEBUG i.g.c.a.repo.StreamRepositoryImpl - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/timeline/201/following/?api_key=
13:34:12.323 [main] DEBUG i.g.c.a.repo.StreamRepositoryImpl - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/timeline/201/following/?api_key=
13:34:12.433 [main] DEBUG i.g.c.a.repo.StreamRepositoryImpl - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/timeline/201/following/?api_key=
13:34:12.573 [main] DEBUG i.g.c.a.r.StreamActivityRepository - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/customer/101/?api_key='
Feed one activities:
13:34:12.817 [main] DEBUG i.g.c.a.r.StreamActivityRepository - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/customer/101/?api_key=w&limit=25'
SimpleActivity{id=f3d610da-81df-11e7-8080-80000cce824c, actor=customer:101, verb=tweet, object=tweet:1, target=null, time=Tue Aug 15 13:34:12 EDT 2017, to=[customer:102, customer:103], origin=null, score=null, duration=null}
Feed two activities:
13:34:12.892 [main] DEBUG i.g.c.a.r.StreamActivityRepository - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/customer/102/?api_key=w&limit=25'
SimpleActivity{id=f3d610da-81df-11e7-8080-80000cce824c, actor=customer:101, verb=tweet, object=tweet:1, target=null, time=Tue Aug 15 13:34:12 EDT 2017, to=[customer:102, customer:103], origin=null, score=null, duration=null}
Feed Three activities:
13:34:12.963 [main] DEBUG i.g.c.a.r.StreamActivityRepository - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/customer/103/?api_key=&limit=25'
SimpleActivity{id=f3d610da-81df-11e7-8080-80000cce824c, actor=customer:101, verb=tweet, object=tweet:1, target=null, time=Tue Aug 15 13:34:12 EDT 2017, to=[customer:102, customer:103], origin=customer:102, score=null, duration=null}
Timeline activities:
13:34:13.012 [main] DEBUG i.g.c.a.r.StreamActivityRepository - Invoking url: 'https://us-east-api.getstream.io/api/v1.0/feed/timeline/201/?api_key=&limit=25'
SimpleActivity{id=f3d610da-81df-11e7-8080-80000cce824c, actor=customer:101, verb=tweet, object=tweet:1, target=null, time=Tue Aug 15 13:34:12 EDT 2017, to=[customer:102, customer:103], origin=customer:103, score=null, duration=null}这是预期的行为吗?我希望他们都有不同的id。
发布于 2017-08-16 03:27:56
很抱歉在电话中对此感到困惑。因为您使用的是To字段,所以它将相同的有效负载写入到每个提要中,因为它们具有相同的time字段,所以它们实际上具有相同的活动ID值。如果您在单独的调用中编写了活动,那么它应该给出不同的活动ID值。
但是,使用活动ID执行删除操作仅特定于单个提要,因此调用如下所示:
feedTwoService.deleteActivity('f3d6...824c');..。应该只从该提要中删除活动。
如果您使用的是delete值,并且在对原始提要的foreign_id调用中使用了该foreign_id,则它还会从通过以下关系获得副本的任何提要中删除活动,等等。
https://stackoverflow.com/questions/45699206
复制相似问题