(
input: {
userId: string;
groupId: string;
groupMainPageId: string;
groupIsPersonal: boolean;
dtrx?: DataTransaction;
} & GroupCreationSchema,
)
| 44 | >; |
| 45 | |
| 46 | export async function createGroup( |
| 47 | input: { |
| 48 | userId: string; |
| 49 | |
| 50 | groupId: string; |
| 51 | groupMainPageId: string; |
| 52 | groupIsPersonal: boolean; |
| 53 | |
| 54 | dtrx?: DataTransaction; |
| 55 | } & GroupCreationSchema, |
| 56 | ) { |
| 57 | await dataAbstraction().insert( |
| 58 | 'group', |
| 59 | input.groupId, |
| 60 | { |
| 61 | id: input.groupId, |
| 62 | |
| 63 | encrypted_name: input.groupEncryptedName ?? new Uint8Array(), |
| 64 | |
| 65 | main_page_id: input.groupMainPageId, |
| 66 | |
| 67 | encrypted_rehashed_password_hash: |
| 68 | input.groupPasswordHash != null |
| 69 | ? encryptGroupRehashedPasswordHash( |
| 70 | computePasswordHash(input.groupPasswordHash), |
| 71 | ) |
| 72 | : undefined, |
| 73 | |
| 74 | access_keyring: input.groupIsPublic |
| 75 | ? input.groupAccessKeyring |
| 76 | : undefined, |
| 77 | encrypted_content_keyring: input.groupEncryptedContentKeyring, |
| 78 | |
| 79 | user_id: input.groupIsPersonal ? input.userId : undefined, |
| 80 | |
| 81 | public_keyring: input.groupPublicKeyring, |
| 82 | encrypted_private_keyring: input.groupEncryptedPrivateKeyring, |
| 83 | }, |
| 84 | { dtrx: input.dtrx }, |
| 85 | ); |
| 86 | |
| 87 | await dataAbstraction().insert( |
| 88 | 'group-member', |
| 89 | `${input.groupId}:${input.userId}`, |
| 90 | { |
| 91 | group_id: input.groupId, |
| 92 | user_id: input.userId, |
| 93 | |
| 94 | role: 'owner', |
| 95 | |
| 96 | encrypted_access_keyring: input.groupIsPublic |
| 97 | ? undefined |
| 98 | : input.groupAccessKeyring, |
| 99 | encrypted_internal_keyring: input.groupEncryptedInternalKeyring, |
| 100 | |
| 101 | encrypted_name: input.groupOwnerEncryptedName ?? new Uint8Array(), |
| 102 | }, |
| 103 | { dtrx: input.dtrx }, |
no test coverage detected