我正在使用GetStream Django包与getstream.io进行交互。我已经成功地使用Enricher()
该类使用 Django 模型信息丰富了我的活动提要feed_manager.get_user_feed()
,但无法获得类似的结果feed_manager.get_notification_feed()
这是我的模型的缩短版本。
class Task(models.Model, Activity):
title = models.CharField()
assigned_to = models.ForeignKey(User)
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(User)
@property
def activity_object_attr(self):
return self
@property
def activity_actor_attr(self):
return self.assigned_to
@property
def activity_notify(self):
return [feed_manager.get_notification_feed(self.assigned_to.id),]
如果我的视图抓取了用户提要:
enricher = Enrich()
feed = feed_manager.get_user_feed(request.user.id)
# feed = feed_manager.get_notification_feed(request.user.id)
activities = feed.get(limit=25)['results']
enriched_activities = enricher.enrich_activities(activities)
我的输出按预期工作,并且每个都在我的模板中填充了正确的数据:
Actor: {{ activity.actor }}<br>
Title: {{ activity.title }}<br>
Time: {{ activity.time|timesince }}<br>
但是,如果我切换到通知提要(请注意注释行外的变化):
enricher = Enrich()
# feed = feed_manager.get_user_feed(request.user.id)
feed = feed_manager.get_notification_feed(request.user.id)
activities = feed.get(limit=25)['results']
enriched_activities = enricher.enrich_activities(activities)
然后,我可以从中获取数据的唯一字段是activity.created_at
.
的输出activity.keys
显示如下:
[u'activities', u'group', u'activity_count', u'created_at', u'updated_at', u'actor_count', u'verb', u'is_seen', u'id', u'is_read']
似乎对于通知提要,演员和对象没有被报告回 GetStream:
但是,它适用于用户提要:
我很困惑为什么。我错过了什么?