forked from AkkomaGang/akkoma
[#394] Refactoring.
This commit is contained in:
parent
22830c8fc9
commit
7bcb6a183a
3 changed files with 7 additions and 8 deletions
|
@ -846,12 +846,7 @@ defmodule Pleroma.User do
|
||||||
|
|
||||||
Repo.transaction(fn ->
|
Repo.transaction(fn ->
|
||||||
for user <- users do
|
for user <- users do
|
||||||
new_tags =
|
new_tags = mutate_tags(user, tags, action)
|
||||||
if action == :tag do
|
|
||||||
Enum.uniq(user.tags ++ tags)
|
|
||||||
else
|
|
||||||
user.tags -- tags
|
|
||||||
end
|
|
||||||
|
|
||||||
{:ok, updated_user} =
|
{:ok, updated_user} =
|
||||||
user
|
user
|
||||||
|
@ -862,4 +857,8 @@ defmodule Pleroma.User do
|
||||||
end
|
end
|
||||||
end)
|
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
|
end
|
||||||
|
|
|
@ -59,7 +59,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
||||||
privacy: user_info.default_scope,
|
privacy: user_info.default_scope,
|
||||||
sensitive: false
|
sensitive: false
|
||||||
},
|
},
|
||||||
# Note: Mastodon does not return this field:
|
# Pleroma extension
|
||||||
tags: user.tags
|
tags: user.tags
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -78,7 +78,7 @@ defmodule Pleroma.Web.TwitterAPI.UserView do
|
||||||
"default_scope" => user.info.default_scope,
|
"default_scope" => user.info.default_scope,
|
||||||
"no_rich_text" => user.info.no_rich_text,
|
"no_rich_text" => user.info.no_rich_text,
|
||||||
"fields" => fields,
|
"fields" => fields,
|
||||||
# Note: twitter.com does not return this field:
|
# Pleroma extension
|
||||||
"tags" => user.tags
|
"tags" => user.tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue