40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import type { SzPlatformClient } from '../classes.platformclient.js';
|
|
import * as plugins from '../plugins.js';
|
|
|
|
import { logger } from '../logger.js';
|
|
|
|
export class SzEmailConnector {
|
|
public platformClientRef: SzPlatformClient;
|
|
|
|
constructor(platformClientRefArg: SzPlatformClient) {
|
|
this.platformClientRef = platformClientRefArg;
|
|
}
|
|
|
|
public async sendEmail(
|
|
optionsArg: plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail['request']
|
|
) {
|
|
if (this.platformClientRef.debugMode) {
|
|
logger.log('info', `sent email with subject ${optionsArg.title} to ${optionsArg.to}
|
|
body:
|
|
${optionsArg.body.split('\n').map(line => ` ${line}`).join('\n')}
|
|
|
|
`);
|
|
}
|
|
|
|
if (this.platformClientRef.debugMode) {
|
|
return;
|
|
}
|
|
|
|
const typedRequest =
|
|
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.mta.IRequest_SendEmail>(
|
|
'sendEmail'
|
|
);
|
|
const response = await typedRequest.fire(optionsArg);
|
|
|
|
}
|
|
|
|
public async sendNotification(optionsArg: { toArg: string; subject: string; text: string }) {}
|
|
|
|
public async sendActionLink(optionsArg: { toArg: string; subject: string; text: string }) {}
|
|
}
|