chore: removed stated return type
This commit is contained in:
committed by
Andrew Bastin
parent
1d93745a4e
commit
089f6823e6
@@ -4,7 +4,6 @@ import * as E from 'fp-ts/Either';
|
|||||||
import { PrismaService } from 'src/prisma/prisma.service';
|
import { PrismaService } from 'src/prisma/prisma.service';
|
||||||
import { TeamInvitation as DBTeamInvitation } from '@prisma/client';
|
import { TeamInvitation as DBTeamInvitation } from '@prisma/client';
|
||||||
import { TeamMember, TeamMemberRole } from 'src/team/team.model';
|
import { TeamMember, TeamMemberRole } from 'src/team/team.model';
|
||||||
import { User } from 'src/user/user.model';
|
|
||||||
import { TeamService } from 'src/team/team.service';
|
import { TeamService } from 'src/team/team.service';
|
||||||
import {
|
import {
|
||||||
INVALID_EMAIL,
|
INVALID_EMAIL,
|
||||||
@@ -50,9 +49,7 @@ export class TeamInvitationService {
|
|||||||
* @param inviteID invite id
|
* @param inviteID invite id
|
||||||
* @returns an Option of team invitation or none
|
* @returns an Option of team invitation or none
|
||||||
*/
|
*/
|
||||||
async getInvitation(
|
async getInvitation(inviteID: string) {
|
||||||
inviteID: string,
|
|
||||||
): Promise<O.None | O.Some<TeamInvitation>> {
|
|
||||||
try {
|
try {
|
||||||
const dbInvitation = await this.prisma.teamInvitation.findUniqueOrThrow({
|
const dbInvitation = await this.prisma.teamInvitation.findUniqueOrThrow({
|
||||||
where: {
|
where: {
|
||||||
@@ -105,7 +102,7 @@ export class TeamInvitationService {
|
|||||||
teamID: string,
|
teamID: string,
|
||||||
inviteeEmail: string,
|
inviteeEmail: string,
|
||||||
inviteeRole: TeamMemberRole,
|
inviteeRole: TeamMemberRole,
|
||||||
): Promise<E.Left<string> | E.Right<TeamInvitation>> {
|
) {
|
||||||
// validate email
|
// validate email
|
||||||
const isEmailValid = validateEmail(inviteeEmail);
|
const isEmailValid = validateEmail(inviteeEmail);
|
||||||
if (!isEmailValid) return E.left(INVALID_EMAIL);
|
if (!isEmailValid) return E.left(INVALID_EMAIL);
|
||||||
@@ -169,9 +166,7 @@ export class TeamInvitationService {
|
|||||||
* @param inviteID invite id
|
* @param inviteID invite id
|
||||||
* @returns an Either of true or error message
|
* @returns an Either of true or error message
|
||||||
*/
|
*/
|
||||||
async revokeInvitation(
|
async revokeInvitation(inviteID: string) {
|
||||||
inviteID: string,
|
|
||||||
): Promise<E.Left<string> | E.Right<boolean>> {
|
|
||||||
// check if the invite exists
|
// check if the invite exists
|
||||||
const invitation = await this.getInvitation(inviteID);
|
const invitation = await this.getInvitation(inviteID);
|
||||||
if (O.isNone(invitation)) return E.left(TEAM_INVITE_NO_INVITE_FOUND);
|
if (O.isNone(invitation)) return E.left(TEAM_INVITE_NO_INVITE_FOUND);
|
||||||
@@ -197,10 +192,7 @@ export class TeamInvitationService {
|
|||||||
* @param acceptedBy user who accepted the invitation
|
* @param acceptedBy user who accepted the invitation
|
||||||
* @returns an Either of team member or error message
|
* @returns an Either of team member or error message
|
||||||
*/
|
*/
|
||||||
async acceptInvitation(
|
async acceptInvitation(inviteID: string, acceptedBy: AuthUser) {
|
||||||
inviteID: string,
|
|
||||||
acceptedBy: AuthUser,
|
|
||||||
): Promise<E.Left<string> | E.Right<TeamMember>> {
|
|
||||||
// check if the invite exists
|
// check if the invite exists
|
||||||
const invitation = await this.getInvitation(inviteID);
|
const invitation = await this.getInvitation(inviteID);
|
||||||
if (O.isNone(invitation)) return E.left(TEAM_INVITE_NO_INVITE_FOUND);
|
if (O.isNone(invitation)) return E.left(TEAM_INVITE_NO_INVITE_FOUND);
|
||||||
|
|||||||
Reference in New Issue
Block a user