@@ -11,6 +11,7 @@ import { decryptFile } from '@/utils/encrypt'
1111import { parseCSV } from '@/utils/files'
1212import { ValidateTicketPod } from '@/utils/zupass'
1313import { GenerateRandomUsername , GetEnsAddress , GetEnsAvatar , GetEnsName } from '@/utils/account'
14+ import { apikeyHandler } from '@/middleware/apikey'
1415import dayjs from 'dayjs'
1516
1617const client = new PrismaClient ( )
@@ -32,6 +33,7 @@ accountRouter.get(`/account/speakers`, FollowedSpeakers)
3233accountRouter . get ( `/account/speakers/recommended` , RecommendedSpeakers )
3334accountRouter . get ( `/account/sessions` , FollowedSessions )
3435accountRouter . get ( `/account/sessions/recommended` , RecommendedSessions )
36+ accountRouter . post ( `/account/accreditation/email` , apikeyHandler , SendAccreditationEmail )
3537
3638async function GetAccount ( req : Request , res : Response ) {
3739 // #swagger.tags = ['Account']
@@ -725,6 +727,48 @@ async function RecommendedSessions(req: Request, res: Response) {
725727 return res . status ( 200 ) . send ( { code : 200 , message : '' , data : sessions } )
726728}
727729
730+ async function SendAccreditationEmail ( req : Request , res : Response ) {
731+ // #swagger.tags = ['Account']
732+ // Private route: requires apiKey
733+ // #swagger.ignore = true
734+
735+ const { email, name, insuranceLink } = req . body
736+
737+ if ( ! email || ! name || ! insuranceLink ) {
738+ return res . status ( 400 ) . send ( {
739+ code : 400 ,
740+ message : 'Missing required fields: email, name, insuranceLink'
741+ } )
742+ }
743+
744+ try {
745+ // Import the email service
746+ const { sendAccreditationConfirmationEmail } = await import ( '@/services/email' )
747+
748+ // Send the accreditation confirmation email
749+ const success = await sendAccreditationConfirmationEmail ( email , name , insuranceLink )
750+
751+ if ( success ) {
752+ return res . status ( 200 ) . send ( {
753+ code : 200 ,
754+ message : 'Accreditation confirmation email sent successfully' ,
755+ data : { email, name, insuranceLink }
756+ } )
757+ } else {
758+ return res . status ( 500 ) . send ( {
759+ code : 500 ,
760+ message : 'Failed to send accreditation email'
761+ } )
762+ }
763+ } catch ( error ) {
764+ console . error ( 'Error in SendAccreditationEmail:' , error )
765+ return res . status ( 500 ) . send ( {
766+ code : 500 ,
767+ message : 'Internal server error'
768+ } )
769+ }
770+ }
771+
728772async function parseProfileData ( attendeeEmail : string ) {
729773 const normalizedEmail = attendeeEmail . toLowerCase ( )
730774
0 commit comments