projects
/
akkoma
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'bugfix/1543-streaming-boosts' into 'develop'
[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 0efcabc019b420f56c7b3a0e7f7c9f844b1ea07f..b4b61e74cfd393fe22cb9241a024c4cce661178f 100644
(file)
--- a/
lib/pleroma/web/mastodon_api/views/account_view.ex
+++ b/
lib/pleroma/web/mastodon_api/views/account_view.ex
@@
-13,16
+13,19
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
alias Pleroma.Web.MediaProxy
def render("index.json", %{users: users} = opts) do
alias Pleroma.Web.MediaProxy
def render("index.json", %{users: users} = opts) do
+ reading_user = opts[:for]
+
+ # Note: :skip_relationships option is currently intentionally not supported for accounts
relationships_opt =
cond do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
relationships_opt =
cond do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
- is_nil(
opts[:for]
) ->
+ is_nil(
reading_user
) ->
UserRelationship.view_relationships_option(nil, [])
true ->
UserRelationship.view_relationships_option(nil, [])
true ->
- UserRelationship.view_relationships_option(
opts[:for]
, users)
+ UserRelationship.view_relationships_option(
reading_user
, users)
end
opts = Map.put(opts, :relationships, relationships_opt)
end
opts = Map.put(opts, :relationships, relationships_opt)
@@
-43,7
+46,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
id: to_string(user.id),
acct: user.nickname,
username: username_from_nickname(user.nickname),
id: to_string(user.id),
acct: user.nickname,
username: username_from_nickname(user.nickname),
- url:
User.profile_url(user)
+ url:
user.uri || user.ap_id
}
end
}
end
@@
-71,7
+74,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
followed_by =
if following_relationships do
case FollowingRelationship.find(following_relationships, target, reading_user) do
followed_by =
if following_relationships do
case FollowingRelationship.find(following_relationships, target, reading_user) do
- %{state:
"accept"
} -> true
+ %{state:
:follow_accept
} -> true
_ -> false
end
else
_ -> false
end
else
@@
-81,7
+84,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
# NOTE: adjust UserRelationship.view_relationships_option/2 on new relation-related flags
%{
id: to_string(target.id),
# NOTE: adjust UserRelationship.view_relationships_option/2 on new relation-related flags
%{
id: to_string(target.id),
- following: follow_state ==
"accept"
,
+ following: follow_state ==
:follow_accept
,
followed_by: followed_by,
blocking:
UserRelationship.exists?(
followed_by: followed_by,
blocking:
UserRelationship.exists?(
@@
-123,7
+126,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
reading_user,
&User.subscribed_to?(&2, &1)
),
reading_user,
&User.subscribed_to?(&2, &1)
),
- requested: follow_state ==
"pending"
,
+ requested: follow_state ==
:follow_pending
,
domain_blocking: User.blocks_domain?(reading_user, target),
showing_reblogs:
not UserRelationship.exists?(
domain_blocking: User.blocks_domain?(reading_user, target),
showing_reblogs:
not UserRelationship.exists?(
@@
-143,7
+146,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
Map.has_key?(opts, :relationships) ->
opts[:relationships]
Map.has_key?(opts, :relationships) ->
opts[:relationships]
- is_nil(
opts[:for]
) ->
+ is_nil(
user
) ->
UserRelationship.view_relationships_option(nil, [])
true ->
UserRelationship.view_relationships_option(nil, [])
true ->
@@
-178,23
+181,25
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
bot = user.actor_type in ["Application", "Service"]
emojis =
bot = user.actor_type in ["Application", "Service"]
emojis =
- (user.source_data["tag"] || [])
- |> Enum.filter(fn %{"type" => t} -> t == "Emoji" end)
- |> Enum.map(fn %{"icon" => %{"url" => url}, "name" => name} ->
+ Enum.map(user.emoji, fn {shortcode, url} ->
%{
%{
- "shortcode" =>
String.trim(name, ":")
,
- "url" =>
MediaProxy.url(url)
,
- "static_url" =>
MediaProxy.url(url)
,
+ "shortcode" =>
shortcode
,
+ "url" =>
url
,
+ "static_url" =>
url
,
"visible_in_picker" => false
}
end)
relationship =
"visible_in_picker" => false
}
end)
relationship =
- render("relationship.json", %{
- user: opts[:for],
- target: user,
- relationships: opts[:relationships]
- })
+ if opts[:skip_relationships] do
+ %{}
+ else
+ render("relationship.json", %{
+ user: opts[:for],
+ target: user,
+ relationships: opts[:relationships]
+ })
+ end
%{
id: to_string(user.id),
%{
id: to_string(user.id),
@@
-207,7
+212,7
@@
defmodule Pleroma.Web.MastodonAPI.AccountView do
following_count: following_count,
statuses_count: user.note_count,
note: user.bio || "",
following_count: following_count,
statuses_count: user.note_count,
note: user.bio || "",
- url:
User.profile_url(user)
,
+ url:
user.uri || user.ap_id
,
avatar: image,
avatar_static: image,
header: header,
avatar: image,
avatar_static: image,
header: header,