Merge branch 'mastodon-badges' into 'main'
Fix role badges for Pleroma Closes #1654 See merge request soapbox-pub/soapbox!3001
This commit is contained in:
commit
d6b5fb8fe7
1 changed files with 2 additions and 2 deletions
|
@ -129,7 +129,7 @@ const getDomain = (url: string) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const filterBadges = (tags?: 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. */
|
/** Add internal fields to the account. */
|
||||||
const transformAccount = <T extends TransformableAccount>({ pleroma, other_settings, fields, ...account }: T) => {
|
const transformAccount = <T extends TransformableAccount>({ pleroma, other_settings, fields, ...account }: T) => {
|
||||||
|
@ -169,7 +169,7 @@ const transformAccount = <T extends TransformableAccount>({ pleroma, other_setti
|
||||||
const { relationship, ...rest } = pleroma;
|
const { relationship, ...rest } = pleroma;
|
||||||
return rest;
|
return rest;
|
||||||
})(),
|
})(),
|
||||||
roles: account.roles || filterBadges(pleroma?.tags),
|
roles: account.roles.length ? account.roles : filterBadges(pleroma?.tags),
|
||||||
relationship: pleroma?.relationship,
|
relationship: pleroma?.relationship,
|
||||||
staff: pleroma?.is_admin || pleroma?.is_moderator || false,
|
staff: pleroma?.is_admin || pleroma?.is_moderator || false,
|
||||||
suspended: account.suspended || pleroma?.deactivated || false,
|
suspended: account.suspended || pleroma?.deactivated || false,
|
||||||
|
|
Loading…
Reference in a new issue