decidim-comments 0.32.1 → 0.32.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f914a0bb7eb14fa5d81946301f908d7abc9000e9a317a18b453a1197cce1bad
4
- data.tar.gz: 72b443375fdb95dda4c3448c336ab86b7257816fea68e43f353031ad14b543ff
3
+ metadata.gz: b40d0d4aa990d69cab616ffb20bad1edb97444b272c50eafde6e089138c84e24
4
+ data.tar.gz: 946410858a7a66fef57f4bd8b37d7c7e218f4aef0664720ce3287d13d6ef7cfc
5
5
  SHA512:
6
- metadata.gz: 3ec45128f4b7b40766a9570f9bb467064d054f4bfb3c78700ddee39254a3ce2502094ff507f3cb4f84d9f96e8298c925e7045256f496c26d695ba28f3095aca4
7
- data.tar.gz: 29598456e8f13f820dda933a279b97de18dbb6e3f3906194c0eb3dc0dfdbe0b7cea61fa453f43475dceaa073abe04fea53348282aa266c9499caa6cc4230b9d9
6
+ metadata.gz: 9382b8a728a8af2319248331a512cb34b38a040a5a32224f700df44bc53ce1daba67024d41582c6df73a218118d2ab5c268f177cb2364aa6c1be488f79f57db4
7
+ data.tar.gz: 9c658b3a40f3531db3aab30887639b6199e2a339202fa2e469f18199178101b7aeba1b523f4d23711cd0e923e7f0d0e7073781d115bd8f7dd38205d0a031cfc9
@@ -20,7 +20,11 @@
20
20
  required: true,
21
21
  placeholder: t("decidim.components.add_comment_form.form.body.placeholder"),
22
22
  label: false,
23
- data: { remaining_characters: "##{add_comment_id}-remaining-characters", controller: "emoji mention character-counter" }
23
+ data: {
24
+ remaining_characters: "##{add_comment_id}-remaining-characters",
25
+ controller: "emoji mention character-counter",
26
+ search_prompt: t("decidim.shared.mentions.search_prompt")
27
+ }
24
28
  ) %>
25
29
  </div>
26
30
  <span id="<%= add_comment_id %>-remaining-characters" class="remaining-character-count"></span>
@@ -19,7 +19,11 @@
19
19
  placeholder: t("decidim.components.edit_comment_modal_form.form.body.placeholder"),
20
20
  label: false,
21
21
  class: "w-full rounded border min-h-[160px] border-text-gray-2",
22
- data: { remaining_characters: "##{form_id}-remaining-characters", controller: "emoji mention character-counter" }
22
+ data: {
23
+ remaining_characters: "##{form_id}-remaining-characters",
24
+ controller: "emoji mention character-counter",
25
+ search_prompt: t("decidim.shared.mentions.search_prompt")
26
+ }
23
27
  ) %>
24
28
  </div>
25
29
  </div>
@@ -5,6 +5,8 @@ module Decidim
5
5
  # This controller is the abstract class from which all other controllers of
6
6
  # this engine inherit.
7
7
  class ApplicationController < Decidim::ApplicationController
8
+ protected
9
+
8
10
  def permission_class_chain
9
11
  [
10
12
  ::Decidim::Comments::Permissions,
@@ -13,7 +13,7 @@ module Decidim
13
13
  before_action :set_commentable, except: [:destroy, :update]
14
14
  before_action :ensure_commentable!, except: [:destroy, :update]
15
15
 
16
- helper_method :root_depth, :commentable, :order, :reply?, :reload?, :root_comment, :load_more?, :comments_offset, :alignment
16
+ helper_method :root_depth, :commentable, :order, :reply?, :reload?, :root_comment, :load_more?, :comments_offset, :alignment, :current_component
17
17
 
18
18
  def index
19
19
  enforce_permission_to(:read, :comment, commentable:)
@@ -136,7 +136,7 @@ export default class CommentsComponent {
136
136
  * @returns {String} - Returns a unique identifier
137
137
  */
138
138
  _getUID() {
139
- return `comments-${new Date().setUTCMilliseconds()}-${Math.floor(Math.random() * 10000000)}`;
139
+ return `comments-${new Date().getUTCMilliseconds()}-${Math.floor(Math.random() * 10000000)}`;
140
140
  }
141
141
 
142
142
  /**
@@ -403,6 +403,12 @@ describe("CommentsComponent", () => {
403
403
  expect(CommentsComponent).toBeDefined();
404
404
  });
405
405
 
406
+ it("generates an ID if not defined", () => {
407
+ const dummyElement = document.createElement("div");
408
+ const component = new CommentsComponent($(dummyElement), {});
409
+ expect(component.id).toMatch(/^comments-\d{1,3}-\d+$/);
410
+ });
411
+
406
412
  it("initializes unmounted", () => {
407
413
  expect(subject.mounted).toBeFalsy();
408
414
  });
@@ -1,5 +1,3 @@
1
- @use "stylesheets/decidim/editor_suggestions";
2
-
3
1
  .comments {
4
2
  &__container {
5
3
  @apply md:mt-12;
@@ -169,12 +169,12 @@ ca:
169
169
  email_intro: "%{author_name} ha deixat un comentari a %{resource_title}. Podeu llegir-lo en aquesta pàgina:"
170
170
  email_outro: Has rebut aquesta notificació perquè estàs seguint el comentari "%{author_name}". Pots deixar de seguir a aquesta participant des de la seva pàgina de perfil.
171
171
  email_subject: Hi ha un nou comentari de %{author_name} en %{resource_title}
172
- notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name}</a> a<a href="%{resource_path}">%{resource_title}</a>.
172
+ notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name}</a> a <a href="%{resource_path}">%{resource_title}</a>.
173
173
  comment_created:
174
174
  email_intro: "Algú ha deixat un comentari a \"%{resource_title}\". Pots llegir el comentari a través del següent enllaç:"
175
175
  email_outro: Has rebut aquesta notificació perquè estàs seguint el comentari "%{resource_title}" o la seva autora. Pots deixar de seguir-la des de l'enllaç anterior.
176
176
  email_subject: Hi ha un nou comentari de %{author_name} a %{resource_title}
177
- notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name}</a> a<a href="%{resource_path}">%{resource_title}</a>
177
+ notification_title: Hi ha un nou comentari de <a href="%{author_path}">%{author_name}</a> a <a href="%{resource_path}">%{resource_title}</a>
178
178
  comment_downvoted:
179
179
  email_intro: El teu comentari a "%{resource_title}" ha rebut un vot negatiu. Ara té un total de %{upvotes} vots positius i %{downvotes} vots negatius.
180
180
  email_outro: Has rebut aquesta notificació perquè vas fer aquest comentari.
@@ -194,7 +194,7 @@ ca:
194
194
  email_intro: Has estat esmentada
195
195
  email_outro: Has rebut aquesta notificació perquè t'han esmentat al comentari "%{resource_title}".
196
196
  email_subject: Has estat esmentada a %{resource_title}
197
- notification_title: Has estat esmentada per <a href="%{author_path}">%{author_name}</a> a <a href="%{resource_path}">%{resource_title}</a>
197
+ notification_title: T'han esmentat per <a href="%{author_path}">%{author_name}</a> a <a href="%{resource_path}">%{resource_title}</a>
198
198
  errors:
199
199
  messages:
200
200
  cannot_have_comments: no es poden fer comentaris
@@ -169,10 +169,12 @@ de:
169
169
  email_intro: "%{author_name} hat einen Kommentar zu %{resource_title} hinterlassen. Sie können diesen auf dieser Seite lesen:"
170
170
  email_outro: Sie haben diese Benachrichtigung erhalten, weil Sie %{author_name} folgen. Falls Sie keine solchen Benachrichtigungen mehr erhalten möchten, besuchen Sie die Profil-Seite dieses Benutzers.
171
171
  email_subject: Neuer Kommentar von %{author_name} zu %{resource_title}
172
+ notification_title: Es gibt einen neuen Kommentar von <a href="%{author_path}">%{author_name}</a> zu <a href="%{resource_path}">%{resource_title}</a>.
172
173
  comment_created:
173
174
  email_intro: "%{resource_title} wurde kommentiert. Sie können den Kommentar auf dieser Seite lesen:"
174
175
  email_outro: Sie haben diese Benachrichtigung erhalten, weil Sie "%{resource_title}" oder seinem Autor folgen. Falls Sie keine solchen Benachrichtigungen mehr erhalten möchten, besuchen Sie den obigen Link.
175
176
  email_subject: Neuer Kommentar von %{author_name} zu %{resource_title}
177
+ notification_title: Es gibt einen neuen Kommentar von <a href="%{author_path}">%{author_name}</a> zu <a href="%{resource_path}">%{resource_title}</a>
176
178
  comment_downvoted:
177
179
  email_intro: Ihr Kommentar in "%{resource_title}" wurde negativ bewertet. Er hat nun insgesamt %{upvotes} positive und %{downvotes} negative Stimmen.
178
180
  email_outro: Sie haben diese Benachrichtigung erhalten, weil Sie der Autor des Vorschlags sind.
@@ -187,10 +189,12 @@ de:
187
189
  email_intro: "%{author_name} hat auf Ihren Kommentar zu %{resource_title} geantwortet. Sie können das auf dieser Seite lesen:"
188
190
  email_outro: Sie haben diese Benachrichtigung erhalten, weil Ihr Kommentar beantwortet wurde.
189
191
  email_subject: "%{author_name} hat auf Ihren Kommentar zu %{resource_title} geantwortet"
192
+ notification_title: <a href="%{author_path}">%{author_name}</a> hat auf Ihren Kommentar zu <a href="%{resource_path}">%{resource_title}</a> geantwortet
190
193
  user_mentioned:
191
194
  email_intro: Sie wurden erwähnt
192
195
  email_outro: Sie haben diese Benachrichtigung erhalten, weil Sie in %{resource_title} erwähnt wurden.
193
196
  email_subject: Sie wurden in %{resource_title} erwähnt
197
+ notification_title: Sie wurden von <a href="%{author_path}">%{author_name}</a> in <a href="%{resource_path}">%{resource_title}</a> erwähnt
194
198
  errors:
195
199
  messages:
196
200
  cannot_have_comments: kann keine Kommentare haben
@@ -146,6 +146,7 @@ fr:
146
146
  comment_votes:
147
147
  id: L'id du vote
148
148
  comments:
149
+ author: Le nom du participant qui a laissé ce commentaire
149
150
  body: Le commentaire lui-même
150
151
  commentable_id: L'identifiant unique de l"élément commenté
151
152
  commentable_type: Le type de l'élément commenté (si c'était un résultat, une proposition, etc.)
@@ -4,6 +4,7 @@ gl:
4
4
  models:
5
5
  decidim/comments/comment_by_followed_user_event: Comentario
6
6
  decidim/comments/comment_created_event: Comentario
7
+ decidim/comments/comment_upvoted_event: Comentario valorado positivamente
7
8
  decidim/comments/reply_created_event: Comentario de resposta
8
9
  decidim/comments/user_mentioned_event: Mención
9
10
  activerecord:
@@ -13,7 +14,7 @@ gl:
13
14
  other: Comentarios
14
15
  decidim/comments/comment_vote:
15
16
  one: Vota
16
- other: Votos
17
+ other: Apoios
17
18
  decidim:
18
19
  admin:
19
20
  admin_log:
@@ -26,20 +27,32 @@ gl:
26
27
  enabled: Comentarios habilitados
27
28
  end_time: Comentarios habilitados até
28
29
  start_time: Comentarios habilitados dende
30
+ comment_thread:
31
+ accessibility_label: Fío de comentarios iniciado por %{full_name} o %{date}
29
32
  comments:
30
33
  create:
31
34
  error: Produciuse un problema ao crear o comentario.
35
+ delete:
36
+ error: Non se puido eliminar o comentario.
32
37
  update:
33
38
  error: Produciuse un problema ao actualizar o comentario.
39
+ comments_title: Comentar
40
+ last_activity:
41
+ new_comment: 'Novo comentario:'
34
42
  votes:
35
43
  create:
36
- error: Houbo erros ao votar o comentario.
44
+ error: Houbo erros ao apoiar o comentario.
37
45
  components:
38
46
  add_comment_form:
47
+ account_message: Inicia sesión ou crea unha conta para engadir o teu comentario.
48
+ add_comment: Engadir comentario
39
49
  form:
40
50
  body:
41
51
  label: Comentario
42
52
  placeholder: Que vos parece?
53
+ form_error: O texto é obrigatorio e non pode superar os %{length} caracteres.
54
+ submit_reply: Publicar resposta
55
+ submit_root_comment: Publicar comentario
43
56
  opinion:
44
57
  label: A túa opinión canto a este tema
45
58
  negative: Negativa
@@ -55,13 +68,24 @@ gl:
55
68
  alignment:
56
69
  against: Contra
57
70
  in_favor: A favor
71
+ cancel_reply: Cancelar resposta
72
+ comment_label: Comentario %{comment_id}
73
+ comment_label_reply: Comentario %{comment_id} (resposta ao comentario %{parent_comment_id})
58
74
  confirm_destroy: Estás certo/a de querer eliminar este comentario?
75
+ controls_label: Controis do comentario
59
76
  delete: Eliminar
60
77
  deleted_at: Comentario eliminado o %{date}
61
78
  deleted_user: Usuario eliminado
62
79
  edit: Editar
63
80
  edited: Editado
81
+ hide_replies:
82
+ one: Ocultar resposta
83
+ other: Ocultar %{count} respostas
84
+ load_replies: Cargar respostas
64
85
  moderated_at: Comentario moderado o %{date}
86
+ replies_count:
87
+ one: "%{count} resposta"
88
+ other: "%{count} respostas"
65
89
  reply: Responder
66
90
  report:
67
91
  action: Informe
@@ -70,10 +94,15 @@ gl:
70
94
  description: Este contido é inapropiado?
71
95
  details: Comentarios adicionais
72
96
  reasons:
97
+ does_not_belong: Contén actividade ilegal, ameazas de suicidio, información persoal ou outro contido que consideras que non debería estar en %{organization_name}.
73
98
  offensive: Contén racismo, sexismo, abuso, ataques persoais, ameazas de morte, solicitudes de suicidio ou calquera tipo de discurso de odio.
74
99
  spam: Contén clic, publicidade, fraudes ou bots de script.
75
100
  title: Denunciar contido inapropiado
101
+ show_replies:
102
+ one: Mostrar resposta
103
+ other: Mostrar %{count} respostas
76
104
  single_comment_link_title: Obter ligazón
105
+ sort_by: 'Ordenar por: '
77
106
  comment_order_selector:
78
107
  order:
79
108
  best_rated: Mellor valorado
@@ -82,16 +111,25 @@ gl:
82
111
  recent: Recentes
83
112
  title: 'Ordenar por:'
84
113
  comments:
114
+ against: En contra
85
115
  blocked_comments_for_unauthorized_user_warning: Tes de estar verificado para poder comentar neste intre, porén podes ler os comentarios anteriores.
86
116
  blocked_comments_for_user_warning: Non podes comentar neste momento, pero podes ler os anteriores.
117
+ blocked_comments_warning: Os comentarios están desactivados neste momento; só as persoas administradoras poden responder ou publicar novos comentarios.
87
118
  comment_details_title: Detalles do comentario
119
+ in_favor: A favor
120
+ load_more_comments: Cargar máis comentarios
88
121
  loading: Cargando comentarios ...
122
+ no_comments_yet: Aínda non hai comentarios
89
123
  single_comment_warning: <a href="%{url}">Ver todos os comentarios</a>
90
124
  single_comment_warning_title: Estás a ver un único comentario
91
125
  title:
92
126
  one: "%{count} comentario"
93
127
  other: "%{count} comentarios"
128
+ top_comment_label: Mellor valorado
94
129
  down_vote_button:
130
+ label:
131
+ one: Botón «Non me gusta». %{count} valoración negativa
132
+ other: Botón «Non me gusta». %{count} valoracións negativas
95
133
  text: Non estou de acordo con este comentario
96
134
  edit_comment_modal_form:
97
135
  close: Pechar
@@ -102,22 +140,61 @@ gl:
102
140
  submit: Enviar
103
141
  title: Editar o teu comentario
104
142
  up_vote_button:
143
+ label:
144
+ one: Botón «Gústame». %{count} valoración positiva
145
+ other: Botón «Gústame». %{count} valoracións positivas
105
146
  text: Estou de acordo con este comentario
147
+ download_your_data:
148
+ help:
149
+ comment_votes:
150
+ comment: O identificador do comentario que se valorou
151
+ created_at: A data na que se creou esta valoración
152
+ id: O identificador da valoración
153
+ updated_at: A data da última actualización desta valoración
154
+ weight: O peso da valoración (1 para positiva e -1 para negativa)
155
+ comments:
156
+ alignment: Se este comentario foi a favor, en contra ou neutral
157
+ author: O nome da persoa participante que fixo este comentario
158
+ body: O propio comentario
159
+ commentable_id: O identificador único do recurso comentable
160
+ commentable_type: O tipo de recurso comentable (se era un resultado, unha proposta etc.)
161
+ created_at: A data na que se creou este comentario
162
+ depth: A posición deste comentario na árbore de comentarios (se é unha resposta ou unha resposta a outra resposta)
163
+ id: O identificador deste comentario
164
+ locale: A configuración rexional (idioma) da persoa participante cando deixou este comentario
165
+ root_commentable_url: O URL do recurso ao que está vinculado este comentario
106
166
  events:
107
167
  comments:
108
168
  comment_by_followed_user:
109
169
  email_intro: "%{author_name} deixou un comentario en %{resource_title}. Podes lelo nesta páxina:"
110
- email_outro: Recibiches esta notificación porque estás seguindo %{author_name}. Podes deixar de seguir este usuario desde a súa páxina de perfil.
170
+ email_outro: Recibiches esta notificación porque estás seguindo %{author_name}. Podes deixar de seguir este participante desde a súa páxina de perfil.
111
171
  email_subject: Hai un novo comentario por %{author_name} en %{resource_title}
172
+ notification_title: Hai un novo comentario de <a href="%{author_path}">%{author_name}</a> en <a href="%{resource_path}">%{resource_title}</a>.
112
173
  comment_created:
113
174
  email_intro: "Comentouse %{resource_title} . Podes ler o comentario nesta páxina:"
114
175
  email_outro: Recibiches esta notificación porque estás seguindo "%{resource_title}" ou o seu autor. Podes deixar de seguir desde a ligazón anterior.
115
176
  email_subject: Hai un novo comentario de %{author_name} en %{resource_title}
177
+ notification_title: Hai un novo comentario de <a href="%{author_path}">%{author_name}</a> en <a href="%{resource_path}">%{resource_title}</a>
178
+ comment_downvoted:
179
+ email_intro: O teu comentario en «%{resource_title}» recibiu unha valoración negativa. Agora ten un total de %{upvotes} valoracións positivas e %{downvotes} negativas.
180
+ email_outro: Recibiches esta notificación porque es a persoa autora deste comentario.
181
+ email_subject: O teu comentario en «%{resource_title}» recibiu unha valoración negativa.
182
+ notification_title: O teu <a href="%{resource_path}">comentario</a> en «%{resource_title}» recibiu unha valoración negativa. Agora ten un total de %{upvotes} valoracións positivas e %{downvotes} negativas.
183
+ comment_upvoted:
184
+ email_intro: O teu comentario en «%{resource_title}» recibiu unha valoración positiva. Agora ten un total de %{upvotes} valoracións positivas e %{downvotes} negativas.
185
+ email_outro: Recibiches esta notificación porque es a persoa autora deste comentario.
186
+ email_subject: O teu comentario en «%{resource_title}» recibiu unha valoración positiva.
187
+ notification_title: O teu <a href="%{resource_path}">comentario</a> en «%{resource_title}» recibiu unha valoración positiva. Agora ten un total de %{upvotes} valoracións positivas e %{downvotes} negativas.
116
188
  reply_created:
117
189
  email_intro: "%{author_name} respondeu o teu comentario en %{resource_title}. Podes lelo nesta páxina:"
118
190
  email_outro: Recibiches esta notificación porque o teu comentario foi respondido.
119
191
  email_subject: "%{author_name} respondeu o teu comentario en %{resource_title}"
192
+ notification_title: <a href="%{author_path}">%{author_name}</a> respondeu ao teu comentario en <a href="%{resource_path}">%{resource_title}</a>
120
193
  user_mentioned:
121
194
  email_intro: Foi mencionado
122
195
  email_outro: Recibiches esta notificación porque foi mencionado en %{resource_title}.
123
196
  email_subject: Foi mencionado en %{resource_title}
197
+ notification_title: <a href="%{author_path}">%{author_name}</a> mencionoute en <a href="%{resource_path}">%{resource_title}</a>
198
+ errors:
199
+ messages:
200
+ cannot_have_comments: non pode ter comentarios
@@ -81,7 +81,11 @@ sv:
81
81
  hide_replies:
82
82
  one: Dölj svar
83
83
  other: Dölj %{count} svar
84
+ load_replies: Ladda svar
84
85
  moderated_at: Kommentar modererad %{date}
86
+ replies_count:
87
+ one: "%{count} svar"
88
+ other: "%{count} svar"
85
89
  reply: Svara
86
90
  report:
87
91
  action: Rapportera
@@ -113,7 +117,9 @@ sv:
113
117
  blocked_comments_warning: Kommentarer är inaktiverade, endast administratörer kan svara eller skriva nya.
114
118
  comment_details_title: Kommentarsdetaljer
115
119
  in_favor: För
120
+ load_more_comments: Läs in fler kommentarer
116
121
  loading: Laddar kommentarer...
122
+ no_comments_yet: Inga kommentarer ännu
117
123
  single_comment_warning: <a href="%{url}">Visa alla kommentarer</a>
118
124
  single_comment_warning_title: Du visar en enda kommentar
119
125
  title:
@@ -163,12 +169,12 @@ sv:
163
169
  email_intro: "%{author_name} har lämnat en kommentar i %{resource_title}. Du kan läsa den på den här sidan:"
164
170
  email_outro: Du har fått den här notisen eftersom du följer %{author_name}. Du kan avfölja den här användaren från deras profilsida.
165
171
  email_subject: Det finns en ny kommentar av %{author_name} i %{resource_title}
166
- notification_title: Det finns en ny kommentar av <a href="%{author_path}">%{author_name}</a> i <a href="%{resource_path}">%{resource_title}</a>.
172
+ notification_title: Ny kommentar av <a href="%{author_path}">%{author_name}</a> i <a href="%{resource_path}">%{resource_title}</a>.
167
173
  comment_created:
168
174
  email_intro: "%{resource_title} har kommenterats. Du kan läsa kommentaren på den här sidan:"
169
175
  email_outro: Du har fått det här meddelandet eftersom du följer "%{resource_title}" eller dess författare. Du kan avfölja det från föregående länk.
170
176
  email_subject: Det finns en ny kommentar från %{author_name} i %{resource_title}
171
- notification_title: Det finns en ny kommentar från <a href="%{author_path}">%{author_name}</a> i <a href="%{resource_path}">%{resource_title}</a>
177
+ notification_title: Ny kommentar från <a href="%{author_path}">%{author_name}</a> i <a href="%{resource_path}">%{resource_title}</a>
172
178
  comment_downvoted:
173
179
  email_intro: Din kommentar i "%{resource_title}" har blivit nedröstad. Den har nu totalt %{upvotes} uppröster och %{downvotes} nedröster.
174
180
  email_outro: Du har fått det här meddelandet eftersom du är författare till denna kommentar.
@@ -183,7 +189,7 @@ sv:
183
189
  email_intro: "%{author_name} har svarat din kommentar i %{resource_title}. Du kan läsa den på den här sidan:"
184
190
  email_outro: Du har fått denna notis eftersom din kommentar blev besvarad.
185
191
  email_subject: "%{author_name} har svarat din kommentar i %{resource_title}"
186
- notification_title: <a href="%{author_path}">%{author_name}</a> besvarade din kommentar i <a href="%{resource_path}">%{resource_title}</a>
192
+ notification_title: <a href="%{author_path}">%{author_name}</a> har svarat på din kommentar i <a href="%{resource_path}">%{resource_title}</a>
187
193
  user_mentioned:
188
194
  email_intro: Du har nämnts
189
195
  email_outro: Du har fått denna notis eftersom du har nämnts i %{resource_title}.
@@ -3,7 +3,7 @@
3
3
  $LOAD_PATH.push File.expand_path("lib", __dir__)
4
4
 
5
5
  Gem::Specification.new do |s|
6
- version = "0.32.1"
6
+ version = "0.32.2"
7
7
  s.version = version
8
8
  s.authors = ["Josep Jaume Rey Peroy", "Marc Riera Casals", "Oriol Gual Oliva"]
9
9
  s.email = ["josepjaume@gmail.com", "mrc2407@gmail.com", "oriolgual@gmail.com"]
@@ -30,6 +30,8 @@ module Decidim
30
30
  end
31
31
 
32
32
  def commentable(id:, type:, locale: Decidim.default_locale, toggle_translations: false)
33
+ raise GraphQL::ExecutionError, "Invalid commentable type" unless valid_commentable_type?(type)
34
+
33
35
  I18n.locale = locale.presence
34
36
  RequestStore.store[:toggle_machine_translations] = toggle_translations
35
37
  type.constantize.find(id)
@@ -40,6 +42,16 @@ module Decidim
40
42
  RequestStore.store[:toggle_machine_translations] = toggle_translations
41
43
  Comment.find(id)
42
44
  end
45
+
46
+ private
47
+
48
+ def valid_commentable_type?(type)
49
+ klass = type.safe_constantize
50
+ return false unless klass
51
+ return false unless klass.is_a?(Class)
52
+
53
+ klass.include?(Decidim::Comments::Commentable)
54
+ end
43
55
  end
44
56
  end
45
57
  end
@@ -21,6 +21,7 @@ module Decidim
21
21
 
22
22
  def commentable(id:, locale:, toggle_translations:, type:)
23
23
  raise GraphQL::ExecutionError, "#{locale} is not a valid locale" unless available_locales.include?(locale)
24
+ raise GraphQL::ExecutionError, "Invalid commentable type" unless valid_commentable_type?(type)
24
25
 
25
26
  I18n.locale = locale.presence
26
27
  RequestStore.store[:toggle_machine_translations] = toggle_translations
@@ -29,6 +30,14 @@ module Decidim
29
30
 
30
31
  private
31
32
 
33
+ def valid_commentable_type?(type)
34
+ klass = type.safe_constantize
35
+ return false unless klass
36
+ return false unless klass.is_a?(Class)
37
+
38
+ klass.include?(Decidim::Comments::Commentable)
39
+ end
40
+
32
41
  def available_locales
33
42
  if context[:current_organization].present?
34
43
  context[:current_organization].available_locales
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-comments version.
5
5
  module Comments
6
6
  def self.version
7
- "0.32.1"
7
+ "0.32.2"
8
8
  end
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-comments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.32.1
4
+ version: 0.32.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.32.1
20
+ version: 0.32.2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.32.1
27
+ version: 0.32.2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: redcarpet
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -51,28 +51,28 @@ dependencies:
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.32.1
54
+ version: 0.32.2
55
55
  type: :development
56
56
  prerelease: false
57
57
  version_requirements: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.32.1
61
+ version: 0.32.2
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: decidim-dev
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.32.1
68
+ version: 0.32.2
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.32.1
75
+ version: 0.32.2
76
76
  description: Pluggable comments system for some components.
77
77
  email:
78
78
  - josepjaume@gmail.com