Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
gab
social
gab-social
Commits
fea1b938
Commit
fea1b938
authored
Feb 18, 2021
by
Fosco Marotto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a writing role to the shortcuts controller
parent
be5fc255
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
app/controllers/api/v1/shortcuts_controller.rb
app/controllers/api/v1/shortcuts_controller.rb
+5
-3
No files found.
app/controllers/api/v1/shortcuts_controller.rb
View file @
fea1b938
...
...
@@ -6,7 +6,7 @@ class Api::V1::ShortcutsController < Api::BaseController
def
index
@shortcuts
=
Shortcut
.
where
(
account:
current_account
).
limit
(
100
)
@onlyGroupIds
=
@shortcuts
.
select
{
|
s
|
s
.
shortcut_type
==
'group'
}.
map
(
&
:shortcut_id
)
@onlyAccountIds
=
@shortcuts
.
select
{
|
s
|
s
.
shortcut_type
==
'account'
}.
map
(
&
:shortcut_id
)
...
...
@@ -29,7 +29,9 @@ class Api::V1::ShortcutsController < Api::BaseController
elsif
s
.
shortcut_type
==
'account'
@account
=
@accounts
.
detect
{
|
a
|
a
.
id
==
s
.
shortcut_id
}
if
@account
.
nil?
s
.
destroy!
ActiveRecord
::
Base
.
connected_to
(
role: :writing
)
do
s
.
destroy!
end
else
value
=
REST
::
AccountSerializer
.
new
(
@account
)
end
...
...
@@ -73,7 +75,7 @@ class Api::V1::ShortcutsController < Api::BaseController
}
render
json:
r
rescue
ActiveRecord
::
RecordNotUnique
render
json:
{
error:
I18n
.
t
(
'shortcuts.errors.exists'
)
},
status:
422
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment