pleroma/app/soapbox/normalizers/group-relationship.ts
marcin mikołajczak 12825f9350 Groups: actions, normalizers, reducers
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-12-11 22:24:01 +01:00

22 lines
525 B
TypeScript

/**
* Group relationship normalizer:
* Converts API group relationships into our internal format.
*/
import {
Map as ImmutableMap,
Record as ImmutableRecord,
fromJS,
} from 'immutable';
export const GroupRelationshipRecord = ImmutableRecord({
id: '',
member: false,
requested: false,
role: null as 'admin' | 'moderator' | 'user' | null,
});
export const normalizeGroupRelationship = (relationship: Record<string, any>) => {
return GroupRelationshipRecord(
ImmutableMap(fromJS(relationship)),
);
};