Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions src/api/group-membership/groupMembership.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -524,15 +524,12 @@ export class GroupMembershipService {
* @returns response dto
*/
async getMemberGroups(memberId: string, dto: GetMemberGroupsDto) {
const returnUuid = dto.uuid;
const returnUuid = dto?.uuid ?? true;

Choose a reason for hiding this comment

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

[⚠️ correctness]
Using the nullish coalescing operator ?? with true as a default value may lead to unexpected behavior if dto.uuid is explicitly set to false. Consider whether this is the intended behavior or if a different default value should be used.

const memberships = await this.prisma.groupMembership.findMany({
where: {
memberId: memberId,
group: {
status: GroupStatus.ACTIVE,
oldId: {
not: null,
},
},
},
});
Expand All @@ -557,15 +554,15 @@ export class GroupMembershipService {

const groups: any[] = [];
groupRes.forEach((groupL1) => {
if (groupL1.status === GroupStatus.ACTIVE && groupL1.oldId) {
if (groupL1.status === GroupStatus.ACTIVE) {
groups.push(groupL1);
}
groupL1.parentGroups.forEach((groupL2) => {
if (groupL2.status === GroupStatus.ACTIVE && groupL2.oldId) {
if (groupL2.status === GroupStatus.ACTIVE) {
groups.push(groupL2);
}
groupL2.parentGroups.forEach((groupL3) => {
if (groupL3.status === GroupStatus.ACTIVE && groupL3.oldId) {
if (groupL3.status === GroupStatus.ACTIVE) {
groups.push(groupL3);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/dto/groupMembership.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,13 @@ export class GetMemberGroupsDto {
name: 'uuid',
description: 'whether return uuid',
type: 'boolean',
default: false,
default: true,
required: false,
})
@Transform(({ value }) => transformBoolean(value))
@IsBoolean()
@IsOptional()
uuid: boolean = false;
uuid: boolean = true;
}

export class GetGroupMembersCountDto {
Expand Down
Loading