简体   繁体   English

GetStream-IO将没有f​​oreignId的活动添加到多个提要,但是这些活动共享相同的ID

[英]GetStream-IO Add activity without foreignId to multiple feeds, but these activities share same Id

I'm using the Stream Java client version 1.3.2. 我正在使用Stream Java客户端版本1.3.2。

I have three flat customer feeds: customer:101 , customer:102 , and customer103 . 我有三个固定的customer供稿: customer:101customer:102customer103 customer:102

There is also a flat timeline feed, timeline:201 , which follows the above three customer feeds. 还有一个固定的timeline供稿timeline:201 ,它遵循上述三个customer供稿。

I added an activity to customer:101 . 我向customer:101添加了活动。 The activity has the to field set to customer:102 and customer:103 . 该活动的to字段设置为customer:102customer:103

The activity should now be in the three customer feeds and the timeline feed. 现在,该活动应该位于三个customer提要和timeline提要中。

The foreignId and time fields are not set for that activity. 没有为该活动设置foreignIdtime字段。 Should I expect the same activity to have different id s in the different feeds? 我是否应该期望同一活动在不同的Feed中具有不同的id

I was under the impression that if I don't set the foreignId and time fields on an activity, the same activity on different feeds will have different id s. 我的印象是,如果我没有在活动上设置foreignIdtime字段,则不同提要上的同一活动将具有不同的id But that does not seem to be the case from what I ran so far. 但是从我到目前为止的情况来看,情况似乎并非如此。

Here's a snippet of my code: 这是我的代码片段:

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);

I got the following output: 我得到以下输出:

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}

Is this the expected behavior? 这是预期的行为吗? I expected them to all have different id s. 我希望他们都有不同的id

Apologies for the confusion on the call about this. 很抱歉为此打上电话。 Because you're using the To field, it writes the same payload into each of the feeds, which because they have the same time field would indeed have the same activity ID value. 因为您使用的是To字段,所以它将相同的有效负载写入每个提要,而由于它们具有相同的time字段,所以它们实际上具有相同的活动ID值。 If you had written the activities in separate calls it should have given different activity ID values. 如果您在单独的调用中编写了活动,则应提供不同的活动ID值。

Issuing a delete using the activity ID, however, is specific only to a single feed, so a call like: 但是,使用活动ID发出删除操作仅特定于单个Feed,因此调用如下:

feedTwoService.deleteActivity('f3d6...824c');

... should delete the activity ONLY from that one feed. ...仅应从该Feed中删除该活动。

If you were using foreign_id values, and you used that foreign_id in the delete call on the original feed, it would also delete the activity from any feeds that got a copy through follow relationships, etc. 如果您使用 foreign_id值,并且使用该foreign_id在原饲料删除通话的同时,也会从通过后续关系等得到了一个副本的任何饲料删除活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM