[Gekidou] Update database to hold if a user is a team or channel admin (#6351)

* Update database to hold if a user is a team or channel admin

* TeamMembership identifier

* Fix handleTeamMembership test

* Update server.md

Co-authored-by: Avinash Lingaloo <avinashlng1080@gmail.com>
This commit is contained in:
Elias Nahum
2022-06-06 05:54:02 -04:00
committed by GitHub
parent f97d943f9a
commit 81357d8a0e
14 changed files with 36 additions and 3 deletions

View File

@@ -85,10 +85,15 @@ describe('*** Operator: Team Handlers tests ***', () => {
prepareRecordsOnly: false,
});
const memberships = teamMemberships.map((m) => ({
...m,
id: `${m.team_id}-${m.user_id}`,
}));
expect(spyOnHandleRecords).toHaveBeenCalledTimes(1);
expect(spyOnHandleRecords).toHaveBeenCalledWith({
fieldName: 'user_id',
createOrUpdateRawValues: teamMemberships,
createOrUpdateRawValues: memberships,
tableName: 'TeamMembership',
prepareRecordsOnly: false,
buildKeyRecordBy: buildTeamMembershipKey,

View File

@@ -59,7 +59,12 @@ const TeamHandler = (superclass: any) => class extends superclass {
return [];
}
const createOrUpdateRawValues = getUniqueRawsBy({raws: teamMemberships, key: 'team_id'});
const memberships: TeamMembership[] = teamMemberships.map((m) => ({
...m,
id: `${m.team_id}-${m.user_id}`,
}));
const createOrUpdateRawValues = getUniqueRawsBy({raws: memberships, key: 'id'});
return this.handleRecords({
fieldName: 'user_id',