decidim-spam_detection 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38cc3310b2ed4c7e48cadea2c1bf9f0ff86d8f28bad7b3e04398d5922598442d
4
- data.tar.gz: be191b16b6827c2e6963b72578fe899d1feace76156b87cb246928dc869619d3
3
+ metadata.gz: 9b9e77c55c37762f44ecfcfcd84d383ddef69ecd39a46e50586715c2b943850d
4
+ data.tar.gz: 5c4e554147e711a82b7f2d1271c50166972d79bb9701a1d56aca424b0a646662
5
5
  SHA512:
6
- metadata.gz: ef0c0fcc58dfdb427725cc53ad5a3fa2829b0482180e4b311427a483345b97f09ec90d55ffdcfaf778903ed00913bf17976ae56e2a9fb13deb17605cf45c0425
7
- data.tar.gz: 9d6b782f0b236cd000b1bf361b5d83524c037da23fa22aa779321f5c09fafbc849d45d713c965b2e9a6eb2a37d465565e91b33bfcff0a1e73436065ee76265b6
6
+ metadata.gz: 6702d4551ed229114b12cbd672f7714e9a4cf291bb8121919ffca7414470fe90ac18b66bc5d19c963017a159cd107ceb3d58d9b21359a5260486b868dd6d0ae4
7
+ data.tar.gz: '0719aa19be805f1732b391e1c3b172ce31be3504a41b6fc0ab8130793350b843bbe827acd6efa4e7e3c39b9f129275ad1eb4bc674f12c39c5386067825a6f0a9'
data/README.md CHANGED
@@ -1,7 +1,8 @@
1
1
  # Decidim::SpamDetection
2
2
  [![codecov](https://codecov.io/gh/OpenSourcePolitics/decidim-spam_detection/branch/master/graph/badge.svg?token=eJu34XLlVu)](https://codecov.io/gh/OpenSourcePolitics/decidim-spam_detection)
3
- ![Tests](https://github.com/opensourcepolitics/decidim-spam_detection/actions/workflows/tests.yml/badge.svg)
4
- ![Tests](https://github.com/opensourcepolitics/decidim-spam_detection/actions/workflows/lint.yml/badge.svg)
3
+ ![Tests](https://github.com/opensourcepolitics/decidim-spam_detection/actions/workflows/ci_cd.yml/badge.svg)
4
+ [![Gem Version](https://badge.fury.io/rb/decidim-spam_detection.svg)](https://badge.fury.io/rb/decidim-spam_detection)
5
+
5
6
 
6
7
  ## Usage
7
8
 
@@ -3,6 +3,8 @@
3
3
  module Decidim
4
4
  module SpamDetection
5
5
  class SpamDetectionMailer < Decidim::ApplicationMailer
6
+ helper_method :blocked_users_url, :reported_users_url
7
+
6
8
  def notify_detection(user, results)
7
9
  with_user(user) do
8
10
  @reported_count = results[:reported_user]
@@ -14,6 +16,24 @@ module Decidim
14
16
  mail(to: @user.email, subject: subject)
15
17
  end
16
18
  end
19
+
20
+ private
21
+
22
+ def blocked_users_url
23
+ decidim_admin.moderated_users_url(blocked: true, host: root_url)
24
+ end
25
+
26
+ def reported_users_url
27
+ decidim_admin.moderated_users_url(blocked: false, host: root_url)
28
+ end
29
+
30
+ def decidim_admin
31
+ Decidim::Admin::Engine.routes.url_helpers
32
+ end
33
+
34
+ def root_url
35
+ decidim.root_url(host: @user.organization.host)[0..-2]
36
+ end
17
37
  end
18
38
  end
19
39
  end
@@ -5,10 +5,12 @@
5
5
  <p>
6
6
  <%= t(".reported_count", count: @reported_count) %>
7
7
  </p>
8
+ <p><%= link_to(t(".reported_link"), reported_users_url ) %></p>
8
9
  <% end %>
9
10
 
10
11
  <% if @blocked_count.present? %>
11
12
  <p>
12
13
  <%= t(".blocked_count", count: @blocked_count) %>
13
14
  </p>
15
+ <p><%= link_to(t(".blocked_link"), blocked_users_url ) %></p>
14
16
  <% end %>
@@ -5,6 +5,8 @@ locales: [en, fr, es, ca]
5
5
 
6
6
  ignore_unused:
7
7
  - "decidim.components.spam_detection.name"
8
+ - blocked_user.*
9
+ - reported_user.*
8
10
 
9
11
  ignore_missing:
10
12
  - decidim.participatory_processes.scopes.global
@@ -1,16 +1,26 @@
1
1
  ---
2
2
  ca:
3
+ blocked_user:
4
+ reason: La nostra tasca de detecció automàtica dspam li ha bloquejat. Si això
5
+ és un error. Poseu-vos en contacte amb els administradors de la plataforma que
6
+ poden restaurar el vostre compte.
3
7
  decidim:
4
8
  components:
5
9
  spam_detection:
6
- name: SpamDetection
10
+ name: DeteccioSpam
7
11
  spam_detection:
8
12
  spam_detection_mailer:
9
13
  notify_detection:
10
- blocked_count: blocked_count %{count}
11
- hello: Hello %{name}
12
- intro: Aquí teniu l'informe de la tasca de detecció de correu brossa
13
- reported_count: reported_count %{count}
14
+ blocked_count: Comptes de spam bloquejats %{count}
15
+ blocked_link: Consulteu la llista de tots els comptes bloquejats
16
+ hello: Hola %{name}
17
+ intro: Aquí teniu l’informe de la tasca de detecció de spam
18
+ reported_count: Comptes blocs de %{count}
19
+ reported_link: Consulteu la llista de tots els comptes reportats al lloc
14
20
  spam_detection_mailer:
15
21
  notify_detection:
16
- subject: Resum de detecció de correu brossa
22
+ subject: Informe de la tasca automàtica detecció de spam
23
+ reported_user:
24
+ details: L’usuari s’ha marcat com spam a causa d’una alta probabilitat de spam
25
+ per la tasca de detecció automàtica de spam de Decidim amb una probabilitat
26
+ de %{probability}%
@@ -1,5 +1,9 @@
1
1
  ---
2
2
  en:
3
+ blocked_user:
4
+ reason: Our automatic spam account detection task has blocked you. If this is
5
+ an error. Contact the platform administrators who will be able to restore your
6
+ account.
3
7
  decidim:
4
8
  components:
5
9
  spam_detection:
@@ -7,10 +11,15 @@ en:
7
11
  spam_detection:
8
12
  spam_detection_mailer:
9
13
  notify_detection:
10
- blocked_count: 'Blocked users count: %{count}'
14
+ blocked_count: 'Spam accounts blocked: %{count}'
15
+ blocked_link: See the list of all blocked accounts
11
16
  hello: Hello %{name}
12
- intro: Here is the report of the spam detection task
13
- reported_count: 'Reported users count: %{count}'
17
+ intro: Here is the report of the automated spam detection task.
18
+ reported_count: 'Spam accounts reported: %{count}'
19
+ reported_link: See the list of all reported accounts
14
20
  spam_detection_mailer:
15
21
  notify_detection:
16
- subject: Spam detection digest
22
+ subject: Automated spam detection task digest
23
+ reported_user:
24
+ details: The user was reported because of a high spam probability by the automated
25
+ spam detection task with a probability of %{probability}%
@@ -1,16 +1,25 @@
1
1
  ---
2
2
  es:
3
+ blocked_user:
4
+ reason: Nuestra tarea de detección automática de spam le ha bloqueado. Si esto
5
+ es un error. Póngase en contacto con los administradores de la plataforma que
6
+ pueden restaurar su cuenta.
3
7
  decidim:
4
8
  components:
5
9
  spam_detection:
6
- name: SpamDetection
10
+ name: DeteccionSpam
7
11
  spam_detection:
8
12
  spam_detection_mailer:
9
13
  notify_detection:
10
- blocked_count: blocked_count %{count}
11
- hello: Hello %{name}
12
- intro: Here is the report of the spam detection task
13
- reported_count: reported_count %{count}
14
+ blocked_count: 'Cuentas de spam bloqueadas : %{count}'
15
+ blocked_link: Ver la lista de todas las cuentas bloqueadas
16
+ hello: Hola %{name}
17
+ intro: Aquí está el informe de la tarea de detección automática de spam.
18
+ reported_count: Cuentas de spam señaladas %{count}
19
+ reported_link: Ver la lista de cuentas señaladas
14
20
  spam_detection_mailer:
15
21
  notify_detection:
16
- subject: Subject
22
+ subject: Informe de la tarea automática detección de spam
23
+ reported_user:
24
+ details: El usuario fue señalado debido a una alta probabilidad de spam por la
25
+ tarea de detección automática de spam con una probabilidad de %{probability}%
@@ -1,16 +1,25 @@
1
1
  ---
2
2
  fr:
3
+ blocked_user:
4
+ reason: Notre tâche de détection automatique des comptes spam vous a bloqué. S'il
5
+ s'agit d'une erreur. Prenez contact avec les administrateurs de la plateforme
6
+ qui pourront rétablir votre compte.
3
7
  decidim:
4
8
  components:
5
9
  spam_detection:
6
- name: SpamDetection
10
+ name: DetectionSpam
7
11
  spam_detection:
8
12
  spam_detection_mailer:
9
13
  notify_detection:
10
- blocked_count: blocked_count %{count}
11
- hello: Hello %{name}
12
- intro: Here is the report of the spam detection task
13
- reported_count: reported_count %{count}
14
+ blocked_count: 'Comptes spam bloqués : %{count}'
15
+ blocked_link: Voir la liste de tous les comptes bloqués du site
16
+ hello: Bonjour %{name}
17
+ intro: Voici le rapport de la tâche de détection automatisée des spams.
18
+ reported_count: 'Comptes spam signalés : %{count}'
19
+ reported_link: Voir la liste de tous les comptes signalés
14
20
  spam_detection_mailer:
15
21
  notify_detection:
16
- subject: Subject
22
+ subject: Rapport de la tâche de détection automatique de spam
23
+ reported_user:
24
+ details: L’utilisateur a été signalé en raison d’une forte probabilité de spam
25
+ par la tâche de détection automatique de spam avec une probabilité de %{probability}%
@@ -55,14 +55,19 @@ module Decidim
55
55
  @user.blocked = true
56
56
  @user.blocked_at = Time.current
57
57
  @user.blocking = @current_blocking
58
- @user.extended_data["user_name"] = @user.name
58
+ update_extended_data
59
59
  @user.name = "Blocked user"
60
60
  @user.save!
61
61
  end
62
62
  end
63
63
 
64
64
  def reason
65
- "The user was blocked because of a high spam probability by Decidim spam detection bot with a probability of #{@probability}%"
65
+ I18n.t("blocked_user.reason", probability: @probability)
66
+ end
67
+
68
+ def update_extended_data
69
+ @user.extended_data = {} if @user.extended_data.nil?
70
+ @user.extended_data["user_name"] = @user.name
66
71
  end
67
72
  end
68
73
  end
@@ -28,7 +28,7 @@ module Decidim
28
28
  end
29
29
 
30
30
  def details
31
- "The user was marked as spam by Decidim spam detection bot with a probability of #{@probability}%"
31
+ I18n.t("reported_user.details", probability: @probability)
32
32
  end
33
33
 
34
34
  def find_or_create_moderation!
@@ -5,11 +5,11 @@ module Decidim
5
5
  # This holds the decidim-spam_detection version.
6
6
  module SpamDetection
7
7
  def self.version
8
- "1.1.0"
8
+ "2.0.0"
9
9
  end
10
10
 
11
11
  def self.decidim_version
12
- "0.25"
12
+ "0.26"
13
13
  end
14
14
  end
15
15
  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: 1.1.0
4
+ version: 2.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: 2022-02-08 00:00:00.000000000 Z
11
+ date: 2022-05-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.25'
19
+ version: '0.26'
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.25'
26
+ version: '0.26'
27
27
  description: " SpamDetection is a detection bot made by OpenSourcePolitics. \n It
28
28
  works with a spam detection service (https://github.com/OpenSourcePolitics/spam_detection)
29
29
  \n which marks the user with a spam probability score, \n between 0.7 and 0.99