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,
|
dry_run: :boolean,
|
||||||
verbose: :boolean,
|
verbose: :boolean,
|
||||||
forward_reports: :boolean,
|
forward_reports: :boolean,
|
||||||
local_only: :boolean
|
local_only: :boolean,
|
||||||
|
only_profiles: :boolean,
|
||||||
|
only_events: :boolean
|
||||||
],
|
],
|
||||||
aliases: [
|
aliases: [
|
||||||
d: :dry_run,
|
d: :dry_run,
|
||||||
v: :verbose,
|
v: :verbose,
|
||||||
f: :forward_reports,
|
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()
|
anonymous_actor_id = Config.anonymous_actor_id()
|
||||||
|
|
||||||
|
unless only_events?(options) do
|
||||||
options
|
options
|
||||||
|> Keyword.get(:local_only, false)
|
|> Keyword.get(:local_only, false)
|
||||||
|> profiles()
|
|> profiles()
|
||||||
@ -49,7 +54,9 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||||||
process_profile(profile, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
process_profile(profile, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
||||||
end)
|
end)
|
||||||
|> Stream.run()
|
|> Stream.run()
|
||||||
|
end
|
||||||
|
|
||||||
|
unless only_profiles?(options) do
|
||||||
options
|
options
|
||||||
|> Keyword.get(:local_only, false)
|
|> Keyword.get(:local_only, false)
|
||||||
|> events()
|
|> events()
|
||||||
@ -59,6 +66,7 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||||||
end)
|
end)
|
||||||
|> Stream.run()
|
|> Stream.run()
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
defp profiles(local_only) do
|
defp profiles(local_only) do
|
||||||
shell_info("Starting scanning of profiles")
|
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 verbose?(options), do: Keyword.get(options, :verbose, false)
|
||||||
defp dry_run?(options), do: Keyword.get(options, :dry_run, 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()
|
defp anti_spam, do: AntiSpam.service()
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user