From 0d714f07ecda00a54392f47fe0054e37e269a7d3 Mon Sep 17 00:00:00 2001 From: Ilja Date: Sat, 6 Aug 2022 11:43:06 +0200 Subject: [PATCH] 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. --- .../entity_normalizer.service.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index 7f831ed9..1be19cf1 100644 --- 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) {