1
0
Fork 1
mirror of https://akkoma.dev/AkkomaGang/akkoma.git synced 2024-11-18 10:59:17 +00:00

[#394] Refactoring.

This commit is contained in:
Ivan Tashkinov 2018-12-06 20:23:16 +03:00
parent 22830c8fc9
commit 7bcb6a183a
3 changed files with 7 additions and 8 deletions

View file

@ -846,12 +846,7 @@ defp tag_or_untag([hd | _] = users, tags, action) when is_map(hd) do
Repo.transaction(fn ->
for user <- users do
new_tags =
if action == :tag do
Enum.uniq(user.tags ++ tags)
else
user.tags -- tags
end
new_tags = mutate_tags(user, tags, action)
{:ok, updated_user} =
user
@ -862,4 +857,8 @@ defp tag_or_untag([hd | _] = users, tags, action) when is_map(hd) do
end
end)
end
defp mutate_tags(user, tags, :tag), do: Enum.uniq(user.tags ++ tags)
defp mutate_tags(user, tags, :untag), do: user.tags -- tags
end

View file

@ -59,7 +59,7 @@ def render("account.json", %{user: user} = opts) do
privacy: user_info.default_scope,
sensitive: false
},
# Note: Mastodon does not return this field:
# Pleroma extension
tags: user.tags
}
end

View file

@ -78,7 +78,7 @@ def render("user.json", %{user: user = %User{}} = assigns) do
"default_scope" => user.info.default_scope,
"no_rich_text" => user.info.no_rich_text,
"fields" => fields,
# Note: twitter.com does not return this field:
# Pleroma extension
"tags" => user.tags
}