forked from AkkomaGang/akkoma
Merge branch 'develop' of https://git.pleroma.social/pleroma/pleroma into develop
This commit is contained in:
commit
bea4a82d1e
3 changed files with 55 additions and 0 deletions
|
@ -507,6 +507,7 @@ def handle_incoming(
|
||||||
})
|
})
|
||||||
|
|
||||||
{:user_locked, true} ->
|
{:user_locked, true} ->
|
||||||
|
{:ok, _relationship} = FollowingRelationship.update(follower, followed, "pending")
|
||||||
:noop
|
:noop
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
defmodule Pleroma.Repo.Migrations.MigrateFollowingRelationships do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
execute(import_pending_follows_from_activities(), "")
|
||||||
|
end
|
||||||
|
|
||||||
|
defp import_pending_follows_from_activities do
|
||||||
|
"""
|
||||||
|
INSERT INTO
|
||||||
|
following_relationships (
|
||||||
|
follower_id,
|
||||||
|
following_id,
|
||||||
|
state,
|
||||||
|
inserted_at,
|
||||||
|
updated_at
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
followers.id,
|
||||||
|
following.id,
|
||||||
|
activities.data ->> 'state',
|
||||||
|
(activities.data ->> 'published') :: timestamp,
|
||||||
|
now()
|
||||||
|
FROM
|
||||||
|
activities
|
||||||
|
JOIN users AS followers ON (activities.actor = followers.ap_id)
|
||||||
|
JOIN users AS following ON (activities.data ->> 'object' = following.ap_id)
|
||||||
|
WHERE
|
||||||
|
activities.data ->> 'type' = 'Follow'
|
||||||
|
AND activities.data ->> 'state' = 'pending'
|
||||||
|
ORDER BY activities.updated_at DESC
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
end
|
|
@ -804,6 +804,25 @@ test "it works for incomming unfollows with an existing follow" do
|
||||||
refute User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
refute User.following?(User.get_cached_by_ap_id(data["actor"]), user)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "it works for incoming follows to locked account" do
|
||||||
|
pending_follower = insert(:user, ap_id: "http://mastodon.example.org/users/admin")
|
||||||
|
user = insert(:user, locked: true)
|
||||||
|
|
||||||
|
data =
|
||||||
|
File.read!("test/fixtures/mastodon-follow-activity.json")
|
||||||
|
|> Poison.decode!()
|
||||||
|
|> Map.put("object", user.ap_id)
|
||||||
|
|
||||||
|
{:ok, %Activity{data: data, local: false}} = Transmogrifier.handle_incoming(data)
|
||||||
|
|
||||||
|
assert data["type"] == "Follow"
|
||||||
|
assert data["object"] == user.ap_id
|
||||||
|
assert data["state"] == "pending"
|
||||||
|
assert data["actor"] == "http://mastodon.example.org/users/admin"
|
||||||
|
|
||||||
|
assert [^pending_follower] = User.get_follow_requests(user)
|
||||||
|
end
|
||||||
|
|
||||||
test "it works for incoming blocks" do
|
test "it works for incoming blocks" do
|
||||||
user = insert(:user)
|
user = insert(:user)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue