decidim-cdtb 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/lib/decidim/cdtb/users/remover.rb +17 -19
- data/lib/decidim/cdtb/version.rb +1 -1
- data/lib/tasks/users.rake +2 -2
- 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: 7ea237b7898bc194b0f63514d1f699d5cd1cf649ac7dd7433de19d9319541474
|
4
|
+
data.tar.gz: be9a6f3251d35022b933524b3227edac2186a1c338a4025f6d73eb5495633e61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3999c77a44817f3c0b3bc6b97663a47f3dade93f896958cdce06298bd9695d734cdd82859315607ecc3fcd990efd6e567e2e63d6e0141f5c3d256bc44d6b91ef
|
7
|
+
data.tar.gz: 513123ffe284a654f47666d8a0e355b29cb3dd011a30bab73cdef0348776f45cd44dab8c8c9f23f5e962fb5f00a5dc9acb9d68a70ced7b39335cfc225ce56839
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -105,7 +105,7 @@ bin/rake cdtb:users:fix_nicknames
|
|
105
105
|
|
106
106
|
#### Remove users
|
107
107
|
|
108
|
-
You can delete users through a CSV with the user ID. The purpose is to be able to eliminate potentially spammy users.
|
108
|
+
You can delete users through a CSV with the user ID and a reporter user mailer. The purpose is to be able to eliminate potentially spammy users.
|
109
109
|
|
110
110
|
This task reports and hide the user's comments, blocks the user, and finally deletes the user.
|
111
111
|
|
@@ -114,7 +114,7 @@ The CSV will have a header and one column with the user ID.
|
|
114
114
|
To execute the task run:
|
115
115
|
|
116
116
|
```
|
117
|
-
bundle exec rake cdtb:users:remove[spam_users.csv]
|
117
|
+
bundle exec rake cdtb:users:remove[spam_users.csv, reporter_user@example.org]
|
118
118
|
```
|
119
119
|
|
120
120
|
### Upgrades:
|
@@ -6,8 +6,9 @@ module Decidim
|
|
6
6
|
# Remove Decidim::User's
|
7
7
|
#
|
8
8
|
class Remover < ::Decidim::Cdtb::Task
|
9
|
-
def initialize(csv_path)
|
9
|
+
def initialize(csv_path, reporter_user_email)
|
10
10
|
@csv_path = csv_path
|
11
|
+
@reporter_user_email = reporter_user_email
|
11
12
|
progress_bar = { title: "Decidim::User" }
|
12
13
|
super("USER REMOVER", progress_bar: progress_bar)
|
13
14
|
end
|
@@ -25,10 +26,10 @@ module Decidim
|
|
25
26
|
user = Decidim::User.find_by(id: row[0])
|
26
27
|
next unless user.present?
|
27
28
|
|
28
|
-
reporter_user = Decidim::User.find_by(email:
|
29
|
+
reporter_user = Decidim::User.find_by(email: @reporter_user_email,
|
29
30
|
organization: user.organization)
|
30
31
|
comments = Decidim::Comments::Comment.where(decidim_author_id: user.id)
|
31
|
-
manage_comments(comments, reporter_user) unless comments.empty?
|
32
|
+
manage_comments(comments, user, reporter_user) unless comments.empty?
|
32
33
|
destroy_user(user) if block_user(user, reporter_user)
|
33
34
|
progress_bar.increment
|
34
35
|
end
|
@@ -40,10 +41,9 @@ module Decidim
|
|
40
41
|
|
41
42
|
private
|
42
43
|
|
43
|
-
def manage_comments(comments, reporter_user)
|
44
|
+
def manage_comments(comments, user, reporter_user)
|
44
45
|
comments.find_each do |comment|
|
45
|
-
report_comment(comment, reporter_user)
|
46
|
-
hide_comment(comment, reporter_user)
|
46
|
+
report_comment(comment, user, reporter_user)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
@@ -91,15 +91,16 @@ module Decidim
|
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
def report_comment(comment, reporter_user)
|
94
|
+
def report_comment(comment, user, reporter_user)
|
95
95
|
params = {
|
96
96
|
reason: "spam",
|
97
97
|
details: "Spam message"
|
98
98
|
}
|
99
99
|
|
100
|
-
form = Decidim::ReportForm.from_params(params)
|
100
|
+
form = Decidim::ReportForm.from_params(params).with_context(context_for_report(user, comment, reporter_user))
|
101
|
+
reportable = GlobalID::Locator.locate_signed(comment.to_sgid.to_s)
|
101
102
|
|
102
|
-
CreateReport.call(form,
|
103
|
+
Decidim::CreateReport.call(form, reportable, reporter_user) do
|
103
104
|
on(:ok) do
|
104
105
|
puts "OK: Comment #{comment.id} of User #{user.id} reported"
|
105
106
|
end
|
@@ -110,16 +111,13 @@ module Decidim
|
|
110
111
|
end
|
111
112
|
end
|
112
113
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
puts "ERROR: Comment #{comment.id} of User #{user.id} not hided"
|
121
|
-
end
|
122
|
-
end
|
114
|
+
def context_for_report(user, comment, reporter_user)
|
115
|
+
{
|
116
|
+
current_organization: user.organization,
|
117
|
+
current_component: comment.component,
|
118
|
+
current_user: reporter_user,
|
119
|
+
current_participatory_space: comment.participatory_space
|
120
|
+
}
|
123
121
|
end
|
124
122
|
end
|
125
123
|
end
|
data/lib/decidim/cdtb/version.rb
CHANGED
data/lib/tasks/users.rake
CHANGED
@@ -15,8 +15,8 @@ namespace :cdtb do
|
|
15
15
|
desc <<~EODESC
|
16
16
|
Remove Decidim::User's by IDs in a CSV.
|
17
17
|
EODESC
|
18
|
-
task :remove, %i[
|
19
|
-
service = ::Decidim::Cdtb::Users::Remover.new(args.
|
18
|
+
task :remove, %i[csv_path reporter_user_email] => [:environment] do |_taks, args|
|
19
|
+
service = ::Decidim::Cdtb::Users::Remover.new(args.csv_path, args.reporter_user_email)
|
20
20
|
service.execute!
|
21
21
|
end
|
22
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: decidim-cdtb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Valls
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: decidim
|