diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-06-24 13:09:46 +0200 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-06-24 13:09:46 +0200 |
commit | 6935fc3e010391d647bcec70bd3d6d6cb8de73a0 (patch) | |
tree | 0496d6f85f1c67b636cef07f2bb065bda78b1aba /lib | |
parent | ffc9d7708b3917a3a853cd54c13bbd6d0b3b9ba6 (diff) | |
download | pleroma-6935fc3e010391d647bcec70bd3d6d6cb8de73a0.tar.gz |
Update user data on fetch if it changed.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pleroma/web/ostatus/ostatus.ex | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/pleroma/web/ostatus/ostatus.ex b/lib/pleroma/web/ostatus/ostatus.ex index 7fd3a5edd..bb0a3b5b9 100644 --- a/lib/pleroma/web/ostatus/ostatus.ex +++ b/lib/pleroma/web/ostatus/ostatus.ex @@ -192,6 +192,11 @@ defmodule Pleroma.Web.OStatus do end end + def insert_or_update_user(data) do + cs = User.remote_user_creation(data) + Repo.insert(cs, on_conflict: :replace_all, conflict_target: :nickname) + end + def make_user(uri) do with {:ok, info} <- gather_user_info(uri) do data = %{ @@ -204,9 +209,7 @@ defmodule Pleroma.Web.OStatus do } with %User{} = user <- User.get_by_ap_id(data.ap_id) do {:ok, user} - else _e -> - cs = User.remote_user_creation(data) - Repo.insert(cs) + else _e -> insert_or_update_user(data) end end end |