-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feature/mails admin revamp (#26) * Update CI * Don't use decidim commands * Add organizations to results * Send a digest to admins by mail * Fix offenses * Use bundle exec * Remove duplicate precompile * Run in assets precompile in ci * Fix failing tests * Normalize locales * Update translations * Revert "Update translations" This reverts commit 1704e0d. * Don't fail on invalid user * Use status instead of results * Send mail in a delegated job * Fix offenses * Add conditionnal in mailer * Display probability in details and reason Co-authored-by: paulinebessoles <[email protected]> * Bump version (#28) Co-authored-by: paulinebessoles <[email protected]>
- Loading branch information
1 parent
684e1d4
commit e9a6ee3
Showing
23 changed files
with
428 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,8 +60,9 @@ jobs: | |
- uses: nanasess/[email protected] | ||
- name: Run precompile if needed | ||
run: | | ||
if [[ -d ./spec/system && -n "$(ls -A ./spec/system)" ]]; then | ||
rails assets:precompile | ||
if [[ -d "app/views" ]] || [[ -d "spec/mailers" ]] || [[ -d "spec/system" ]]; then | ||
cd "spec/decidim_dummy_app" | ||
bundle exec rails assets:precompile | ||
else | ||
echo "No need to precompile assets since system folder is empty" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
PATH | ||
remote: . | ||
specs: | ||
decidim-spam_detection (1.0.0) | ||
decidim-spam_detection (1.1.0) | ||
decidim-core (~> 0.25) | ||
|
||
GEM | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module SpamDetection | ||
class NotifyAdmins < ApplicationJob | ||
queue_as :default | ||
|
||
def perform(results_hash) | ||
results_hash.each do |id, result| | ||
next if result.keys == [:nothing] | ||
|
||
Decidim::Organization.find(id).admins.each do |admin| | ||
Decidim::SpamDetection::SpamDetectionMailer.notify_detection(admin, result).deliver_later | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
19 changes: 19 additions & 0 deletions
19
app/mailers/decidim/spam_detection/spam_detection_mailer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
module SpamDetection | ||
class SpamDetectionMailer < Decidim::ApplicationMailer | ||
def notify_detection(user, results) | ||
with_user(user) do | ||
@reported_count = results[:reported_user] | ||
@blocked_count = results[:blocked_user] | ||
@organization = user.organization | ||
@user = user | ||
|
||
subject = I18n.t("notify_detection.subject", scope: "decidim.spam_detection_mailer") | ||
mail(to: @user.email, subject: subject) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/views/decidim/spam_detection/spam_detection_mailer/notify_detection.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<p class="email-greeting"><%= t(".hello", name: @user.name) %></p> | ||
<p><%= t(".intro") %></p> | ||
|
||
<% if @reported_count.present? %> | ||
<p> | ||
<%= t(".reported_count", count: @reported_count) %> | ||
</p> | ||
<% end %> | ||
|
||
<% if @blocked_count.present? %> | ||
<p> | ||
<%= t(".blocked_count", count: @blocked_count) %> | ||
</p> | ||
<% end %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
ca: | ||
decidim: | ||
components: | ||
spam_detection: | ||
name: SpamDetection | ||
spam_detection: | ||
spam_detection_mailer: | ||
notify_detection: | ||
blocked_count: blocked_count %{count} | ||
hello: Hello %{name} | ||
intro: Aquí teniu l'informe de la tasca de detecció de correu brossa | ||
reported_count: reported_count %{count} | ||
spam_detection_mailer: | ||
notify_detection: | ||
subject: Resum de detecció de correu brossa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
es: | ||
decidim: | ||
components: | ||
spam_detection: | ||
name: SpamDetection | ||
spam_detection: | ||
spam_detection_mailer: | ||
notify_detection: | ||
blocked_count: blocked_count %{count} | ||
hello: Hello %{name} | ||
intro: Here is the report of the spam detection task | ||
reported_count: reported_count %{count} | ||
spam_detection_mailer: | ||
notify_detection: | ||
subject: Subject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
fr: | ||
decidim: | ||
components: | ||
spam_detection: | ||
name: SpamDetection | ||
spam_detection: | ||
spam_detection_mailer: | ||
notify_detection: | ||
blocked_count: blocked_count %{count} | ||
hello: Hello %{name} | ||
intro: Here is the report of the spam detection task | ||
reported_count: reported_count %{count} | ||
spam_detection_mailer: | ||
notify_detection: | ||
subject: Subject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.