Use update_and_set cache.
This commit is contained in:
parent
e3629af4da
commit
dfaddeb765
3 changed files with 8 additions and 10 deletions
|
@ -128,9 +128,8 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
|||
|
||||
actor
|
||||
|> User.upgrade_changeset(update_data)
|
||||
|> Repo.update
|
||||
|> User.update_and_set_cache()
|
||||
|
||||
User.invalidate_cache(actor)
|
||||
ActivityPub.update(%{local: false, to: data["to"] || [], cc: data["cc"] || [], object: object, actor: actor_id})
|
||||
else
|
||||
e ->
|
||||
|
|
|
@ -207,7 +207,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
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
|
||||
|
@ -216,7 +216,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
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
|
||||
|
@ -228,7 +228,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
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
|
||||
|
@ -255,7 +255,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
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
|
||||
|
@ -305,7 +305,7 @@ defmodule Pleroma.Web.TwitterAPI.Controller do
|
|||
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 ->
|
||||
|
|
|
@ -60,9 +60,8 @@ defmodule Pleroma.Web.WebFinger do
|
|||
else
|
||||
{:ok, pem} = Salmon.generate_rsa_pem
|
||||
info = Map.put(info, "keys", pem)
|
||||
res = Repo.update(Ecto.Changeset.change(user, info: info))
|
||||
User.invalidate_cache(user)
|
||||
res
|
||||
Ecto.Changeset.change(user, info: info)
|
||||
|> User.update_and_set_cache()
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue