decidim-api 0.31.7 → 0.31.8
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/config/locales/cs.yml +1 -0
- data/config/locales/de.yml +7 -0
- data/config/locales/gl.yml +7 -0
- data/lib/decidim/api/graphql_permissions.rb +30 -18
- data/lib/decidim/api/test/shared_examples/commentable_interface_examples.rb +46 -0
- data/lib/decidim/api/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 000be390e45024f2d1ece4e95cfd630e24a23c9c3fb5358e05238767aa89ca5d
|
|
4
|
+
data.tar.gz: 36a051e7271e07c8ea618d44e6e0f73c98184e7a275d0b3889d3045fcf3cc4ed
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4ebe3978797e8f12fd6e89767d408f52c9b086110a70ceb34c61c6472e0acfbb65e12f6496a4fe188236e59041863340f67c7c74af6ebd4a84a520eba3c68afb
|
|
7
|
+
data.tar.gz: c7851eccab45b3541e31e63058739cd601e36686fe7e7d4bcc82adf11ac6477e4308a73c667c6150bf17b6e20efafb3ea573e6caa74addfd0a2833800e9a89b3
|
data/config/locales/cs.yml
CHANGED
|
@@ -3,5 +3,6 @@ cs:
|
|
|
3
3
|
decidim:
|
|
4
4
|
api:
|
|
5
5
|
errors:
|
|
6
|
+
introspection_disabled: Introspekce je pro tento požadavek zakázána
|
|
6
7
|
recursion_limit_exceeded_error: V dotazu bylo zjištěno příliš mnoho rekurzí
|
|
7
8
|
too_many_aliases_error: Příliš mnoho aliasů. Použili jste aliasy %{size}, ale %{limit} jsou povoleny.
|
data/config/locales/de.yml
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
+
---
|
|
1
2
|
de:
|
|
3
|
+
decidim:
|
|
4
|
+
api:
|
|
5
|
+
errors:
|
|
6
|
+
introspection_disabled: Introspection ist für diese Anfrage deaktiviert
|
|
7
|
+
recursion_limit_exceeded_error: In der Abfrage wurden zu viele Rekursionen festgestellt
|
|
8
|
+
too_many_aliases_error: Es wurden zu viele Aliase verwendet. Sie haben %{size} Aliase verwendet, erlaubt sind jedoch nur %{limit}.
|
data/config/locales/gl.yml
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
+
---
|
|
1
2
|
gl:
|
|
3
|
+
decidim:
|
|
4
|
+
api:
|
|
5
|
+
errors:
|
|
6
|
+
introspection_disabled: A introspección está desactivada para esta solicitude
|
|
7
|
+
recursion_limit_exceeded_error: Detectáronse demasiadas recursións na consulta
|
|
8
|
+
too_many_aliases_error: Usáronse demasiados alias. Usaches %{size}, pero só se permiten %{limit}.
|
|
@@ -17,8 +17,8 @@ module Decidim
|
|
|
17
17
|
subject = determine_subject_name(object)
|
|
18
18
|
context[subject] = object
|
|
19
19
|
|
|
20
|
-
chain.unshift(allowed_to?(:read, :participatory_space, object, context)) if object.respond_to?(:participatory_space)
|
|
21
|
-
chain.unshift(allowed_to?(:read, :component, object, context)) if object.respond_to?(:component) && object.component.present?
|
|
20
|
+
chain.unshift(allowed_to?(:read, :participatory_space, object.participatory_space, context)) if object.respond_to?(:participatory_space)
|
|
21
|
+
chain.unshift(allowed_to?(:read, :component, object.component, context)) if object.respond_to?(:component) && object.component.present?
|
|
22
22
|
|
|
23
23
|
super && chain.all?
|
|
24
24
|
end
|
|
@@ -43,12 +43,7 @@ module Decidim
|
|
|
43
43
|
permission_action = Decidim::PermissionAction.new(scope:, action:, subject:)
|
|
44
44
|
|
|
45
45
|
permission_chain(object).inject(permission_action) do |current_permission_action, permission_class|
|
|
46
|
-
permission_context =
|
|
47
|
-
if scope == :admin
|
|
48
|
-
local_admin_context(object, context)
|
|
49
|
-
else
|
|
50
|
-
local_context(object, context)
|
|
51
|
-
end
|
|
46
|
+
permission_context = local_user_context(object, context)
|
|
52
47
|
|
|
53
48
|
permission_class.new(
|
|
54
49
|
context[:current_user],
|
|
@@ -58,25 +53,40 @@ module Decidim
|
|
|
58
53
|
end.allowed?
|
|
59
54
|
end
|
|
60
55
|
|
|
61
|
-
# Injects into context
|
|
56
|
+
# Injects into the context the current_participatory_space and current_component keys
|
|
57
|
+
# for the object being checked, as they are needed by the permission classes.
|
|
62
58
|
#
|
|
63
59
|
# @param object [ActiveModel::Base] The object that is being represented.
|
|
64
60
|
# @param context [GraphQL::Query::Context] The GraphQL context
|
|
65
61
|
#
|
|
66
62
|
# @return Hash
|
|
67
63
|
def local_context(object, context)
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
participatory_space = participatory_space_for(object)
|
|
65
|
+
component = component_for(object)
|
|
66
|
+
|
|
67
|
+
# Always use the associations of the object being checked. The context
|
|
68
|
+
# is shared by every field in the query, so keeping a previous object's
|
|
69
|
+
# space could authorize resources from a different space.
|
|
70
|
+
context[:current_participatory_space] = participatory_space if participatory_space
|
|
71
|
+
context[:current_component] = component if component
|
|
75
72
|
|
|
76
73
|
context.to_h
|
|
77
74
|
end
|
|
78
75
|
|
|
79
|
-
def
|
|
76
|
+
def participatory_space_for(object)
|
|
77
|
+
return object.participatory_space if object.respond_to?(:participatory_space)
|
|
78
|
+
return object if object.is_a?(Decidim::Participable)
|
|
79
|
+
|
|
80
|
+
component_for(object)&.participatory_space
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def component_for(object)
|
|
84
|
+
return object if object.is_a?(Decidim::Component)
|
|
85
|
+
|
|
86
|
+
object.component if object.respond_to?(:component)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def local_user_context(object, context)
|
|
80
90
|
context = local_context(object, context)
|
|
81
91
|
|
|
82
92
|
component = context[:current_component]
|
|
@@ -103,7 +113,9 @@ module Decidim
|
|
|
103
113
|
Decidim::Permissions
|
|
104
114
|
]
|
|
105
115
|
|
|
106
|
-
if object.is_a?(Decidim::
|
|
116
|
+
if object.is_a?(Decidim::Participable)
|
|
117
|
+
permissions.unshift(object.manifest.permissions_class)
|
|
118
|
+
elsif object.is_a?(Decidim::Component)
|
|
107
119
|
permissions.unshift(object.participatory_space.manifest.permissions_class)
|
|
108
120
|
permissions.unshift(object.manifest.permissions_class)
|
|
109
121
|
else
|
|
@@ -10,4 +10,50 @@ shared_examples_for "commentable interface" do
|
|
|
10
10
|
expect(response["totalCommentsCount"]).to eq(model.comments_count)
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
describe "with comments" do
|
|
15
|
+
let(:comments) { create_list(:comment, 5, commentable: model) }
|
|
16
|
+
let(:subcomments_level1) do
|
|
17
|
+
comments.map do |comment|
|
|
18
|
+
create_list(:comment, 2, commentable: comment)
|
|
19
|
+
end.flatten
|
|
20
|
+
end
|
|
21
|
+
let!(:subcomments_level2) do
|
|
22
|
+
subcomments_level1.map do |comment|
|
|
23
|
+
create(:comment, commentable: comment)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
let(:query) do
|
|
28
|
+
%(
|
|
29
|
+
{
|
|
30
|
+
comments {
|
|
31
|
+
...dataFragment
|
|
32
|
+
comments {
|
|
33
|
+
...dataFragment
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
fragment dataFragment on Comment {
|
|
38
|
+
id
|
|
39
|
+
body
|
|
40
|
+
createdAt
|
|
41
|
+
author { name }
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "includes the comments" do
|
|
47
|
+
expect(response["comments"]).to be_a(Array)
|
|
48
|
+
expect(response["comments"].count).to eq(5)
|
|
49
|
+
|
|
50
|
+
response["comments"].each do |comment|
|
|
51
|
+
expect(comment["comments"]).to be_a(Array)
|
|
52
|
+
expect(comment["comments"].count).to eq(2)
|
|
53
|
+
|
|
54
|
+
subcomments = subcomments_level1.select { |c| c.commentable.id == comment["id"].to_i }
|
|
55
|
+
expect(comment["comments"].map { |c| c["id"].to_i }).to match_array(subcomments.map(&:id))
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
13
59
|
end
|
data/lib/decidim/api/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: decidim-api
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.31.
|
|
4
|
+
version: 0.31.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Josep Jaume Rey Peroy
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2026-
|
|
13
|
+
date: 2026-10-22 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: decidim-core
|
|
@@ -18,14 +18,14 @@ dependencies:
|
|
|
18
18
|
requirements:
|
|
19
19
|
- - '='
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
|
-
version: 0.31.
|
|
21
|
+
version: 0.31.8
|
|
22
22
|
type: :runtime
|
|
23
23
|
prerelease: false
|
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
25
|
requirements:
|
|
26
26
|
- - '='
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: 0.31.
|
|
28
|
+
version: 0.31.8
|
|
29
29
|
- !ruby/object:Gem::Dependency
|
|
30
30
|
name: devise-jwt
|
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,56 +94,56 @@ dependencies:
|
|
|
94
94
|
requirements:
|
|
95
95
|
- - '='
|
|
96
96
|
- !ruby/object:Gem::Version
|
|
97
|
-
version: 0.31.
|
|
97
|
+
version: 0.31.8
|
|
98
98
|
type: :development
|
|
99
99
|
prerelease: false
|
|
100
100
|
version_requirements: !ruby/object:Gem::Requirement
|
|
101
101
|
requirements:
|
|
102
102
|
- - '='
|
|
103
103
|
- !ruby/object:Gem::Version
|
|
104
|
-
version: 0.31.
|
|
104
|
+
version: 0.31.8
|
|
105
105
|
- !ruby/object:Gem::Dependency
|
|
106
106
|
name: decidim-comments
|
|
107
107
|
requirement: !ruby/object:Gem::Requirement
|
|
108
108
|
requirements:
|
|
109
109
|
- - '='
|
|
110
110
|
- !ruby/object:Gem::Version
|
|
111
|
-
version: 0.31.
|
|
111
|
+
version: 0.31.8
|
|
112
112
|
type: :development
|
|
113
113
|
prerelease: false
|
|
114
114
|
version_requirements: !ruby/object:Gem::Requirement
|
|
115
115
|
requirements:
|
|
116
116
|
- - '='
|
|
117
117
|
- !ruby/object:Gem::Version
|
|
118
|
-
version: 0.31.
|
|
118
|
+
version: 0.31.8
|
|
119
119
|
- !ruby/object:Gem::Dependency
|
|
120
120
|
name: decidim-dev
|
|
121
121
|
requirement: !ruby/object:Gem::Requirement
|
|
122
122
|
requirements:
|
|
123
123
|
- - '='
|
|
124
124
|
- !ruby/object:Gem::Version
|
|
125
|
-
version: 0.31.
|
|
125
|
+
version: 0.31.8
|
|
126
126
|
type: :development
|
|
127
127
|
prerelease: false
|
|
128
128
|
version_requirements: !ruby/object:Gem::Requirement
|
|
129
129
|
requirements:
|
|
130
130
|
- - '='
|
|
131
131
|
- !ruby/object:Gem::Version
|
|
132
|
-
version: 0.31.
|
|
132
|
+
version: 0.31.8
|
|
133
133
|
- !ruby/object:Gem::Dependency
|
|
134
134
|
name: decidim-participatory_processes
|
|
135
135
|
requirement: !ruby/object:Gem::Requirement
|
|
136
136
|
requirements:
|
|
137
137
|
- - '='
|
|
138
138
|
- !ruby/object:Gem::Version
|
|
139
|
-
version: 0.31.
|
|
139
|
+
version: 0.31.8
|
|
140
140
|
type: :development
|
|
141
141
|
prerelease: false
|
|
142
142
|
version_requirements: !ruby/object:Gem::Requirement
|
|
143
143
|
requirements:
|
|
144
144
|
- - '='
|
|
145
145
|
- !ruby/object:Gem::Version
|
|
146
|
-
version: 0.31.
|
|
146
|
+
version: 0.31.8
|
|
147
147
|
description: API engine for decidim
|
|
148
148
|
email:
|
|
149
149
|
- josepjaume@gmail.com
|