File tree Expand file tree Collapse file tree
lib/teiserver/moderation/tasks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,19 +2,35 @@ defmodule Teiserver.Moderation.LoadBannedDomainsTask do
22 @ moduledoc """
33 Loads the list of banned domains from the database into the cache.
44 """
5+ alias Req.Response
56 alias Teiserver.Helpers.CacheHelper
67 alias Teiserver.Moderation
78 alias Teiserver.Moderation.BannedDomain
89
910 def perform do
10- banned_domains =
11+ url = Config . get_site_config_cache ( "teiserver.Email domain blocklist URL" )
12+
13+ external_banned_domains =
14+ with true <- url != nil and url != "" ,
15+ { :ok , % Response { status: 200 , body: body } } <- Req . get ( url ) do
16+ String . split ( body , "\n " )
17+ else
18+ { :error , error } ->
19+ Logger . error ( "Error loading VPN list - #{ inspect ( error ) } " )
20+ [ ]
21+
22+ _any ->
23+ [ ]
24+ end
25+
26+ internal_banned_domains =
1127 Moderation . list_banned_domains ( )
1228 |> Enum . map ( fn % BannedDomain { domain: domain } -> domain end )
1329
1430 CacheHelper . store_put (
1531 :application_metadata_cache ,
1632 "banned_domains" ,
17- banned_domains
33+ external_banned_domains ++ internal_banned_domains
1834 )
1935 end
2036
You can’t perform that action at this time.
0 commit comments