From: kaniini Date: Thu, 26 Sep 2019 03:00:38 +0000 (+0000) Subject: Merge branch 'refactor/user' into 'develop' X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=48a82c46096a560fe9331a63f19ace6faaf98c3d;p=akkoma Merge branch 'refactor/user' into 'develop' Simplify updating user's `info` See merge request pleroma/pleroma!1712 --- 48a82c46096a560fe9331a63f19ace6faaf98c3d diff --cc lib/pleroma/web/common_api/common_api.ex index 9ee704022,40eebe2aa..4a74dc16f --- a/lib/pleroma/web/common_api/common_api.ex +++ b/lib/pleroma/web/common_api/common_api.ex @@@ -295,27 -300,16 +295,25 @@@ defmodule Pleroma.Web.CommonAPI d end end + # parse and put emoji to object data + defp put_emoji(map, text, emojis) do + Map.put( + map, + "emoji", + Map.merge(Emoji.Formatter.get_emoji_map(text), emojis) + ) + end + # Updates the emojis for a user based on their profile def update(user) do + emoji = emoji_from_profile(user) + source_data = user.info |> Map.get(:source_data, {}) |> Map.put("tag", emoji) + user = - with emoji <- emoji_from_profile(user), - source_data <- (user.info.source_data || %{}) |> Map.put("tag", emoji), - info_cng <- User.Info.set_source_data(user.info, source_data), - change <- Ecto.Changeset.change(user) |> Ecto.Changeset.put_embed(:info, info_cng), - {:ok, user} <- User.update_and_set_cache(change) do + with {:ok, user} <- User.update_info(user, &User.Info.set_source_data(&1, source_data)) do user else - _e -> - user + _e -> user end ActivityPub.update(%{