Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
[feat] : Allow admins to revoke a team invite (HBE-230) (#3162)
Ankit Sridhar88f6a4ae26a2
diff --git a/packages/hoppscotch-backend/src/admin/admin.resolver.ts b/packages/hoppscotch-backend/src/admin/admin.resolver.tsindex 12838963a..d8832071f 100644--- a/packages/hoppscotch-backend/src/admin/admin.resolver.ts+++ b/packages/hoppscotch-backend/src/admin/admin.resolver.ts@@ -411,6 +411,23 @@ export class AdminResolver {return deletedTeam.right;}+ @Mutation(() => Boolean, {+ description: 'Revoke a team Invite by Invite ID',+ })+ @UseGuards(GqlAuthGuard, GqlAdminGuard)+ async revokeTeamInviteByAdmin(+ @Args({+ name: 'inviteID',+ description: 'Team Invite ID',+ type: () => ID,+ })+ inviteID: string,+ ): Promise<boolean> {+ const invite = await this.adminService.revokeTeamInviteByID(inviteID);+ if (E.isLeft(invite)) throwErr(invite.left);+ return true;+ }+/* Subscriptions */@Subscription(() => InvitedUser, {diff --git a/packages/hoppscotch-backend/src/admin/admin.service.ts b/packages/hoppscotch-backend/src/admin/admin.service.tsindex ab1f1dc9c..1ac4102ae 100644--- a/packages/hoppscotch-backend/src/admin/admin.service.ts+++ b/packages/hoppscotch-backend/src/admin/admin.service.ts@@ -11,6 +11,7 @@ import {INVALID_EMAIL,ONLY_ONE_ADMIN_ACCOUNT,TEAM_INVITE_ALREADY_MEMBER,+ TEAM_INVITE_NO_INVITE_FOUND,USER_ALREADY_INVITED,USER_IS_ADMIN,USER_NOT_FOUND,@@ -416,4 +417,19 @@ export class AdminService {if (E.isLeft(team)) return E.left(team.left);return E.right(team.right);}++ /**+ * Revoke a team invite by ID+ * @param inviteID Team Invite ID+ * @returns an Either of boolean or error+ */+ async revokeTeamInviteByID(inviteID: string) {+ const teamInvite = await this.teamInvitationService.revokeInvitation(+ inviteID,+ );++ if (E.isLeft(teamInvite)) return E.left(teamInvite.left);++ return E.right(teamInvite.right);+ }}