decidim-spam_detection 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/app/services/decidim/spam_detection/mark_users_service.rb +2 -0
- data/lib/decidim/spam_detection/api_proxy.rb +2 -2
- data/lib/decidim/spam_detection/spam_user_command_adapter.rb +1 -1
- data/lib/decidim/spam_detection/version.rb +1 -1
- data/lib/decidim/spam_detection.rb +31 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f24ecac49f9c8814f2dd96c598a036884b67f170ff780f45fc08edfd889f4731
|
4
|
+
data.tar.gz: d4fcfab70fafa852c915207a7762a380afe5b55d4e330a22e3c1a96c8df49cce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231ce11ea08422ce24f822b68c33a5ec73641e8077d3615097443b9e3a14ed0e29c3ccc89dfae7c3de89927881b6e1230f9903a6eba17be2783ccbc249c61957
|
7
|
+
data.tar.gz: b1aa9020d61d8683e4d66bb05c6f6042bcaa6f37ac917af76d3e00dc3f1ae4eec437b23a64ff3da9d24736613757d6c70f47b220eb35d594a9e49fa10bfc3248
|
data/README.md
CHANGED
@@ -44,6 +44,9 @@ if you are using sidekiq scheduler you can use the following configuration:
|
|
44
44
|
### Further configuration
|
45
45
|
list of env var, default value and their usage:
|
46
46
|
```
|
47
|
+
ACTIVATE_SPAM_DETECTION_SERVICE:
|
48
|
+
default: false
|
49
|
+
usage: Activate the spam detection service if api url is set to default one
|
47
50
|
SPAM_DETECTION_API_AUTH_TOKEN
|
48
51
|
default_value: dummy
|
49
52
|
usage: Token auth for authentication used by external service, ask us for more details
|
@@ -6,8 +6,8 @@ require "net/http"
|
|
6
6
|
module Decidim
|
7
7
|
module SpamDetection
|
8
8
|
class ApiProxy
|
9
|
-
URL = URI(
|
10
|
-
AUTH_TOKEN =
|
9
|
+
URL = URI(Decidim::SpamDetection.spam_detection_api_url)
|
10
|
+
AUTH_TOKEN = Decidim::SpamDetection.spam_detection_api_auth_token
|
11
11
|
|
12
12
|
def initialize(data_array, batch_size)
|
13
13
|
@data_array = data_array
|
@@ -8,6 +8,9 @@ module Decidim
|
|
8
8
|
# This namespace holds the logic of the `SpamDetection` component. This component
|
9
9
|
# allows users to create spam_detection in a participatory space.
|
10
10
|
module SpamDetection
|
11
|
+
DEFAULT_URL = "http://localhost:8080/api"
|
12
|
+
include ActiveSupport::Configurable
|
13
|
+
|
11
14
|
autoload :Command, "decidim/spam_detection/command"
|
12
15
|
autoload :CommandErrors, "decidim/spam_detection/command_errors"
|
13
16
|
autoload :ApiProxy, "decidim/spam_detection/api_proxy"
|
@@ -15,5 +18,33 @@ module Decidim
|
|
15
18
|
autoload :ReportSpamUserCommand, "decidim/spam_detection/report_spam_user_command"
|
16
19
|
autoload :BlockSpamUserCommand, "decidim/spam_detection/block_spam_user_command"
|
17
20
|
autoload :SpamUserCommandAdapter, "decidim/spam_detection/spam_user_command_adapter"
|
21
|
+
|
22
|
+
config_accessor :spam_detection_api_url do
|
23
|
+
ENV.fetch("SPAM_DETECTION_API_URL", DEFAULT_URL)
|
24
|
+
end
|
25
|
+
|
26
|
+
config_accessor :spam_detection_api_auth_token do
|
27
|
+
ENV.fetch("SPAM_DETECTION_API_AUTH_TOKEN", "dummy")
|
28
|
+
end
|
29
|
+
|
30
|
+
config_accessor :spam_detection_api_perform_block_user do
|
31
|
+
ENV.fetch("PERFORM_BLOCK_USER", "0") == "1"
|
32
|
+
end
|
33
|
+
|
34
|
+
config_accessor :spam_detection_api_force_activate_service do
|
35
|
+
ENV.fetch("ACTIVATE_SPAM_DETECTION_SERVICE", "0") == "1"
|
36
|
+
end
|
37
|
+
|
38
|
+
config_accessor :spam_detection_api_activate_service do
|
39
|
+
lambda do
|
40
|
+
return true unless Rails.env.production?
|
41
|
+
|
42
|
+
spam_detection_api_force_activate_service || spam_detection_api_url != DEFAULT_URL
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.service_activated?
|
47
|
+
spam_detection_api_activate_service.call
|
48
|
+
end
|
18
49
|
end
|
19
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-spam_detection
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Armand Fardeau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01-
|
11
|
+
date: 2023-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-core
|