generating remote users

This commit is contained in:
Alex S 2019-09-06 20:14:02 +03:00
parent 252e5db45c
commit b3f6f6a409
3 changed files with 30 additions and 10 deletions

View file

@ -215,7 +215,7 @@ def query_long_thread(user, activity) do
for: user for: user
}) })
end, end,
"Render context ancestors" => fn -> "Render context" => fn ->
Pleroma.Web.MastodonAPI.StatusView.render( Pleroma.Web.MastodonAPI.StatusView.render(
"index.json", "index.json",
for: user, for: user,

View file

@ -22,6 +22,8 @@ defp do_generate_users(opts) do
end end
defp generate_user_data(i) do defp generate_user_data(i) do
remote = Enum.random([true, false])
user = %User{ user = %User{
name: "Test テスト User #{i}", name: "Test テスト User #{i}",
email: "user#{i}@example.com", email: "user#{i}@example.com",
@ -29,16 +31,32 @@ defp generate_user_data(i) do
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"), password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: "Tester Number #{i}", bio: "Tester Number #{i}",
info: %{}, info: %{},
local: Enum.random([true, false]) local: remote
} }
user = %{ user_urls =
user if remote do
| ap_id: User.ap_id(user), base_url =
follower_address: User.ap_followers(user), Enum.random(["https://domain1.com", "https://domain2.com", "https://domain3.com"])
following_address: User.ap_following(user),
following: [User.ap_id(user)] ap_id = "#{base_url}/users/#{user.nickname}"
}
%{
ap_id: ap_id,
follower_address: ap_id <> "/followers",
following_address: ap_id <> "/following",
following: [ap_id]
}
else
%{
ap_id: User.ap_id(user),
follower_address: User.ap_followers(user),
following_address: User.ap_following(user),
following: [User.ap_id(user)]
}
end
user = Map.merge(user, user_urls)
Repo.insert!(user) Repo.insert!(user)
end end

View file

@ -429,7 +429,9 @@ def follow(%User{} = follower, %User{info: info} = followed) do
{:error, "Could not follow user: #{followed.nickname} blocked you."} {:error, "Could not follow user: #{followed.nickname} blocked you."}
true -> true ->
if !followed.local && follower.local && !ap_enabled?(followed) do benchmark? = Pleroma.Config.get([:env]) == :benchmark
if !followed.local && follower.local && !ap_enabled?(followed) && !benchmark? do
Websub.subscribe(follower, followed) Websub.subscribe(follower, followed)
end end