2017-08-15 22 views
2

我正在使用Stream Java客戶端版本1.3.2。GetStream-IO將沒有f​​oreignId的活動添加到多個提要,但這些活動共享相同的Id

我有三個平板customer飼料:customer:101customer:102customer103

還有一個平面timeline飼料,timeline:201,它跟隨上述三個customer飼料。

我添加了一個活動到customer:101。該活動的to字段設置爲customer:102customer:103

該活動現在應該位於三個customer供稿和timeline供稿中。

foreignIdtime字段未針對該活動設置。我是否應該期望同一活動在不同的Feed中有不同的id

我的印象是,如果我不設置上的活動foreignIdtime領域,在不同的飼料相同的活動都會有不同的id秒。但從目前爲止我看到的情況似乎並非如此。

這裏是我的代碼片段:

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 s。

回答

0

對此致電的混淆抱歉。由於您使用的是收件人字段,因此它將相同的有效內容寫入每個Feed,因爲它們具有相同的time字段的確會具有相同的活動ID值。如果您在不同的調用中編寫了活動,它應該給出不同的活動ID值。

使用活動ID發出刪除,但是,具體的只有一個單一的飼料,所以調用,比如:

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

...應該只從一個飼料刪除活動。

如果使用foreign_id值,並且使用該foreign_id在原飼料刪除調用,它也將從通過後續關係有一個副本的任何飼料刪除的活動等

+0

謝謝爲了快速回復Ian! –

+0

我由呼叫是通過使用活動ID刪除了'timeline'進料的活性,如: 'timeline.deleteActivity( 「f3d610da-81df-11e7-8080-80000cce824c」);' 當我打印所有提要的內容,只有'customer:101'提要包含該活動。其他飼料似乎已刪除該活動... 所以我不知道實際發生了什麼。 從你提到的內容來看,我仍然應該看到所有三個'customer'feed中的活動,只有'timeline'活動應該是空的。 –