Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
DCP project
DCPv4
Commits
bda79012
Commit
bda79012
authored
May 01, 2022
by
Elizabeth Myers
💬
Browse files
Require the emoji permission to upload emoji
parent
4d4c7166
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
3 deletions
+16
-3
dcp/acl.py
dcp/acl.py
+3
-0
dcp/webserver/media.py
dcp/webserver/media.py
+13
-3
No files found.
dcp/acl.py
View file @
bda79012
...
...
@@ -2,6 +2,7 @@ required_permission_user = {
'auspex'
:
'auspex'
,
'ban'
:
'auspex'
,
'banned'
:
'ban'
,
'emoji'
:
'emoji'
,
'mute'
:
'auspex'
,
'muted'
:
'mute'
,
}
...
...
@@ -12,6 +13,7 @@ required_permission_group = {
'ban'
:
'auspex'
,
'banned'
:
'ban'
,
'delete'
:
'delete'
,
'emoji'
:
'emoji'
,
'mute'
:
'auspex'
,
'muted'
:
'mute'
,
}
...
...
@@ -20,6 +22,7 @@ default_acl_user = set()
default_acl_group
=
{
'auspex'
,
'delete'
,
'emoji'
,
'metadata'
,
'ban'
,
'mute'
,
...
...
dcp/webserver/media.py
View file @
bda79012
...
...
@@ -235,15 +235,25 @@ class EmojiFileUploader(MediaFileUploader):
async
with
session
.
begin
():
# Find the user
stmt
=
(
select
(
StorageUser
).
where
(
StorageUser
.
username
==
self
.
user
)
where
(
StorageUser
.
username
==
self
.
user
).
options
(
selectinload
(
StorageUser
.
acls
))
)
result
=
await
session
.
execute
(
stmt
)
try
:
storage_src
=
result
.
one
()[
0
]
except
(
NoResultFound
,
IndexError
):
# Shouldn't happen
return
web
.
json_response
({
'reason'
:
'Server error'
},
status
=
500
)
raise
web
.
HTTPInternalServerError
(
text
=
'{"reason": "Internal server error"}'
,
content_type
=
'application/json'
)
acls
=
set
(
x
.
acl
for
x
in
storage_src
.
acls
)
if
'emoji'
not
in
acls
:
raise
web
.
HTTPUnauthorized
(
text
=
'{"reason": "You are not authorized"}'
,
content_type
=
'application/json'
)
relative_file_path
=
str
(
Path
(
self
.
relative_storage_path
,
self
.
filename
))
...
...
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