Add user upgrade function.
This commit is contained in:
parent
f48bc5c3e1
commit
4816b09fa7
4 changed files with 91 additions and 6 deletions
|
|
@ -178,4 +178,40 @@ defmodule Pleroma.Web.ActivityPub.TransmogrifierTest do
|
|||
assert modified["object"]["actor"] == modified["object"]["attributedTo"]
|
||||
end
|
||||
end
|
||||
|
||||
describe "user upgrade" do
|
||||
test "it upgrades a user to activitypub" do
|
||||
user = insert(:user, %{local: false, ap_id: "https://niu.moe/users/rye", follower_address: "..."})
|
||||
user_two = insert(:user, %{following: [user.follower_address]})
|
||||
|
||||
{:ok, activity} = CommonAPI.post(user, %{"status" => "test"})
|
||||
{:ok, unrelated_activity} = CommonAPI.post(user_two, %{"status" => "test"})
|
||||
assert "..." in activity.recipients
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
assert user.info["note_count"] == 1
|
||||
|
||||
{:ok, user} = Transmogrifier.upgrade_user_from_ap_id("https://niu.moe/users/rye")
|
||||
assert user.info["ap_enabled"]
|
||||
assert user.info["note_count"] == 1
|
||||
assert user.follower_address == "https://niu.moe/users/rye/followers"
|
||||
|
||||
# Wait for the background task
|
||||
:timer.sleep(1000)
|
||||
|
||||
user = Repo.get(User, user.id)
|
||||
assert user.info["note_count"] == 1
|
||||
|
||||
activity = Repo.get(Activity, activity.id)
|
||||
assert user.follower_address in activity.recipients
|
||||
refute "..." in activity.recipients
|
||||
|
||||
unrelated_activity = Repo.get(Activity, unrelated_activity.id)
|
||||
refute user.follower_address in unrelated_activity.recipients
|
||||
|
||||
user_two = Repo.get(User, user_two.id)
|
||||
assert user.follower_address in user_two.following
|
||||
refute "..." in user_two.following
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue