User.follow_all: ensure its stays unique

This commit is contained in:
href 2019-01-31 18:07:46 +01:00
commit 308b35ebe2
No known key found for this signature in database
GPG key ID: EE8296C1A152C325
2 changed files with 23 additions and 1 deletions

View file

@ -315,7 +315,16 @@ defmodule Pleroma.User do
q =
from(u in User,
where: u.id == ^follower.id,
update: [set: [following: fragment("array_cat(?, ?)", u.following, ^followed_addresses)]]
update: [
set: [
following:
fragment(
"array(select distinct unnest (array_cat(?, ?)))",
u.following,
^followed_addresses
)
]
]
)
{1, [follower]} = Repo.update_all(q, [], returning: true)