我目前正在將stream_rails
通知訂閱源集成到現有應用程序中。我試圖在用戶關注其他用戶時添加活動。非常簡單,但由於某種原因,當我在followed_user
的訂閱源上調用add_activity
時,它將信息添加爲字符串。添加活動將用戶對象添加爲字符串而不是實際對象
這裏是我的activity_data
:
activity_data = {
actor: current_user,
verb: 'Follow',
object: followable,
to: ["notifications:#{followable.id}"]
}
這裏的activity_response
,縮短爲簡潔:
activity_response = {"actor"=>
"{u'twitter_followers_count': 0, u'github_created_at': blahblahblah}", # other attributes removed for brevity
"duration"=>"41ms",
"foreign_id"=>nil,
"id"=>"538bc690-51df-11e7-8080-8001521ad36e",
"object"=>
"{u'twitter_followers_count': None, u'github_created_at': blahblahblah}", # other attributes removed for brevity
"origin"=>nil,
"target"=>nil,
"time"=>"2017-06-15T15:28:47.931560",
"to"=>[["notifications:301", "DVcbej_Id4IdQWHOYlA1n7RB4ps"]],
"verb"=>"Follow"}
當應該更像:
activity_response = {"actor"=>
#<User:0x007fa8fae1a488>,
"duration"=>"41ms",
# etc etc
}
也不太清楚爲什麼actor
點到一個實際的ActiveReco字符串rd對象的返回值,與object
相同。在每個屬性之前還有一堆新增的'u'
。
此外,我避免使用StreamRails.feed_manager.follow_user
,因爲我只想發送通知,而不是創建供追隨者查看的訂閱源。感謝任何幫助。謝謝!