From: Egor Kislitsyn Date: Mon, 21 Oct 2019 07:19:15 +0000 (+0700) Subject: Merge branch 'develop' into refactor/following-relationships X-Git-Url: https://git.squeep.com/?a=commitdiff_plain;h=4ea1a61b008c932bc83fcd6cd07bb7f4c251204a;p=akkoma Merge branch 'develop' into refactor/following-relationships --- 4ea1a61b008c932bc83fcd6cd07bb7f4c251204a diff --cc lib/pleroma/user.ex index c32f6b429,ec705b8f6..d3c767f33 --- a/lib/pleroma/user.ex +++ b/lib/pleroma/user.ex @@@ -418,11 -435,14 +416,7 @@@ defmodule Pleroma.User d {:error, "Could not follow user: #{followed.nickname} blocked you."} true -> - if !followed.local && follower.local && !ap_enabled?(followed) do - Websub.subscribe(follower, followed) - end - q = - from(u in User, - where: u.id == ^follower.id, - update: [push: [following: ^ap_followers]], - select: u - ) -- - {1, [follower]} = Repo.update_all(q, []) + FollowingRelationship.follow(follower, followed, state) follower = maybe_update_following_count(follower) diff --cc lib/pleroma/web/activity_pub/transmogrifier.ex index 54ba49520,2c1ce9c55..4eb718294 --- a/lib/pleroma/web/activity_pub/transmogrifier.ex +++ b/lib/pleroma/web/activity_pub/transmogrifier.ex @@@ -555,8 -551,11 +556,9 @@@ defmodule Pleroma.Web.ActivityPub.Trans type: "Reject", actor: followed, object: follow_activity.data["id"], - local: false + local: false, + activity_id: id }) do - User.unfollow(follower, followed) - {:ok, activity} else _e -> :error @@@ -1053,24 -1053,44 +1056,23 @@@ def perform(:user_upgrade, user) do # we pass a fake user so that the followers collection is stripped away old_follower_address = User.ap_followers(%User{nickname: user.nickname}) - maybe_retire_websub(user.ap_id) - q = - from( - u in User, - where: ^old_follower_address in u.following, - update: [ - set: [ - following: - fragment( - "array_replace(?,?,?)", - u.following, - ^old_follower_address, - ^user.follower_address - ) - ] + from( + a in Activity, + where: ^old_follower_address in a.recipients, + update: [ + set: [ + recipients: + fragment( + "array_replace(?,?,?)", + a.recipients, + ^old_follower_address, + ^user.follower_address + ) ] - ) - - Repo.update_all(q, []) - - q = - from( - a in Activity, - where: ^old_follower_address in a.recipients, - update: [ - set: [ - recipients: - fragment( - "array_replace(?,?,?)", - a.recipients, - ^old_follower_address, - ^user.follower_address - ) - ] - ] - ) - - Repo.update_all(q, []) + ] + ) + |> Repo.update_all([]) end def upgrade_user_from_ap_id(ap_id) do