2022-12-11 12:37:00 -08:00
|
|
|
/**
|
|
|
|
* Group relationship normalizer:
|
|
|
|
* Converts API group relationships into our internal format.
|
|
|
|
*/
|
|
|
|
import {
|
|
|
|
Map as ImmutableMap,
|
|
|
|
Record as ImmutableRecord,
|
|
|
|
fromJS,
|
|
|
|
} from 'immutable';
|
|
|
|
|
2023-03-28 08:52:41 -07:00
|
|
|
import { GroupRoles } from 'soapbox/schemas/group-member';
|
|
|
|
|
2022-12-11 12:37:00 -08:00
|
|
|
export const GroupRelationshipRecord = ImmutableRecord({
|
|
|
|
id: '',
|
2023-03-06 07:30:25 -08:00
|
|
|
blocked_by: false,
|
2022-12-11 12:37:00 -08:00
|
|
|
member: false,
|
2023-03-06 07:30:25 -08:00
|
|
|
notifying: null,
|
2022-12-11 12:37:00 -08:00
|
|
|
requested: false,
|
2023-06-08 06:00:49 -07:00
|
|
|
muting: false,
|
2023-03-28 08:52:41 -07:00
|
|
|
role: 'user' as GroupRoles,
|
2023-03-29 10:21:43 -07:00
|
|
|
pending_requests: false,
|
2022-12-11 12:37:00 -08:00
|
|
|
});
|
|
|
|
|
|
|
|
export const normalizeGroupRelationship = (relationship: Record<string, any>) => {
|
|
|
|
return GroupRelationshipRecord(
|
|
|
|
ImmutableMap(fromJS(relationship)),
|
|
|
|
);
|
|
|
|
};
|