Fix OStatus user updates.

Breaks banner updating.
This commit is contained in:
lain 2018-11-30 17:21:58 +01:00
parent 48b95a9b95
commit d088ac6286

View file

@ -226,25 +226,21 @@ def maybe_update_ostatus(doc, user) do
old_data = %{ old_data = %{
avatar: user.avatar, avatar: user.avatar,
bio: user.bio, bio: user.bio,
name: user.name, name: user.name
info: user.info
} }
with false <- user.local, with false <- user.local,
avatar <- make_avatar_object(doc), avatar <- make_avatar_object(doc),
bio <- string_from_xpath("//author[1]/summary", doc), bio <- string_from_xpath("//author[1]/summary", doc),
name <- string_from_xpath("//author[1]/poco:displayName", doc), name <- string_from_xpath("//author[1]/poco:displayName", doc),
info <-
Map.put(user.info, "banner", make_avatar_object(doc, "header") || user.info["banner"]),
new_data <- %{ new_data <- %{
avatar: avatar || old_data.avatar, avatar: avatar || old_data.avatar,
name: name || old_data.name, name: name || old_data.name,
bio: bio || old_data.bio, bio: bio || old_data.bio
info: info || old_data.info
}, },
false <- new_data == old_data do false <- new_data == old_data do
change = Ecto.Changeset.change(user, new_data) change = Ecto.Changeset.change(user, new_data)
Repo.update(change) User.update_and_set_cache(change)
else else
_ -> _ ->
{:ok, user} {:ok, user}