{: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)
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
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