X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Ffollowing_relationship.ex;h=42db9463db6508d6400af3fca8221c58e118a61e;hb=8d17287e2d223abaab31ccfd0ad0b7e5447aeac1;hp=5390a58e1357e9475bb473b3c2c83077022ee824;hpb=c9afb350e7a38aa915418c6b98cedd863ca0405b;p=akkoma
diff --git a/lib/pleroma/following_relationship.ex b/lib/pleroma/following_relationship.ex
index 5390a58e1..42db9463d 100644
--- a/lib/pleroma/following_relationship.ex
+++ b/lib/pleroma/following_relationship.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.FollowingRelationship do
@@ -152,7 +152,7 @@ defmodule Pleroma.FollowingRelationship do
|> join(:inner, [r], f in assoc(r, :follower))
|> where([r], r.state == ^:follow_pending)
|> where([r], r.following_id == ^id)
- |> where([r, f], f.deactivated != true)
+ |> where([r, f], f.is_active == true)
|> select([r, f], f)
|> Repo.all()
end
@@ -194,12 +194,13 @@ defmodule Pleroma.FollowingRelationship do
|> join(:inner, [r], f in assoc(r, :follower))
|> where(following_id: ^origin.id)
|> where([r, f], f.allow_following_move == true)
+ |> where([r, f], f.local == true)
|> limit(50)
|> preload([:follower])
|> Repo.all()
|> Enum.map(fn following_relationship ->
- Repo.delete(following_relationship)
Pleroma.Web.CommonAPI.follow(following_relationship.follower, target)
+ Pleroma.Web.CommonAPI.unfollow(following_relationship.follower, origin)
end)
|> case do
[] ->
@@ -239,30 +240,6 @@ defmodule Pleroma.FollowingRelationship do
end)
end
- @doc """
- For a query with joined activity,
- keeps rows where activity's actor is followed by user -or- is NOT domain-blocked by user.
- """
- def keep_following_or_not_domain_blocked(query, user) do
- where(
- query,
- [_, activity],
- fragment(
- # "(actor's domain NOT in domain_blocks) OR (actor IS in followed AP IDs)"
- """
- NOT (substring(? from '.*://([^/]*)') = ANY(?)) OR
- ? = ANY(SELECT ap_id FROM users AS u INNER JOIN following_relationships AS fr
- ON u.id = fr.following_id WHERE fr.follower_id = ? AND fr.state = ?)
- """,
- activity.actor,
- ^user.domain_blocks,
- activity.actor,
- ^User.binary_id(user.id),
- ^accept_state_code()
- )
- )
- end
-
defp validate_not_self_relationship(%Changeset{} = changeset) do
changeset
|> validate_follower_id_following_id_inequality()