|> ActivityPub.contain_timeline(user)
|> Enum.reverse()
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> add_link_headers(:home_timeline, activities)
|> put_view(StatusView)
|> ActivityPub.fetch_public_activities()
|> Enum.reverse()
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> add_link_headers(:public_timeline, activities, false, %{"local" => local_only})
|> put_view(StatusView)
end
def user_statuses(%{assigns: %{user: reading_user}} = conn, params) do
- with %User{} = user <- User.get_cached_by_id(params["id"]),
- reading_user <- Repo.preload(reading_user, :bookmarks) do
+ with %User{} = user <- User.get_cached_by_id(params["id"]) do
activities = ActivityPub.fetch_user_activities(user, reading_user, params)
conn
|> ActivityPub.fetch_activities_query(params)
|> Pagination.fetch_paginated(params)
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> add_link_headers(:dm_timeline, activities)
|> put_view(StatusView)
def get_status(%{assigns: %{user: user}} = conn, %{"id" => id}) do
with %Activity{} = activity <- Activity.get_by_id_with_object(id),
true <- Visibility.visible_for_user?(activity, user) do
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: activity, for: user})
def reblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
with {:ok, announce, _activity} <- CommonAPI.repeat(ap_id_or_id, user),
%Activity{} = announce <- Activity.normalize(announce.data) do
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: announce, for: user, as: :activity})
def unreblog_status(%{assigns: %{user: user}} = conn, %{"id" => ap_id_or_id}) do
with {:ok, _unannounce, %{data: %{"id" => id}}} <- CommonAPI.unrepeat(ap_id_or_id, user),
%Activity{} = activity <- Activity.get_create_by_object_ap_id_with_object(id) do
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
%User{} = user <- User.get_cached_by_nickname(user.nickname),
true <- Visibility.visible_for_user?(activity, user),
{:ok, _bookmark} <- Bookmark.create(user.id, activity.id) do
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
%User{} = user <- User.get_cached_by_nickname(user.nickname),
true <- Visibility.visible_for_user?(activity, user),
{:ok, _bookmark} <- Bookmark.destroy(user.id, activity.id) do
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> try_render("status.json", %{activity: activity, for: user, as: :activity})
ActivityPub.fetch_activities([], params)
|> Enum.reverse()
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> add_link_headers(:favourites, activities)
|> put_view(StatusView)
def bookmarks(%{assigns: %{user: user}} = conn, params) do
user = User.get_cached_by_id(user.id)
- user = Repo.preload(user, bookmarks: :activity)
bookmarks =
Bookmark.for_user_query(user.id)
|> ActivityPub.fetch_activities_bounded(following, params)
|> Enum.reverse()
- user = Repo.preload(user, bookmarks: :activity)
-
conn
|> put_view(StatusView)
|> render("index.json", %{activities: activities, for: user, as: :activity})