Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/api/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2479,12 +2479,13 @@ export class UserService {
}

private async addUserToGroupByGroupId(userId: number, groupId: string) {
const groupMemberId = crypto.randomUUID();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Using crypto.randomUUID() is a good choice for generating unique IDs, but ensure that the database column id in GroupMember can handle UUIDs if it wasn't previously. Verify the column type to prevent potential issues.

const memberId = String(userId);
const createdBy = String(Constants.DEFAULT_CREATE_USER_ID);
const membershipType = Constants.memberGroupMembershipName;
const affected = await this.groupPrismaClient.$executeRaw`
INSERT INTO "groups"."GroupMember" ("groupId", "memberId", "membershipType", "createdBy")
VALUES (${groupId}, ${memberId}, ${membershipType}, ${createdBy})
INSERT INTO "groups"."GroupMember" ("id", "groupId", "memberId", "membershipType", "createdBy")
VALUES (${groupMemberId}, ${groupId}, ${memberId}, ${membershipType}, ${createdBy})
ON CONFLICT ("groupId", "memberId") DO NOTHING
`;
if (affected === 0) {
Expand Down
Loading