CommonAPI.update(user)
end
- json(conn, AccountView.render("account.json", %{user: user}))
+ json(conn, AccountView.render("account.json", %{user: user, for: user}))
else
_e ->
conn
end
def verify_credentials(%{assigns: %{user: user}} = conn, _) do
- account = AccountView.render("account.json", %{user: user})
+ account = AccountView.render("account.json", %{user: user, for: user})
json(conn, account)
end
- def user(conn, %{"id" => id}) do
+ def user(%{assigns: %{user: for_user}} = conn, %{"id" => id}) do
with %User{} = user <- Repo.get(User, id) do
- account = AccountView.render("account.json", %{user: user})
+ account = AccountView.render("account.json", %{user: user, for: for_user})
json(conn, account)
else
_e ->
def follow(%{assigns: %{user: follower}} = conn, %{"id" => id}) do
with %User{} = followed <- Repo.get(User, id),
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
- {:ok, _activity} <- ActivityPub.follow(follower, followed) do
+ {:ok, _activity} <- ActivityPub.follow(follower, followed),
+ {:ok, follower, followed} <- User.wait_and_refresh(500, follower, followed) do
render(conn, AccountView, "relationship.json", %{user: follower, target: followed})
else
{:error, message} ->
with %User{} = followed <- Repo.get_by(User, nickname: uri),
{:ok, follower} <- User.maybe_direct_follow(follower, followed),
{:ok, _activity} <- ActivityPub.follow(follower, followed) do
- render(conn, AccountView, "account.json", %{user: followed})
+ render(conn, AccountView, "account.json", %{user: followed, for: follower})
else
{:error, message} ->
conn
if user && token do
mastodon_emoji = mastodonized_emoji()
- accounts = Map.put(%{}, user.id, AccountView.render("account.json", %{user: user}))
+
+ accounts =
+ Map.put(%{}, user.id, AccountView.render("account.json", %{user: user, for: user}))
initial_state =
%{
id: id,
type: "mention",
created_at: created_at,
- account: AccountView.render("account.json", %{user: actor}),
+ account: AccountView.render("account.json", %{user: actor, for: user}),
status: StatusView.render("status.json", %{activity: activity, for: user})
}
id: id,
type: "favourite",
created_at: created_at,
- account: AccountView.render("account.json", %{user: actor}),
+ account: AccountView.render("account.json", %{user: actor, for: user}),
status: StatusView.render("status.json", %{activity: liked_activity, for: user})
}
id: id,
type: "reblog",
created_at: created_at,
- account: AccountView.render("account.json", %{user: actor}),
+ account: AccountView.render("account.json", %{user: actor, for: user}),
status: StatusView.render("status.json", %{activity: announced_activity, for: user})
}
id: id,
type: "follow",
created_at: created_at,
- account: AccountView.render("account.json", %{user: actor})
+ account: AccountView.render("account.json", %{user: actor, for: user})
}
_ ->