* Add akismet package to tasker * Create scanWorkflowBody task * Schedule workflow body scan * Add AKISMET_API_KEY .env * Auto lock user if spam is detected * Uncommit key * Add safe param to workflow step * Migration for safe field * Do not process workflow steps is `safe` is false * Update migration to set previous records to true * Address comments * Refactor `scheduleWorkflowNotifications` to accept an object * If new steps or editing old ones send to tasker * Call `scheduleWorkflowNotifications` in task * Fix `IS_SELF_HOSTED` * Remove unused function * Make `safe` optional in schema * Type fix * Revert "Make `safe` optional in schema" This reverts commit d0964702affa87c35562300301473d25635c565b. * Revert "Type fix" This reverts commit d9a031303269a2994ae46f576ab2a3d31e4d977b. * Type fixes * Type fixes * Address comments * Fix tests * Add tests * Update tests * Typo fix * Update `safe` to `verifiedAt` * feat: Compare workflow reminder bodies to default template (#19060) * Add `getTemplateForAction` function * Use `getTemplateForAction` when creating a new step * Use `getTemplateForAction` when action changes * Have `emailReminderTemplate` accept an object as a param * Rename `getTemplateForAction` to `getTemplateBodyForAction` * Simplify changing body when changing templates * Create `compareReminderBodyToTemplate` * In task, compare if reminderBody is a template * Linting * Add tests * refactor: `emailReminderTemplate` to accept object as param (#19288) * Add `getTemplateForAction` function * Use `getTemplateForAction` when creating a new step * Use `getTemplateForAction` when action changes * Have `emailReminderTemplate` accept an object as a param * Rename `getTemplateForAction` to `getTemplateBodyForAction` * Simplify changing body when changing templates * Create `compareReminderBodyToTemplate` * In task, compare if reminderBody is a template * Linting * Add tests * Refactor `scheduleEmailReminders` * Refactor `create.handler` for new workflows * Refactor `emailReminderManager` * Refactor `getEmailTemplateText` * Fix typo * Type fix - whatsapp plain text template imports * Type fix - no template found * Type fix - add `isBrandingDisabled` to `emailReminderTemplate` * Add workflow and user to prisma mock * Fix imports for akismet dependencies * Record user lock reason * Undo linting changes * Fix tests * New workflow, at verify created step * Handle if `SCANNING_WORKFLOW_STEPS` is toggled * Move `verifiedAt` checks to specific schedule functions - `scheduleWhatsappReminder` - `scheduleEmailReminder` - `scheduleSMSReminder` * Update logic * Do not fallback verifiedAt * Add comment to next.config.js
51 lines
1.7 KiB
TypeScript
51 lines
1.7 KiB
TypeScript
import dayjs from "@calcom/dayjs";
|
|
import { TimeFormat } from "@calcom/lib/timeFormat";
|
|
import { WorkflowActions } from "@calcom/prisma/enums";
|
|
|
|
const smsReminderTemplate = (
|
|
isEditingMode: boolean,
|
|
locale: string,
|
|
action?: WorkflowActions,
|
|
timeFormat?: TimeFormat,
|
|
startTime?: string,
|
|
eventName?: string,
|
|
timeZone?: string,
|
|
attendee?: string,
|
|
name?: string
|
|
) => {
|
|
const currentTimeFormat = timeFormat || TimeFormat.TWELVE_HOUR;
|
|
|
|
let eventDate;
|
|
if (isEditingMode) {
|
|
eventName = "{EVENT_NAME}";
|
|
timeZone = "{TIMEZONE}";
|
|
startTime = `{EVENT_TIME_${currentTimeFormat}}`;
|
|
|
|
eventDate = "{EVENT_DATE_YYYY MMM D}";
|
|
attendee = action === WorkflowActions.SMS_ATTENDEE ? "{ORGANIZER}" : "{ATTENDEE}";
|
|
name = action === WorkflowActions.SMS_ATTENDEE ? "{ATTENDEE}" : "{ORGANIZER}";
|
|
} else {
|
|
eventDate = dayjs(startTime).tz(timeZone).locale(locale).format("YYYY MMM D");
|
|
startTime = dayjs(startTime).tz(timeZone).locale(locale).format(currentTimeFormat);
|
|
}
|
|
|
|
const templateOne = `Hi${
|
|
name ? ` ${name}` : ``
|
|
}, this is a reminder that your meeting (${eventName}) with ${attendee} is on ${eventDate} at ${startTime} ${timeZone}.`;
|
|
|
|
//Twilio recommends message to be no longer than 320 characters
|
|
if (templateOne.length <= 320) return templateOne;
|
|
|
|
const templateTwo = `Hi, this is a reminder that your meeting with ${attendee} is on ${eventDate} at ${startTime} ${timeZone}`;
|
|
|
|
//Twilio supports up to 1600 characters
|
|
if (templateTwo.length <= 1600) return templateTwo;
|
|
|
|
return null;
|
|
};
|
|
|
|
export default smsReminderTemplate;
|
|
|
|
export const plainTextTemplate =
|
|
"Hi {ATTENDEE}, this is a reminder that your meeting ({EVENT_NAME}) with {ORGANIZER} is on {EVENT_DATE_YYYY MMM D} at {EVENT_TIME_h:mma} {TIMEZONE}.";
|