forked from potsda.mn/mobilizon
feat(anti-spam): allow to only scan for spam in profiles or events
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
618b3d23d9
commit
c971287624
|
@ -23,13 +23,17 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||
dry_run: :boolean,
|
||||
verbose: :boolean,
|
||||
forward_reports: :boolean,
|
||||
local_only: :boolean
|
||||
local_only: :boolean,
|
||||
only_profiles: :boolean,
|
||||
only_events: :boolean
|
||||
],
|
||||
aliases: [
|
||||
d: :dry_run,
|
||||
v: :verbose,
|
||||
f: :forward_reports,
|
||||
l: :local_only
|
||||
l: :local_only,
|
||||
p: :only_profiles,
|
||||
e: :only_events
|
||||
]
|
||||
)
|
||||
|
||||
|
@ -41,6 +45,7 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||
|
||||
anonymous_actor_id = Config.anonymous_actor_id()
|
||||
|
||||
unless only_events?(options) do
|
||||
options
|
||||
|> Keyword.get(:local_only, false)
|
||||
|> profiles()
|
||||
|
@ -49,7 +54,9 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||
process_profile(profile, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
||||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
|
||||
unless only_profiles?(options) do
|
||||
options
|
||||
|> Keyword.get(:local_only, false)
|
||||
|> events()
|
||||
|
@ -59,6 +66,7 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||
end)
|
||||
|> Stream.run()
|
||||
end
|
||||
end
|
||||
|
||||
defp profiles(local_only) do
|
||||
shell_info("Starting scanning of profiles")
|
||||
|
@ -180,6 +188,8 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||
|
||||
defp verbose?(options), do: Keyword.get(options, :verbose, false)
|
||||
defp dry_run?(options), do: Keyword.get(options, :dry_run, false)
|
||||
defp only_profiles?(options), do: Keyword.get(options, :only_profiles, false)
|
||||
defp only_events?(options), do: Keyword.get(options, :only_events, false)
|
||||
|
||||
defp anti_spam, do: AntiSpam.service()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue