decidim-spam_detection 3.0.0 → 4.0.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/commands/decidim/admin/unblock_user.rb +2 -2
- data/app/commands/decidim/admin/unreport_user.rb +2 -2
- data/app/services/decidim/spam_detection/mark_users_service.rb +2 -0
- data/lib/decidim/spam_detection/abstract_spam_user_command.rb +0 -1
- 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 +2 -2
- data/lib/decidim/spam_detection.rb +31 -0
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc40888f7da14f290222e3e99fcd985c8020affbebc5f7d213754e8415025db9
|
4
|
+
data.tar.gz: 62521b3df543d4b344aaa937e2cb53d572ac5fc96559dabbefdbaa55b5f26664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1934658b6b73cfa41fece1ac68f3d4b85360e53ab179bcb3e62c48b99228ccd1b9b368d92e1ab057270eb8d321ee86303d8a2df1026e11885f73397cd48c7ae6
|
7
|
+
data.tar.gz: 36083c1b45fd4ad0c49ad5fbfc466f0631ecc9c5907611a7629868d5ae72b533c912d8e236e1484b7882cfb011ed674f1d82384a905a65de46f551bfd4e4c12b
|
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
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
class UnblockUser <
|
5
|
+
class UnblockUser < Decidim::Command
|
6
6
|
# Public: Initializes the command.
|
7
7
|
#
|
8
8
|
# blocked_user - the user that is unblocked
|
@@ -48,7 +48,7 @@ module Decidim
|
|
48
48
|
def add_spam_detection_metadata!
|
49
49
|
return if @blocked_user.extended_data.dig("spam_detection", "blocked_at").blank?
|
50
50
|
|
51
|
-
@blocked_user.update!(extended_data: @blocked_user.extended_data.dup.deep_merge("spam_detection" => {
|
51
|
+
@blocked_user.update!(extended_data: @blocked_user.extended_data.dup.deep_merge("spam_detection" => { unblocked_at: Time.current }))
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Decidim
|
4
4
|
module Admin
|
5
|
-
class UnreportUser <
|
5
|
+
class UnreportUser < Decidim::Command
|
6
6
|
# Public: Initializes the command.
|
7
7
|
#
|
8
8
|
# reportable - A Decidim::User - The user reported
|
@@ -46,7 +46,7 @@ module Decidim
|
|
46
46
|
def add_spam_detection_metadata!
|
47
47
|
return if @reportable.extended_data.dig("spam_detection", "reported_at").blank?
|
48
48
|
|
49
|
-
@reportable.update!(extended_data: @reportable.extended_data.dup.deep_merge("spam_detection" => {
|
49
|
+
@reportable.update!(extended_data: @reportable.extended_data.dup.deep_merge("spam_detection" => { unreported_at: Time.current }))
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -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:
|
4
|
+
version: 4.0.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-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim-core
|
@@ -16,18 +16,19 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.27.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
27
|
-
description:
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
version: 0.27.0
|
27
|
+
description: |2
|
28
|
+
SpamDetection is a detection bot made by OpenSourcePolitics.
|
29
|
+
It works with a spam detection service (https://github.com/OpenSourcePolitics/spam_detection)
|
30
|
+
which marks the user with a spam probability score,
|
31
|
+
between 0.7 and 0.99 it is probable, and above 0.99 it is very sure.
|
31
32
|
email:
|
32
33
|
- fardeauarmand@gmail.com
|
33
34
|
executables: []
|
@@ -75,7 +76,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
76
|
requirements:
|
76
77
|
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
79
|
+
version: '3.0'
|
79
80
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
82
|
- - ">="
|