Merge remote-tracking branch 'upstream/develop' into by-approval
This commit is contained in:
commit
6931dbfa58
242 changed files with 2000 additions and 2867 deletions
|
|
@ -32,9 +32,19 @@ defmodule Pleroma.Web.MastodonAPI.DomainBlockController do
|
|||
json(conn, %{})
|
||||
end
|
||||
|
||||
def create(%{assigns: %{user: blocker}} = conn, %{domain: domain}) do
|
||||
User.block_domain(blocker, domain)
|
||||
json(conn, %{})
|
||||
end
|
||||
|
||||
@doc "DELETE /api/v1/domain_blocks"
|
||||
def delete(%{assigns: %{user: blocker}, body_params: %{domain: domain}} = conn, _params) do
|
||||
User.unblock_domain(blocker, domain)
|
||||
json(conn, %{})
|
||||
end
|
||||
|
||||
def delete(%{assigns: %{user: blocker}} = conn, %{domain: domain}) do
|
||||
User.unblock_domain(blocker, domain)
|
||||
json(conn, %{})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -93,7 +93,6 @@ defmodule Pleroma.Web.MastodonAPI.SearchController do
|
|||
AccountView.render("index.json",
|
||||
users: accounts,
|
||||
for: options[:for_user],
|
||||
as: :user,
|
||||
embed_relationships: options[:embed_relationships]
|
||||
)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -172,6 +172,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusController do
|
|||
with_direct_conversation_id: true
|
||||
)
|
||||
else
|
||||
{:error, {:reject, message}} ->
|
||||
conn
|
||||
|> put_status(:unprocessable_entity)
|
||||
|> json(%{error: message})
|
||||
|
||||
{:error, message} ->
|
||||
conn
|
||||
|> put_status(:unprocessable_entity)
|
||||
|
|
|
|||
|
|
@ -27,21 +27,40 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
UserRelationship.view_relationships_option(reading_user, users)
|
||||
end
|
||||
|
||||
opts = Map.put(opts, :relationships, relationships_opt)
|
||||
opts =
|
||||
opts
|
||||
|> Map.merge(%{relationships: relationships_opt, as: :user})
|
||||
|> Map.delete(:users)
|
||||
|
||||
users
|
||||
|> render_many(AccountView, "show.json", opts)
|
||||
|> Enum.filter(&Enum.any?/1)
|
||||
end
|
||||
|
||||
def render("show.json", %{user: user} = opts) do
|
||||
if User.visible_for(user, opts[:for]) == :visible do
|
||||
@doc """
|
||||
Renders specified user account.
|
||||
:skip_visibility_check option skips visibility check and renders any user (local or remote)
|
||||
regardless of [:pleroma, :restrict_unauthenticated] setting.
|
||||
:for option specifies the requester and can be a User record or nil.
|
||||
Only use `user: user, for: user` when `user` is the actual requester of own profile.
|
||||
"""
|
||||
def render("show.json", %{user: _user, skip_visibility_check: true} = opts) do
|
||||
do_render("show.json", opts)
|
||||
end
|
||||
|
||||
def render("show.json", %{user: user, for: for_user_or_nil} = opts) do
|
||||
if User.visible_for(user, for_user_or_nil) == :visible do
|
||||
do_render("show.json", opts)
|
||||
else
|
||||
%{}
|
||||
end
|
||||
end
|
||||
|
||||
def render("show.json", _) do
|
||||
raise "In order to prevent account accessibility issues, " <>
|
||||
":skip_visibility_check or :for option is required."
|
||||
end
|
||||
|
||||
def render("mention.json", %{user: user}) do
|
||||
%{
|
||||
id: to_string(user.id),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ defmodule Pleroma.Web.MastodonAPI.ConversationView do
|
|||
|
||||
%{
|
||||
id: participation.id |> to_string(),
|
||||
accounts: render(AccountView, "index.json", users: users, as: :user),
|
||||
accounts: render(AccountView, "index.json", users: users, for: user),
|
||||
unread: !participation.read,
|
||||
last_status:
|
||||
render(StatusView, "show.json",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@ defmodule Pleroma.Web.MastodonAPI.InstanceView do
|
|||
account_activation_required: Keyword.get(instance, :account_activation_required),
|
||||
features: features(),
|
||||
federation: federation(),
|
||||
fields_limits: fields_limits()
|
||||
fields_limits: fields_limits(),
|
||||
post_formats: Config.get([:instance, :allowed_post_formats])
|
||||
},
|
||||
vapid_public_key: Keyword.get(Pleroma.Web.Push.vapid_config(), :public_key)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -297,13 +297,17 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
|
||||
emoji_reactions =
|
||||
with %{data: %{"reactions" => emoji_reactions}} <- object do
|
||||
Enum.map(emoji_reactions, fn [emoji, users] ->
|
||||
%{
|
||||
name: emoji,
|
||||
count: length(users),
|
||||
me: !!(opts[:for] && opts[:for].ap_id in users)
|
||||
}
|
||||
Enum.map(emoji_reactions, fn
|
||||
[emoji, users] when is_list(users) ->
|
||||
build_emoji_map(emoji, users, opts[:for])
|
||||
|
||||
{emoji, users} when is_list(users) ->
|
||||
build_emoji_map(emoji, users, opts[:for])
|
||||
|
||||
_ ->
|
||||
nil
|
||||
end)
|
||||
|> Enum.reject(&is_nil/1)
|
||||
else
|
||||
_ -> []
|
||||
end
|
||||
|
|
@ -545,4 +549,12 @@ defmodule Pleroma.Web.MastodonAPI.StatusView do
|
|||
|
||||
defp pinned?(%Activity{id: id}, %User{pinned_activities: pinned_activities}),
|
||||
do: id in pinned_activities
|
||||
|
||||
defp build_emoji_map(emoji, users, current_user) do
|
||||
%{
|
||||
name: emoji,
|
||||
count: length(users),
|
||||
me: !!(current_user && current_user.ap_id in users)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue