ActivityPub: Remove ActivityPub.accept
Switch to the pipeline in CommonAPI and SideEffects
This commit is contained in:
parent
f988d82e46
commit
25bfee0d12
|
@ -285,11 +285,6 @@ def listen(%{to: to, actor: actor, context: context, object: object} = params) d
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec accept(map()) :: {:ok, Activity.t()} | {:error, any()}
|
|
||||||
def accept(params) do
|
|
||||||
accept_or_reject("Accept", params)
|
|
||||||
end
|
|
||||||
|
|
||||||
@spec reject(map()) :: {:ok, Activity.t()} | {:error, any()}
|
@spec reject(map()) :: {:ok, Activity.t()} | {:error, any()}
|
||||||
def reject(params) do
|
def reject(params) do
|
||||||
accept_or_reject("Reject", params)
|
accept_or_reject("Reject", params)
|
||||||
|
|
|
@ -16,6 +16,7 @@ defmodule Pleroma.Web.ActivityPub.SideEffects do
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
alias Pleroma.Web.ActivityPub.ActivityPub
|
alias Pleroma.Web.ActivityPub.ActivityPub
|
||||||
|
alias Pleroma.Web.ActivityPub.Builder
|
||||||
alias Pleroma.Web.ActivityPub.Pipeline
|
alias Pleroma.Web.ActivityPub.Pipeline
|
||||||
alias Pleroma.Web.ActivityPub.Utils
|
alias Pleroma.Web.ActivityPub.Utils
|
||||||
alias Pleroma.Web.Push
|
alias Pleroma.Web.Push
|
||||||
|
@ -72,18 +73,8 @@ def handle(
|
||||||
{_, {:ok, _}, _, _} <-
|
{_, {:ok, _}, _, _} <-
|
||||||
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
{:following, User.follow(follower, followed, :follow_pending), follower, followed} do
|
||||||
if followed.local && !followed.locked do
|
if followed.local && !followed.locked do
|
||||||
Utils.update_follow_state_for_all(object, "accept")
|
{:ok, accept_data, _} = Builder.accept(followed, object)
|
||||||
FollowingRelationship.update(follower, followed, :follow_accept)
|
{:ok, _activity, _} = Pipeline.common_pipeline(accept_data, local: true)
|
||||||
User.update_follower_count(followed)
|
|
||||||
User.update_following_count(follower)
|
|
||||||
|
|
||||||
%{
|
|
||||||
to: [following_user],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_id,
|
|
||||||
local: true
|
|
||||||
}
|
|
||||||
|> ActivityPub.accept()
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
{:following, {:error, _}, follower, followed} ->
|
{:following, {:error, _}, follower, followed} ->
|
||||||
|
|
|
@ -122,17 +122,8 @@ def unfollow(follower, unfollowed) do
|
||||||
|
|
||||||
def accept_follow_request(follower, followed) do
|
def accept_follow_request(follower, followed) do
|
||||||
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
with %Activity{} = follow_activity <- Utils.fetch_latest_follow(follower, followed),
|
||||||
{:ok, follower} <- User.follow(follower, followed),
|
{:ok, accept_data, _} <- Builder.accept(followed, follow_activity),
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state_for_all(follow_activity, "accept"),
|
{:ok, _activity, _} <- Pipeline.common_pipeline(accept_data, local: true) do
|
||||||
{:ok, _relationship} <- FollowingRelationship.update(follower, followed, :follow_accept),
|
|
||||||
{:ok, _activity} <-
|
|
||||||
ActivityPub.accept(%{
|
|
||||||
to: [follower.ap_id],
|
|
||||||
actor: followed,
|
|
||||||
object: follow_activity.data["id"],
|
|
||||||
type: "Accept"
|
|
||||||
}) do
|
|
||||||
Notification.update_notification_type(followed, follow_activity)
|
|
||||||
{:ok, follower}
|
{:ok, follower}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue