diff --git a/packages/connector-aliyun-dm/src/index.ts b/packages/connector-aliyun-dm/src/index.ts index 8cf3a2265..470de315e 100644 --- a/packages/connector-aliyun-dm/src/index.ts +++ b/packages/connector-aliyun-dm/src/index.ts @@ -37,7 +37,7 @@ export default class AliyunDmConnector implements EmailConnector { const emailConfig = await this.getConfig(this.metadata.id); await this.validateConfig(emailConfig); - return this.sendMessageCore(address, type, data, emailConfig); + return this.sendMessageBy(emailConfig, address, type, data); }; public sendTestMessage: EmailSendMessageFunction = async (address, type, data, config) => { @@ -47,14 +47,14 @@ export default class AliyunDmConnector implements EmailConnector { await this.validateConfig(config); - return this.sendMessageCore(address, type, data, config as AliyunDmConfig); + return this.sendMessageBy(config as AliyunDmConfig, address, type, data); }; - private readonly sendMessageCore = async ( + private readonly sendMessageBy = async ( + config: AliyunDmConfig, address: string, type: keyof EmailMessageTypes, - data: EmailMessageTypes[typeof type], - config: AliyunDmConfig + data: EmailMessageTypes[typeof type] ) => { const { accessKeyId, accessKeySecret, accountName, fromAlias, templates } = config; const template = templates.find((template) => template.usageType === type); diff --git a/packages/connector-aliyun-sms/src/index.ts b/packages/connector-aliyun-sms/src/index.ts index 5f67e9e36..de19714a5 100644 --- a/packages/connector-aliyun-sms/src/index.ts +++ b/packages/connector-aliyun-sms/src/index.ts @@ -32,7 +32,7 @@ export default class AliyunSmsConnector implements SmsConnector { const smsConfig = await this.getConfig(this.metadata.id); await this.validateConfig(smsConfig); - return this.sendMessageCore(phone, type, { code }, smsConfig); + return this.sendMessageBy(smsConfig, phone, type, { code }); }; public sendTestMessage: SmsSendMessageFunction = async (phone, type, { code }, config) => { @@ -42,14 +42,14 @@ export default class AliyunSmsConnector implements SmsConnector { await this.validateConfig(config); - return this.sendMessageCore(phone, type, { code }, config as AliyunSmsConfig); + return this.sendMessageBy(config as AliyunSmsConfig, phone, type, { code }); }; - private readonly sendMessageCore = async ( + private readonly sendMessageBy = async ( + config: AliyunSmsConfig, phone: string, type: keyof SmsMessageTypes, - data: SmsMessageTypes[typeof type], - config: AliyunSmsConfig + data: SmsMessageTypes[typeof type] ) => { const { accessKeyId, accessKeySecret, signName, templates } = config; const template = templates.find(({ usageType }) => usageType === type); diff --git a/packages/connector-sendgrid-mail/src/index.ts b/packages/connector-sendgrid-mail/src/index.ts index e4ef7091f..6a40de97e 100644 --- a/packages/connector-sendgrid-mail/src/index.ts +++ b/packages/connector-sendgrid-mail/src/index.ts @@ -38,7 +38,7 @@ export default class SendGridMailConnector implements EmailConnector { const emailConfig = await this.getConfig(this.metadata.id); await this.validateConfig(emailConfig); - return this.sendMessageCore(address, type, data, emailConfig); + return this.sendMessageBy(emailConfig, address, type, data); }; public sendTestMessage: EmailSendMessageFunction = async (address, type, data, config) => { @@ -48,14 +48,14 @@ export default class SendGridMailConnector implements EmailConnector { await this.validateConfig(config); - return this.sendMessageCore(address, type, data, config as SendGridMailConfig); + return this.sendMessageBy(config as SendGridMailConfig, address, type, data); }; - private readonly sendMessageCore = async ( + private readonly sendMessageBy = async ( + config: SendGridMailConfig, address: string, type: keyof EmailMessageTypes, - data: EmailMessageTypes[typeof type], - config: SendGridMailConfig + data: EmailMessageTypes[typeof type] ) => { const { apiKey, fromEmail, fromName, templates } = config; const template = templates.find((template) => template.usageType === type); diff --git a/packages/connector-smtp/src/index.ts b/packages/connector-smtp/src/index.ts index 68a2ef772..7ed40532c 100644 --- a/packages/connector-smtp/src/index.ts +++ b/packages/connector-smtp/src/index.ts @@ -32,7 +32,7 @@ export default class SmtpConnector implements EmailConnector { const emailConfig = await this.getConfig(this.metadata.id); await this.validateConfig(emailConfig); - return this.sendMessageCore(address, type, data, emailConfig); + return this.sendMessageBy(emailConfig, address, type, data); }; public sendTestMessage: EmailSendMessageFunction = async (address, type, data, config) => { @@ -42,14 +42,14 @@ export default class SmtpConnector implements EmailConnector { await this.validateConfig(config); - return this.sendMessageCore(address, type, data, config as SmtpConfig); + return this.sendMessageBy(config as SmtpConfig, address, type, data); }; - private readonly sendMessageCore = async ( + private readonly sendMessageBy = async ( + config: SmtpConfig, address: string, type: keyof EmailMessageTypes, - data: EmailMessageTypes[typeof type], - config: SmtpConfig + data: EmailMessageTypes[typeof type] ) => { const { host, port, username, password, fromEmail, replyTo, templates } = config; const template = templates.find((template) => template.usageType === type); diff --git a/packages/connector-twilio-sms/src/index.ts b/packages/connector-twilio-sms/src/index.ts index 88870bfe9..c17b4fb22 100644 --- a/packages/connector-twilio-sms/src/index.ts +++ b/packages/connector-twilio-sms/src/index.ts @@ -31,7 +31,7 @@ export default class TwilioSmsConnector implements SmsConnector { const smsConfig = await this.getConfig(this.metadata.id); await this.validateConfig(smsConfig); - return this.sendMessageCore(address, type, data, smsConfig); + return this.sendMessageBy(smsConfig, address, type, data); }; public sendTestMessage: SmsSendMessageFunction = async (address, type, data, config) => { @@ -41,14 +41,14 @@ export default class TwilioSmsConnector implements SmsConnector { await this.validateConfig(config); - return this.sendMessageCore(address, type, data, config as TwilioSmsConfig); + return this.sendMessageBy(config as TwilioSmsConfig, address, type, data); }; - private readonly sendMessageCore = async ( + private readonly sendMessageBy = async ( + config: TwilioSmsConfig, phone: string, type: keyof SmsMessageTypes, - data: SmsMessageTypes[typeof type], - config: TwilioSmsConfig + data: SmsMessageTypes[typeof type] ) => { const { accountSID, authToken, fromMessagingServiceSID, templates } = config; const template = templates.find((template) => template.usageType === type);