|> ActivityPub.contain_timeline(user)
|> Enum.reverse()
- user = Repo.preload(user, :bookmarks)
+ user = Repo.preload(user, bookmarks: :activity)
conn
|> add_link_headers(:home_timeline, activities)
activity_object = Object.normalize(activity)
favorited = opts[:for] && opts[:for].ap_id in (activity_object.data["likes"] || [])
- bookmarked = opts[:for] && activity_object.data["id"] in opts[:for].bookmarks
+
+ bookmarked =
+ opts[:for] && Ecto.assoc_loaded?(opts[:for].bookmarks) &&
+ Enum.any?(opts[:for].bookmarks, fn b ->
+ b.activity_id == activity.id or b.activity.data["object"]["id"] == object
+ end)
mentions =
activity.recipients
bookmarked =
opts[:for] && Ecto.assoc_loaded?(opts[:for].bookmarks) &&
- Enum.any?(opts[:for].bookmarks, fn b -> b.activity_id == activity.id end)
+ Enum.any?(opts[:for].bookmarks, fn b ->
+ b.activity_id == activity.id
+ end)
attachment_data = object.data["attachment"] || []
attachments = render_many(attachment_data, StatusView, "attachment.json", as: :attachment)
user2 = insert(:user)
user3 = insert(:user)
CommonAPI.favorite(activity.id, user2)
- {:ok, user2} = User.bookmark(user2, activity.data["object"]["id"])
+ {:ok, _bookmark} = Pleroma.Bookmark.create(user2.id, activity.id)
{:ok, reblog_activity1, _object} = CommonAPI.repeat(activity.id, user1)
{:ok, _, _object} = CommonAPI.repeat(activity.id, user2)