diff options
author | lain <lain@soykaf.club> | 2020-07-01 12:26:07 +0200 |
---|---|---|
committer | lain <lain@soykaf.club> | 2020-07-01 12:26:07 +0200 |
commit | fedfe8f7d6f78d77e9cbaf70fa8a9e8df38463f7 (patch) | |
tree | 683387132a57d9c764f740a1d56c556a6ee7fede /test | |
parent | 9cf4bfcd818b9631e4352cc30236ef541662c86b (diff) | |
download | pleroma-fedfe8f7d6f78d77e9cbaf70fa8a9e8df38463f7.tar.gz pleroma-fedfe8f7d6f78d77e9cbaf70fa8a9e8df38463f7.zip |
ActivityPub: Handle clashing nicknames for the same ap id
If we get a new user (identified by ap_id) that would have the same
nickname as an existing user, give the existing user a nickname that
is prepended with the user id, as this will never clash.
This can happen when a user switches server software and that soft-
ware generates ap ids in a different way.
Diffstat (limited to 'test')
-rw-r--r-- | test/user_test.exs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/user_test.exs b/test/user_test.exs index 9b66f3f51..7126bb539 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -597,6 +597,31 @@ defmodule Pleroma.UserTest do refute user.last_refreshed_at == orig_user.last_refreshed_at end + test "if nicknames clash, the old user gets a prefix with the old id to the nickname" do + a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800) + + orig_user = + insert( + :user, + local: false, + nickname: "admin@mastodon.example.org", + ap_id: "http://mastodon.example.org/users/harinezumigari", + last_refreshed_at: a_week_ago + ) + + assert orig_user.last_refreshed_at == a_week_ago + + {:ok, user} = User.get_or_fetch_by_ap_id("http://mastodon.example.org/users/admin") + + assert user.inbox + + refute user.id == orig_user.id + + orig_user = User.get_by_id(orig_user.id) + + assert orig_user.nickname == "#{orig_user.id}.admin@mastodon.example.org" + end + @tag capture_log: true test "it returns the old user if stale, but unfetchable" do a_week_ago = NaiveDateTime.add(NaiveDateTime.utc_now(), -604_800) |