Following relationship inconsistency
Environment
- Installation type (OTP or From Source): OTP
- Pleroma version (could be found in the "Version" tab of settings in Pleroma-FE): 2.4.1 https://lily.kazv.moe/infra/pleroma/-/commit/182d2d2b9
- Elixir version (
elixir -v
for from source installations, N/A for OTP): N/A - Operating system: Docker image, host system = Ubuntu 20.04
- PostgreSQL version (
psql -V
): 13.5
Bug description
In frontend, some users are shown as if you are following them, but they are not in your following list. In #2802 (closed) , I analysed this as the Follow
Activity not being updated properly.
/opt/pleroma/bin/pleroma remote
, then
t = Pleroma.User.get_by_nickname("tusooa")
import Ecto.Query
q = Pleroma.Activity.Queries.by_type("Follow") |> Pleroma.Activity.Queries.by_actor(t.ap_id) |> where(fragment("data->>'state' = 'accept'"))
as = q |> Pleroma.Repo.all()
apIds = as |> Enum.map(fn a -> a.data["object"] end) |> Enum.filter(fn a -> a end)
folUsers = apIds |> Enum.map(fn id -> Pleroma.User.get_by_ap_id(id) end) |> Enum.filter(fn a -> a end)
problematic = folUsers |> Enum.filter(fn u -> if !Pleroma.User.following?(t, u) do Pleroma.User.get_follow_state(t, u) == :follow_accept else nil end end)
probIds = problematic |> Enum.map(fn u -> u.ap_id end)
One part of the inconsistency is due to user migration. On develop
, Repo.delete(following_relationship)
was run instead of the full unfollow process.
Another part is due to #2802 (closed) .
Another question to ask is: should we really use follow_state == :follow_accept
without guarding (Pleroma.User.following?(one, another)
) to judge whether one is following another?