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,23 +45,27 @@ defmodule Mix.Tasks.Mobilizon.Maintenance.DetectSpam do
|
|||||||
|
|
||||||
anonymous_actor_id = Config.anonymous_actor_id()
|
anonymous_actor_id = Config.anonymous_actor_id()
|
||||||
|
|
||||||
options
|
unless only_events?(options) do
|
||||||
|> Keyword.get(:local_only, false)
|
options
|
||||||
|> profiles()
|
|> Keyword.get(:local_only, false)
|
||||||
|> Stream.flat_map(& &1)
|
|> profiles()
|
||||||
|> Stream.each(fn profile ->
|
|> Stream.flat_map(& &1)
|
||||||
process_profile(profile, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
|> Stream.each(fn profile ->
|
||||||
end)
|
process_profile(profile, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
||||||
|> Stream.run()
|
end)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
|
|
||||||
options
|
unless only_profiles?(options) do
|
||||||
|> Keyword.get(:local_only, false)
|
options
|
||||||
|> events()
|
|> Keyword.get(:local_only, false)
|
||||||
|> Stream.flat_map(& &1)
|
|> events()
|
||||||
|> Stream.each(fn event ->
|
|> Stream.flat_map(& &1)
|
||||||
process_event(event, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
|> Stream.each(fn event ->
|
||||||
end)
|
process_event(event, Keyword.put(options, :anonymous_actor_id, anonymous_actor_id))
|
||||||
|> Stream.run()
|
end)
|
||||||
|
|> Stream.run()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp profiles(local_only) do
|
defp profiles(local_only) do
|
||||||
@ -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