[Gekidou] Saves groups + group-channel for constrained channels (#6358)

* Rebases and addresses PR feedback

* Rebased and addresses PR feedback

* Checks group constraint in action instead

* Update method docs, parallel promises

* Parallel promises, method docs

* Cleans up method docs

* Method docs cleanup

* Update app/database/operator/server_data_operator/handlers/group.ts

Co-authored-by: Elias Nahum <nahumhbl@gmail.com>
This commit is contained in:
Shaz MJ
2022-08-01 08:02:15 +10:00
committed by GitHub
parent f94dfc9adf
commit 4b698c7f41
7 changed files with 132 additions and 16 deletions

View File

@@ -6,6 +6,7 @@ import {Database, Q} from '@nozbe/watermelondb';
import {MM_TABLES} from '@constants/database';
import type GroupModel from '@typings/database/models/servers/group';
import type GroupChannelModel from '@typings/database/models/servers/group_channel';
import type GroupMembershipModel from '@typings/database/models/servers/group_membership';
import type GroupTeamModel from '@typings/database/models/servers/group_team';
@@ -37,6 +38,12 @@ export const queryGroupsByNameInChannel = (database: Database, name: string, cha
);
};
export const queryGroupChannelForChannel = (database: Database, channelId: string) => {
return database.collections.get<GroupChannelModel>(GROUP_CHANNEL).query(
Q.where('channel_id', channelId),
);
};
export const queryGroupMembershipForMember = (database: Database, userId: string) => {
return database.collections.get<GroupMembershipModel>(GROUP_MEMBERSHIP).query(
Q.where('user_id', userId),