Make sure relay and anonymous actors don't automatically approve

followers

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-05-12 11:02:46 +02:00
parent 938f698b7a
commit 628c55cd84
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 30 additions and 13 deletions

View file

@ -416,17 +416,18 @@ defmodule Mobilizon.Actors.Actor do
@spec build_relay_creation_attrs :: Ecto.Changeset.t()
def build_relay_creation_attrs do
data = %{
"name" => Config.get([:instance, :name], "Mobilizon"),
"summary" =>
name: Config.get([:instance, :name], "Mobilizon"),
summary:
Config.get(
[:instance, :description],
"An internal service actor for this Mobilizon instance"
),
"keys" => Crypto.generate_rsa_2048_private_key(),
"preferred_username" => "relay",
"domain" => nil,
"visibility" => :public,
"type" => :Application
keys: Crypto.generate_rsa_2048_private_key(),
preferred_username: "relay",
domain: nil,
visibility: :public,
type: :Application,
manually_approves_followers: true
}
%__MODULE__{}
@ -440,12 +441,13 @@ defmodule Mobilizon.Actors.Actor do
@spec build_anonymous_actor_creation_attrs :: Ecto.Changeset.t()
def build_anonymous_actor_creation_attrs do
data = %{
"name" => "Mobilizon Anonymous Actor",
"summary" => "A fake person for anonymous participations",
"keys" => Crypto.generate_rsa_2048_private_key(),
"preferred_username" => "anonymous",
"domain" => nil,
"type" => :Person
name: "Mobilizon Anonymous Actor",
summary: "A fake person for anonymous participations",
keys: Crypto.generate_rsa_2048_private_key(),
preferred_username: "anonymous",
domain: nil,
type: :Person,
manually_approves_followers: true
}
%__MODULE__{}

View file

@ -0,0 +1,15 @@
defmodule Mobilizon.Storage.Repo.Migrations.RepairRelayAndAnonymousActors do
use Ecto.Migration
def up do
Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo,
"UPDATE actors SET manually_approves_followers = true WHERE preferred_username = 'relay' and domain is null"
)
Ecto.Adapters.SQL.query!(
Mobilizon.Storage.Repo,
"UPDATE actors SET manually_approves_followers = true WHERE preferred_username = 'anonymous' and domain is null"
)
end
end