fix: Org slight
This commit is contained in:
@@ -10,6 +10,8 @@ services:
|
||||
- '5454:5432'
|
||||
volumes:
|
||||
- multiTenant:/var/lib/postgresql
|
||||
restart: unless-stopped
|
||||
|
||||
|
||||
volumes:
|
||||
multiTenant:
|
||||
|
||||
@@ -9,7 +9,7 @@ import { Authorization } from 'src/auth/decorators';
|
||||
/* NOTE: Regarding endpoint path naming
|
||||
* - Since we follow REST style, endpoint are resource based.
|
||||
* - So insted of /organization/:orgId/invitation-action, we user ..../invitation/:invitationId
|
||||
* (invitationid points to a resource)
|
||||
* (invitationId points to a resource)
|
||||
* */
|
||||
|
||||
@Controller('membership')
|
||||
|
||||
@@ -45,8 +45,10 @@ export class OrganizationMembershipService {
|
||||
where: {
|
||||
orgId,
|
||||
userId,
|
||||
status: ORGANIZATION_JOIN_REQUEST.PENDING
|
||||
},
|
||||
orderBy: {
|
||||
requestedOn: "desc"
|
||||
}
|
||||
}),
|
||||
this.prisma.organizationUserJoinTable.findFirst({
|
||||
where: {
|
||||
@@ -59,7 +61,7 @@ export class OrganizationMembershipService {
|
||||
|
||||
if (!orgExists)
|
||||
throw new NotFoundException("Organization")
|
||||
if (invitationAlreadySent)
|
||||
if (invitationAlreadySent?.status === "PENDING")
|
||||
throw new BadRequestException("Invitation to join this organization already sent")
|
||||
if (userAlreadyPartOf)
|
||||
throw new BadRequestException("User already part of the organization")
|
||||
@@ -85,7 +87,8 @@ export class OrganizationMembershipService {
|
||||
where: {
|
||||
id,
|
||||
userId,
|
||||
orgId
|
||||
orgId,
|
||||
status: ORGANIZATION_JOIN_REQUEST.PENDING,
|
||||
},
|
||||
data: {
|
||||
status: ORGANIZATION_JOIN_REQUEST.CANCELLED,
|
||||
@@ -116,6 +119,7 @@ export class OrganizationMembershipService {
|
||||
where: {
|
||||
userId,
|
||||
requestType: joinReqType,
|
||||
status: ORGANIZATION_JOIN_REQUEST.PENDING
|
||||
},
|
||||
include: { user: { select: { firstName: true, email: true } } }
|
||||
})
|
||||
@@ -152,6 +156,8 @@ export class OrganizationMembershipService {
|
||||
id,
|
||||
userId,
|
||||
orgId,
|
||||
status: ORGANIZATION_JOIN_REQUEST.PENDING,
|
||||
requestType: ORGANIZATION_JOIN_REQUEST_TYPE.REQUESTED
|
||||
},
|
||||
data: {
|
||||
status: userAction,
|
||||
@@ -173,6 +179,7 @@ export class OrganizationMembershipService {
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
console.log(err)
|
||||
if (err instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
if (err.code === 'P2002')
|
||||
throw new BadRequestException('User already part of this organization.');
|
||||
|
||||
Reference in New Issue
Block a user