Allow admins to delete Group statuses
This commit is contained in:
parent
73eedea362
commit
6cd8e50493
|
@ -460,18 +460,24 @@ const StatusActionBar: React.FC<IStatusActionBar> = ({
|
|||
});
|
||||
}
|
||||
|
||||
if (status.group &&
|
||||
groupRelationship?.role &&
|
||||
[GroupRoles.OWNER].includes(groupRelationship.role) &&
|
||||
!ownAccount
|
||||
) {
|
||||
menu.push(null);
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.groupModDelete),
|
||||
action: handleDeleteFromGroup,
|
||||
icon: require('@tabler/icons/trash.svg'),
|
||||
destructive: true,
|
||||
});
|
||||
const isGroupStatus = typeof status.group === 'object';
|
||||
if (isGroupStatus && !!status.group) {
|
||||
const group = status.group as Group;
|
||||
const account = status.account as Account;
|
||||
const isGroupOwner = groupRelationship?.role === GroupRoles.OWNER;
|
||||
const isGroupAdmin = groupRelationship?.role === GroupRoles.ADMIN;
|
||||
const isStatusFromOwner = group.owner.id === account.id;
|
||||
const canDeleteStatus = !ownAccount && (isGroupOwner || (isGroupAdmin && !isStatusFromOwner));
|
||||
|
||||
if (canDeleteStatus) {
|
||||
menu.push(null);
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.groupModDelete),
|
||||
action: handleDeleteFromGroup,
|
||||
icon: require('@tabler/icons/trash.svg'),
|
||||
destructive: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (isStaff) {
|
||||
|
|
|
@ -32,6 +32,9 @@ export const GroupRecord = ImmutableRecord({
|
|||
locked: false,
|
||||
membership_required: false,
|
||||
members_count: 0,
|
||||
owner: {
|
||||
id: '',
|
||||
},
|
||||
note: '',
|
||||
statuses_visibility: 'public',
|
||||
slug: '',
|
||||
|
|
|
@ -27,6 +27,7 @@ const groupSchema = z.object({
|
|||
locked: z.boolean().catch(false),
|
||||
membership_required: z.boolean().catch(false),
|
||||
members_count: z.number().catch(0),
|
||||
owner: z.object({ id: z.string() }),
|
||||
note: z.string().transform(note => note === '<p></p>' ? '' : note).catch(''),
|
||||
relationship: groupRelationshipSchema.nullable().catch(null), // Dummy field to be overwritten later
|
||||
slug: z.string().catch(''), // TruthSocial
|
||||
|
|
Loading…
Reference in New Issue