projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'develop' into global-status-expiration
[akkoma]
/
lib
/
pleroma
/
web
/
mastodon_api
/
views
/
account_view.ex
diff --git
a/lib/pleroma/web/mastodon_api/views/account_view.ex
b/lib/pleroma/web/mastodon_api/views/account_view.ex
index 1068f8823f0ecd464963f84976220f91c5f9a9ff..341dc2c91e2f059a7ced3c4c50d4aca387796138 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/
lib/pleroma/web/mastodon_api/views/account_view.ex
@@
-1,11
+1,10
@@
# Pleroma: A lightweight social networking server
# Pleroma: A lightweight social networking server
-# Copyright © 2017-20
19
Pleroma Authors <https://pleroma.social/>
+# Copyright © 2017-20
20
Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AccountView do
use Pleroma.Web, :view
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AccountView do
use Pleroma.Web, :view
- alias Pleroma.HTML
alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.User
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.MastodonAPI.AccountView
@@
-50,8
+49,8
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
id: to_string(target.id),
following: User.following?(user, target),
followed_by: User.following?(target, user),
id: to_string(target.id),
following: User.following?(user, target),
followed_by: User.following?(target, user),
- blocking: User.blocks_
ap_id
?(user, target),
- blocked_by: User.blocks_
ap_id
?(target, user),
+ blocking: User.blocks_
user
?(user, target),
+ blocked_by: User.blocks_
user
?(target, user),
muting: User.mutes?(user, target),
muting_notifications: User.muted_notifications?(user, target),
subscribing: User.subscribed_to?(user, target),
muting: User.mutes?(user, target),
muting_notifications: User.muted_notifications?(user, target),
subscribing: User.subscribed_to?(user, target),
@@
-67,7
+66,8
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
end
defp do_render("show.json", %{user: user} = opts) do
end
defp do_render("show.json", %{user: user} = opts) do
- display_name = HTML.strip_tags(user.name || user.nickname)
+ user = User.sanitize_html(user, User.html_filter_policy(opts[:for]))
+ display_name = user.name || user.nickname
image = User.avatar_url(user) |> MediaProxy.url()
header = User.banner_url(user) |> MediaProxy.url()
image = User.avatar_url(user) |> MediaProxy.url()
header = User.banner_url(user) |> MediaProxy.url()
@@
-86,7
+86,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
0
end
0
end
- bot =
(user.source_data["type"] || "Person")
in ["Application", "Service"]
+ bot =
user.actor_type
in ["Application", "Service"]
emojis =
(user.source_data["tag"] || [])
emojis =
(user.source_data["tag"] || [])
@@
-100,17
+100,6
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
}
end)
}
end)
- fields =
- user
- |> User.fields()
- |> Enum.map(fn %{"name" => name, "value" => value} ->
- %{
- "name" => Pleroma.HTML.strip_tags(name),
- "value" => Pleroma.HTML.filter_tags(value, Pleroma.HTML.Scrubber.LinksOnly)
- }
- end)
-
- bio = HTML.filter_tags(user.bio, User.html_filter_policy(opts[:for]))
relationship = render("relationship.json", %{user: opts[:for], target: user})
%{
relationship = render("relationship.json", %{user: opts[:for], target: user})
%{
@@
-123,21
+112,22
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
followers_count: followers_count,
following_count: following_count,
statuses_count: user.note_count,
followers_count: followers_count,
following_count: following_count,
statuses_count: user.note_count,
- note: bio || "",
+ note:
user.
bio || "",
url: User.profile_url(user),
avatar: image,
avatar_static: image,
header: header,
header_static: header,
emojis: emojis,
url: User.profile_url(user),
avatar: image,
avatar_static: image,
header: header,
header_static: header,
emojis: emojis,
- fields: fields,
+ fields:
user.
fields,
bot: bot,
source: %{
bot: bot,
source: %{
- note: HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
+ note:
Pleroma.
HTML.strip_tags((user.bio || "") |> String.replace("<br>", "\n")),
sensitive: false,
fields: user.raw_fields,
pleroma: %{
sensitive: false,
fields: user.raw_fields,
pleroma: %{
- discoverable: user.discoverable
+ discoverable: user.discoverable,
+ actor_type: user.actor_type
}
},
}
},
@@
-162,6
+152,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
|> maybe_put_chat_token(user, opts[:for], opts)
|> maybe_put_activation_status(user, opts[:for])
|> maybe_put_follow_requests_count(user, opts[:for])
|> maybe_put_chat_token(user, opts[:for], opts)
|> maybe_put_activation_status(user, opts[:for])
|> maybe_put_follow_requests_count(user, opts[:for])
+ |> maybe_put_allow_following_move(user, opts[:for])
|> maybe_put_unread_conversation_count(user, opts[:for])
end
|> maybe_put_unread_conversation_count(user, opts[:for])
end
@@
-238,6
+229,12
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
defp maybe_put_notification_settings(data, _, _), do: data
defp maybe_put_notification_settings(data, _, _), do: data
+ defp maybe_put_allow_following_move(data, %User{id: user_id} = user, %User{id: user_id}) do
+ Kernel.put_in(data, [:pleroma, :allow_following_move], user.allow_following_move)
+ end
+
+ defp maybe_put_allow_following_move(data, _, _), do: data
+
defp maybe_put_activation_status(data, user, %User{is_admin: true}) do
Kernel.put_in(data, [:pleroma, :deactivated], user.deactivated)
end
defp maybe_put_activation_status(data, user, %User{is_admin: true}) do
Kernel.put_in(data, [:pleroma, :deactivated], user.deactivated)
end