Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into alexgleason/pleroma-confirm-users
This commit is contained in:
commit
fee0c6a2cb
28 changed files with 303 additions and 128 deletions
7
lib/pleroma/logging.ex
Normal file
7
lib/pleroma/logging.ex
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Logging do
|
||||
@callback error(String.t()) :: any()
|
||||
end
|
||||
|
|
@ -142,7 +142,7 @@ defmodule Pleroma.User do
|
|||
field(:allow_following_move, :boolean, default: true)
|
||||
field(:skip_thread_containment, :boolean, default: false)
|
||||
field(:actor_type, :string, default: "Person")
|
||||
field(:also_known_as, {:array, :string}, default: [])
|
||||
field(:also_known_as, {:array, ObjectValidators.ObjectID}, default: [])
|
||||
field(:inbox, :string)
|
||||
field(:shared_inbox, :string)
|
||||
field(:accepts_chat_messages, :boolean, default: nil)
|
||||
|
|
@ -515,6 +515,7 @@ defmodule Pleroma.User do
|
|||
:hide_follows_count,
|
||||
:hide_favorites,
|
||||
:allow_following_move,
|
||||
:also_known_as,
|
||||
:background,
|
||||
:show_role,
|
||||
:skip_thread_containment,
|
||||
|
|
@ -523,7 +524,6 @@ defmodule Pleroma.User do
|
|||
:pleroma_settings_store,
|
||||
:is_discoverable,
|
||||
:actor_type,
|
||||
:also_known_as,
|
||||
:accepts_chat_messages
|
||||
]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
require Pleroma.Constants
|
||||
|
||||
@behaviour Pleroma.Web.ActivityPub.ActivityPub.Persisting
|
||||
@behaviour Pleroma.Web.ActivityPub.ActivityPub.Streaming
|
||||
|
||||
defp get_recipients(%{"type" => "Create"} = data) do
|
||||
to = Map.get(data, "to", [])
|
||||
|
|
@ -224,6 +225,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
Streamer.stream("participation", participations)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def stream_out_participations(%Object{data: %{"context" => context}}, user) do
|
||||
with %Conversation{} = conversation <- Conversation.get_for_ap_id(context) do
|
||||
conversation = Repo.preload(conversation, :participations)
|
||||
|
|
@ -240,8 +242,10 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
end
|
||||
end
|
||||
|
||||
@impl true
|
||||
def stream_out_participations(_, _), do: :noop
|
||||
|
||||
@impl true
|
||||
def stream_out(%Activity{data: %{"type" => data_type}} = activity)
|
||||
when data_type in ["Create", "Announce", "Delete"] do
|
||||
activity
|
||||
|
|
@ -249,6 +253,7 @@ defmodule Pleroma.Web.ActivityPub.ActivityPub do
|
|||
|> Streamer.stream(activity)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def stream_out(_activity) do
|
||||
:noop
|
||||
end
|
||||
|
|
|
|||
12
lib/pleroma/web/activity_pub/activity_pub/streaming.ex
Normal file
12
lib/pleroma/web/activity_pub/activity_pub/streaming.ex
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Pleroma: A lightweight social networking server
|
||||
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
defmodule Pleroma.Web.ActivityPub.ActivityPub.Streaming do
|
||||
alias Pleroma.Activity
|
||||
alias Pleroma.Object
|
||||
alias Pleroma.User
|
||||
|
||||
@callback stream_out(Activity.t()) :: any()
|
||||
@callback stream_out_participations(Object.t(), User.t()) :: any()
|
||||
end
|
||||
|
|
@ -28,6 +28,8 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
|||
require Logger
|
||||
|
||||
@cachex Pleroma.Config.get([:cachex, :provider], Cachex)
|
||||
@ap_streamer Pleroma.Config.get([:side_effects, :ap_streamer], ActivityPub)
|
||||
@logger Pleroma.Config.get([:side_effects, :logger], Logger)
|
||||
|
||||
@behaviour Pleroma.Web.ActivityPub.SideEffects.Handling
|
||||
|
||||
|
|
@ -287,12 +289,12 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
|||
|
||||
MessageReference.delete_for_object(deleted_object)
|
||||
|
||||
ActivityPub.stream_out(object)
|
||||
ActivityPub.stream_out_participations(deleted_object, user)
|
||||
@ap_streamer.stream_out(object)
|
||||
@ap_streamer.stream_out_participations(deleted_object, user)
|
||||
:ok
|
||||
else
|
||||
{:actor, _} ->
|
||||
Logger.error("The object doesn't have an actor: #{inspect(deleted_object)}")
|
||||
@logger.error("The object doesn't have an actor: #{inspect(deleted_object)}")
|
||||
:no_object_actor
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -112,7 +112,8 @@ defmodule Pleroma.Web.ActivityPub.UserView do
|
|||
"tag" => emoji_tags,
|
||||
# Note: key name is indeed "discoverable" (not an error)
|
||||
"discoverable" => user.is_discoverable,
|
||||
"capabilities" => capabilities
|
||||
"capabilities" => capabilities,
|
||||
"alsoKnownAs" => user.also_known_as
|
||||
}
|
||||
|> Map.merge(maybe_make_image(&User.avatar_url/2, "icon", user))
|
||||
|> Map.merge(maybe_make_image(&User.banner_url/2, "image", user))
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ defmodule Pleroma.Web.AdminAPI.ModerationLogView do
|
|||
|> DateTime.to_unix()
|
||||
|
||||
%{
|
||||
id: log_entry.id,
|
||||
data: log_entry.data,
|
||||
time: time,
|
||||
message: ModerationLog.get_log_entry_message(log_entry)
|
||||
|
|
|
|||
|
|
@ -19,8 +19,7 @@ defmodule Pleroma.Web.AdminAPI.ReportView do
|
|||
reports:
|
||||
reports[:items]
|
||||
|> Enum.map(&Report.extract_report_info/1)
|
||||
|> Enum.map(&render(__MODULE__, "show.json", &1))
|
||||
|> Enum.reverse(),
|
||||
|> Enum.map(&render(__MODULE__, "show.json", &1)),
|
||||
total: reports[:total]
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -614,6 +614,12 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||
nullable: true,
|
||||
description: "Allows automatically follow moved following accounts"
|
||||
},
|
||||
also_known_as: %Schema{
|
||||
type: :array,
|
||||
items: %Schema{type: :string},
|
||||
nullable: true,
|
||||
description: "List of alternate ActivityPub IDs"
|
||||
},
|
||||
pleroma_background_image: %Schema{
|
||||
type: :string,
|
||||
nullable: true,
|
||||
|
|
@ -644,6 +650,7 @@ defmodule Pleroma.Web.ApiSpec.AccountOperation do
|
|||
pleroma_settings_store: %{"pleroma-fe" => %{"key" => "val"}},
|
||||
skip_thread_containment: false,
|
||||
allow_following_move: false,
|
||||
also_known_as: ["https://foo.bar/users/foo"],
|
||||
discoverable: false,
|
||||
actor_type: "Person"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ defmodule Pleroma.Web.ApiSpec.Schemas.Account do
|
|||
pleroma: %Schema{
|
||||
type: :object,
|
||||
properties: %{
|
||||
ap_id: %Schema{type: :string},
|
||||
also_known_as: %Schema{type: :array, items: %Schema{type: :string}},
|
||||
allow_following_move: %Schema{
|
||||
type: :boolean,
|
||||
description: "whether the user allows automatically follow moved following accounts"
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||
:show_role,
|
||||
:skip_thread_containment,
|
||||
:allow_following_move,
|
||||
:also_known_as,
|
||||
:accepts_chat_messages
|
||||
]
|
||||
|> Enum.reduce(%{}, fn key, acc ->
|
||||
|
|
@ -207,6 +208,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountController do
|
|||
if bot, do: {:ok, "Service"}, else: {:ok, "Person"}
|
||||
end)
|
||||
|> Maps.put_if_present(:actor_type, params[:actor_type])
|
||||
|> Maps.put_if_present(:also_known_as, params[:also_known_as])
|
||||
# Note: param name is indeed :locked (not an error)
|
||||
|> Maps.put_if_present(:is_locked, params[:locked])
|
||||
# Note: param name is indeed :discoverable (not an error)
|
||||
|
|
|
|||
|
|
@ -265,6 +265,7 @@ defmodule Pleroma.Web.MastodonAPI.AccountView do
|
|||
# Pleroma extension
|
||||
pleroma: %{
|
||||
ap_id: user.ap_id,
|
||||
also_known_as: user.also_known_as,
|
||||
confirmation_pending: user.confirmation_pending,
|
||||
tags: user.tags,
|
||||
hide_followers_count: user.hide_followers_count,
|
||||
|
|
|
|||
|
|
@ -58,12 +58,16 @@ defmodule Pleroma.Web.WebFinger do
|
|||
] ++ Publisher.gather_webfinger_links(user)
|
||||
end
|
||||
|
||||
defp gather_aliases(%User{} = user) do
|
||||
[user.ap_id | user.also_known_as]
|
||||
end
|
||||
|
||||
def represent_user(user, "JSON") do
|
||||
{:ok, user} = User.ensure_keys_present(user)
|
||||
|
||||
%{
|
||||
"subject" => "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}",
|
||||
"aliases" => [user.ap_id],
|
||||
"aliases" => gather_aliases(user),
|
||||
"links" => gather_links(user)
|
||||
}
|
||||
end
|
||||
|
|
@ -71,6 +75,11 @@ defmodule Pleroma.Web.WebFinger do
|
|||
def represent_user(user, "XML") do
|
||||
{:ok, user} = User.ensure_keys_present(user)
|
||||
|
||||
aliases =
|
||||
user
|
||||
|> gather_aliases()
|
||||
|> Enum.map(&{:Alias, &1})
|
||||
|
||||
links =
|
||||
gather_links(user)
|
||||
|> Enum.map(fn link -> {:Link, link} end)
|
||||
|
|
@ -79,9 +88,8 @@ defmodule Pleroma.Web.WebFinger do
|
|||
:XRD,
|
||||
%{xmlns: "http://docs.oasis-open.org/ns/xri/xrd-1.0"},
|
||||
[
|
||||
{:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}"},
|
||||
{:Alias, user.ap_id}
|
||||
] ++ links
|
||||
{:Subject, "acct:#{user.nickname}@#{Pleroma.Web.Endpoint.host()}"}
|
||||
] ++ aliases ++ links
|
||||
}
|
||||
|> XmlBuilder.to_doc()
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue