import { EMAIL_TEMPLATE_ID } from 'common/enums' ; import { environment } from 'common/environment' ; import { notificationQueue } from 'connectors/queue/notification' ; import { GQLVerificationCodeType , LANGUAGES } from 'definitions' ; import { trans } from './utils' ; export const sendCircleInvitation = async ( { code , circle , language = 'zh_hant' , recipient , redirectUrl , sender , to , } ) => { const templateId = EMAIL_TEMPLATE_ID . circleInvitation [ language ] ; const urlHasQs = redirectUrl && redirectUrl . indexOf ( '?' ) >= 0 ; const registerLink = code ? `${ redirectUrl }${ urlHasQs ? '&' : '?' }code=${ code }&type=${ GQLVerificationCodeType . register }` : undefined ; const circleLink = code ? undefined : `${ environment . siteDomain }/~${ circle . name }` ; notificationQueue . sendMail ( { from : environment . emailFromAsk as string , templateId , personalizations : [ { to , dynamic_template_data : { circle , circleLink , code , recipient , registerLink , sender , siteDomain : environment . siteDomain , subject : trans . circle . invitation ( language , { sender : sender . displayName , circle : circle . displayName , } ) , } , } , ] , } ) ; } ;