Files
esign/packages/trpc/server/organisation-router/resend-organisation-member-invite.ts
zooqueen fb4e3df0e3 rename: @hanzo/sign-* → @hanzo/esign-* (full eSign brand consistency)
The product is branded Hanzo eSign (esign.hanzo.ai, repo hanzoai/esign).
Rename all workspace packages @hanzo/sign-* → @hanzo/esign-* (1052 files)
and align docker/Dockerfile turbo --scope/--filter to the actual remix
package name @hanzo/esign (was a pre-existing mismatch with -remix that
broke the build). Protected deps (@hanzo/insights, @hanzo/logo) untouched.
2026-06-21 19:56:09 -07:00

81 lines
2.0 KiB
TypeScript

import { ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP } from '@hanzo/esign-lib/constants/organisations';
import { AppError, AppErrorCode } from '@hanzo/esign-lib/errors/app-error';
import { sendOrganisationMemberInviteEmail } from '@hanzo/esign-lib/server-only/organisation/create-organisation-member-invites';
import { buildOrganisationWhereQuery } from '@hanzo/esign-lib/utils/organisations';
import { prisma } from '@hanzo/esign-prisma';
import {
ZResendOrganisationMemberInviteRequestSchema,
ZResendOrganisationMemberInviteResponseSchema,
} from './resend-organisation-member-invite.types';
export type ResendOrganisationMemberInvitationOptions = {
/**
* The ID of the user who is initiating this action.
*/
userId: number;
/**
* The name of the user who is initiating this action.
*/
userName: string;
/**
* The ID of the organisation.
*/
organisationId: string;
/**
* The IDs of the invitations to resend.
*/
invitationId: string;
};
/**
* Resend an email for a given member invite.
*/
export const resendOrganisationMemberInvitation = async ({
userId,
userName,
organisationId,
invitationId,
}: ResendOrganisationMemberInvitationOptions): Promise<void> => {
const organisation = await prisma.organisation.findFirst({
where: buildOrganisationWhereQuery({
organisationId,
userId,
roles: ORGANISATION_MEMBER_ROLE_PERMISSIONS_MAP['MANAGE_ORGANISATION'],
}),
include: {
organisationGlobalSettings: true,
invites: {
where: {
id: invitationId,
},
},
},
});
if (!organisation) {
throw new AppError('OrganisationNotFound', {
message: 'User is not a valid member of the team.',
statusCode: 404,
});
}
const invitation = organisation.invites[0];
if (!invitation) {
throw new AppError(AppErrorCode.NOT_FOUND, {
message: 'Invitation does not exist',
});
}
await sendOrganisationMemberInviteEmail({
email: invitation.email,
token: invitation.token,
senderName: userName,
organisation,
});
};