commit: 0d714f07ecda00a54392f47fe0054e37e269a7d3
parent 610720f164dc9fcf36f9df33bddec5ac9c654e1e
Author: Ilja <ilja@ilja.space>
Date: Sat, 6 Aug 2022 11:43:06 +0200
Add priviliges
We can now check what priviliges someone has besides only the role.
On older back-ends, privileges aren't provided, so we have a fall-back to list the privileges corresponding to what mods/admins are allowed on older BE's.
Diffstat:
1 file changed, 27 insertions(+), 0 deletions(-)
diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js
@@ -119,6 +119,33 @@ export const parseUser = (data) => {
} else {
output.role = 'member'
}
+
+ if (data.pleroma.privileges) {
+ output.privileges = data.pleroma.privileges
+ } else if (data.pleroma.is_admin) {
+ output.privileges = [
+ 'users_read',
+ 'users_manage_invites',
+ 'users_manage_activation_state',
+ 'users_manage_tags',
+ 'users_manage_credentials',
+ 'users_delete',
+ 'messages_read',
+ 'messages_delete',
+ 'instances_delete',
+ 'reports_manage_reports',
+ 'moderation_log_read',
+ 'announcements_manage_announcements',
+ 'emoji_manage_emoji',
+ 'statistics_read'
+ ]
+ } else if (data.pleroma.is_moderator) {
+ output.privileges = [
+ 'messages_delete'
+ ]
+ } else {
+ output.privileges = []
+ }
}
if (data.source) {