def update_avatar(%{assigns: %{user: user}} = conn, params) do
{:ok, object} = ActivityPub.upload(params)
change = Changeset.change(user, %{avatar: object.data})
- {:ok, user} = Repo.update(change)
+ {:ok, user} = User.update_and_set_cache(change)
render(conn, UserView, "show.json", %{user: user, for: user})
end
with {:ok, object} <- ActivityPub.upload(%{"img" => params["banner"]}),
new_info <- Map.put(user.info, "banner", object.data),
change <- User.info_changeset(user, %{info: new_info}),
- {:ok, _user} <- Repo.update(change) do
+ {:ok, _user} <- User.update_and_set_cache(change) do
%{"url" => [ %{ "href" => href } | _ ]} = object.data
response = %{ url: href } |> Poison.encode!
conn
with {:ok, object} <- ActivityPub.upload(params),
new_info <- Map.put(user.info, "background", object.data),
change <- User.info_changeset(user, %{info: new_info}),
- {:ok, _user} <- Repo.update(change) do
+ {:ok, _user} <- User.update_and_set_cache(change) do
%{"url" => [ %{ "href" => href } | _ ]} = object.data
response = %{ url: href } |> Poison.encode!
conn
mrn <- max(id, user.info["most_recent_notification"] || 0),
updated_info <- Map.put(info, "most_recent_notification", mrn),
changeset <- User.info_changeset(user, %{info: updated_info}),
- {:ok, _user} <- Repo.update(changeset) do
+ {:ok, _user} <- User.update_and_set_cache(changeset) do
conn
|> json_reply(200, Poison.encode!(mrn))
else
end
with changeset <- User.update_changeset(user, params),
- {:ok, user} <- Repo.update(changeset) do
+ {:ok, user} <- User.update_and_set_cache(changeset) do
render(conn, UserView, "user.json", %{user: user, for: user})
else
error ->