diff --git a/src/schemas/account.ts b/src/schemas/account.ts index 06252ac5a..b085120b7 100644 --- a/src/schemas/account.ts +++ b/src/schemas/account.ts @@ -129,7 +129,7 @@ const getDomain = (url: string) => { }; const filterBadges = (tags?: string[]) => - tags?.filter(tag => tag.startsWith('badge:')).map(tag => ({ id: tag, name: tag.replace(/^badge:/, '') })); + tags?.filter(tag => tag.startsWith('badge:')).map(tag => roleSchema.parse({ id: tag, name: tag.replace(/^badge:/, '') })); /** Add internal fields to the account. */ const transformAccount = ({ pleroma, other_settings, fields, ...account }: T) => { @@ -169,7 +169,7 @@ const transformAccount = ({ pleroma, other_setti const { relationship, ...rest } = pleroma; return rest; })(), - roles: account.roles || filterBadges(pleroma?.tags), + roles: account.roles.length ? account.roles : filterBadges(pleroma?.tags), relationship: pleroma?.relationship, staff: pleroma?.is_admin || pleroma?.is_moderator || false, suspended: account.suspended || pleroma?.deactivated || false,