Use atoms when updating user info

This commit is contained in:
rinpatch 2019-07-14 00:21:35 +03:00
parent e5b850a991
commit d06d1b751d
2 changed files with 11 additions and 11 deletions

View file

@ -986,10 +986,10 @@ defp object_to_user_data(data) do
user_data = %{
ap_id: data["id"],
info: %{
"ap_enabled" => true,
"source_data" => data,
"banner" => banner,
"locked" => locked
ap_enabled: true,
source_data: data,
banner: banner,
locked: locked
},
avatar: avatar,
name: data["name"],
@ -1023,10 +1023,10 @@ def fetch_follow_information_for_user(user) do
followers_count when is_integer(followers_count) <- followers_data["totalItems"],
{:ok, hide_followers} <- collection_private(followers_data) do
info = %{
"hide_follows" => hide_follows,
"follower_count" => followers_count,
"following_count" => following_count,
"hide_followers" => hide_followers
hide_follows: hide_follows,
follower_count: followers_count,
following_count: following_count,
hide_followers: hide_followers
}
info = Map.merge(user.info, info)

View file

@ -609,13 +609,13 @@ def handle_incoming(
with %User{ap_id: ^actor_id} = actor <- User.get_cached_by_ap_id(object["id"]) do
{:ok, new_user_data} = ActivityPub.user_data_from_user_object(object)
banner = new_user_data[:info]["banner"]
locked = new_user_data[:info]["locked"] || false
banner = new_user_data[:info][:banner]
locked = new_user_data[:info][:locked] || false
update_data =
new_user_data
|> Map.take([:name, :bio, :avatar])
|> Map.put(:info, %{"banner" => banner, "locked" => locked})
|> Map.put(:info, %{banner: banner, locked: locked})
actor
|> User.upgrade_changeset(update_data)