fix: Org slight

This commit is contained in:
SauravDhakal
2026-04-02 21:51:46 +05:45
parent 349196b801
commit 68135ae022
3 changed files with 13 additions and 4 deletions

View File

@@ -10,6 +10,8 @@ services:
- '5454:5432' - '5454:5432'
volumes: volumes:
- multiTenant:/var/lib/postgresql - multiTenant:/var/lib/postgresql
restart: unless-stopped
volumes: volumes:
multiTenant: multiTenant:

View File

@@ -9,7 +9,7 @@ import { Authorization } from 'src/auth/decorators';
/* NOTE: Regarding endpoint path naming /* NOTE: Regarding endpoint path naming
* - Since we follow REST style, endpoint are resource based. * - Since we follow REST style, endpoint are resource based.
* - So insted of /organization/:orgId/invitation-action, we user ..../invitation/:invitationId * - So insted of /organization/:orgId/invitation-action, we user ..../invitation/:invitationId
* (invitationid points to a resource) * (invitationId points to a resource)
* */ * */
@Controller('membership') @Controller('membership')

View File

@@ -45,8 +45,10 @@ export class OrganizationMembershipService {
where: { where: {
orgId, orgId,
userId, userId,
status: ORGANIZATION_JOIN_REQUEST.PENDING
}, },
orderBy: {
requestedOn: "desc"
}
}), }),
this.prisma.organizationUserJoinTable.findFirst({ this.prisma.organizationUserJoinTable.findFirst({
where: { where: {
@@ -59,7 +61,7 @@ export class OrganizationMembershipService {
if (!orgExists) if (!orgExists)
throw new NotFoundException("Organization") throw new NotFoundException("Organization")
if (invitationAlreadySent) if (invitationAlreadySent?.status === "PENDING")
throw new BadRequestException("Invitation to join this organization already sent") throw new BadRequestException("Invitation to join this organization already sent")
if (userAlreadyPartOf) if (userAlreadyPartOf)
throw new BadRequestException("User already part of the organization") throw new BadRequestException("User already part of the organization")
@@ -85,7 +87,8 @@ export class OrganizationMembershipService {
where: { where: {
id, id,
userId, userId,
orgId orgId,
status: ORGANIZATION_JOIN_REQUEST.PENDING,
}, },
data: { data: {
status: ORGANIZATION_JOIN_REQUEST.CANCELLED, status: ORGANIZATION_JOIN_REQUEST.CANCELLED,
@@ -116,6 +119,7 @@ export class OrganizationMembershipService {
where: { where: {
userId, userId,
requestType: joinReqType, requestType: joinReqType,
status: ORGANIZATION_JOIN_REQUEST.PENDING
}, },
include: { user: { select: { firstName: true, email: true } } } include: { user: { select: { firstName: true, email: true } } }
}) })
@@ -152,6 +156,8 @@ export class OrganizationMembershipService {
id, id,
userId, userId,
orgId, orgId,
status: ORGANIZATION_JOIN_REQUEST.PENDING,
requestType: ORGANIZATION_JOIN_REQUEST_TYPE.REQUESTED
}, },
data: { data: {
status: userAction, status: userAction,
@@ -173,6 +179,7 @@ export class OrganizationMembershipService {
}); });
} }
catch (err) { catch (err) {
console.log(err)
if (err instanceof Prisma.PrismaClientKnownRequestError) { if (err instanceof Prisma.PrismaClientKnownRequestError) {
if (err.code === 'P2002') if (err.code === 'P2002')
throw new BadRequestException('User already part of this organization.'); throw new BadRequestException('User already part of this organization.');