mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-20 04:04:44 +00:00
Merge branch 'bugfix/fix-rejects' into 'develop'
follow request fixups Closes #537 See merge request pleroma/pleroma!734
This commit is contained in:
commit
7a2c4f984b
2 changed files with 21 additions and 2 deletions
|
@ -453,9 +453,9 @@ defmodule Pleroma.Web.ActivityPub.Transmogrifier do
|
||||||
{:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "reject"),
|
{:ok, follow_activity} <- Utils.update_follow_state(follow_activity, "reject"),
|
||||||
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
|
%User{local: true} = follower <- User.get_cached_by_ap_id(follow_activity.data["actor"]),
|
||||||
{:ok, activity} <-
|
{:ok, activity} <-
|
||||||
ActivityPub.accept(%{
|
ActivityPub.reject(%{
|
||||||
to: follow_activity.data["to"],
|
to: follow_activity.data["to"],
|
||||||
type: "Accept",
|
type: "Reject",
|
||||||
actor: followed.ap_id,
|
actor: followed.ap_id,
|
||||||
object: follow_activity.data["id"],
|
object: follow_activity.data["id"],
|
||||||
local: false
|
local: false
|
||||||
|
|
|
@ -316,6 +316,25 @@ defmodule Pleroma.Web.ActivityPub.Utils do
|
||||||
@doc """
|
@doc """
|
||||||
Updates a follow activity's state (for locked accounts).
|
Updates a follow activity's state (for locked accounts).
|
||||||
"""
|
"""
|
||||||
|
def update_follow_state(
|
||||||
|
%Activity{data: %{"actor" => actor, "object" => object, "state" => "pending"}} = activity,
|
||||||
|
state
|
||||||
|
) do
|
||||||
|
try do
|
||||||
|
Ecto.Adapters.SQL.query!(
|
||||||
|
Repo,
|
||||||
|
"UPDATE activities SET data = jsonb_set(data, '{state}', $1) WHERE data->>'type' = 'Follow' AND data->>'actor' = $2 AND data->>'object' = $3 AND data->>'state' = 'pending'",
|
||||||
|
[state, actor, object]
|
||||||
|
)
|
||||||
|
|
||||||
|
activity = Repo.get(Activity, activity.id)
|
||||||
|
{:ok, activity}
|
||||||
|
rescue
|
||||||
|
e ->
|
||||||
|
{:error, e}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def update_follow_state(%Activity{} = activity, state) do
|
def update_follow_state(%Activity{} = activity, state) do
|
||||||
with new_data <-
|
with new_data <-
|
||||||
activity.data
|
activity.data
|
||||||
|
|
Loading…
Reference in a new issue