fix(platformclient): Refactor debug mode checks in SzPlatformClient connectors
This commit is contained in:
@ -11,6 +11,15 @@ export class SzLetterConnector {
|
||||
public async sendLetter(
|
||||
optionsArg: plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter['request']
|
||||
) {
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
console.log('sendLetter', optionsArg);
|
||||
}
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typedRequest =
|
||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.letter.IRequest_SendLetter>(
|
||||
'sendLetter'
|
||||
|
34
ts/email/classes.pushnotificationconnector.ts
Normal file
34
ts/email/classes.pushnotificationconnector.ts
Normal file
@ -0,0 +1,34 @@
|
||||
import type { SzPlatformClient } from '../classes.platformclient.js';
|
||||
import * as plugins from '../plugins.js';
|
||||
|
||||
export class SzPushNotificationConnector {
|
||||
public platformClientRef: SzPlatformClient;
|
||||
|
||||
constructor(platformClientRefArg: SzPlatformClient) {
|
||||
this.platformClientRef = platformClientRefArg;
|
||||
}
|
||||
|
||||
public async sendPushNotification(
|
||||
optionsArg: plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification['request']
|
||||
) {
|
||||
if (this.platformClientRef.debugMode) {
|
||||
console.log('sendPushNotification', optionsArg);
|
||||
}
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typedRequest =
|
||||
this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.pushnotification.IRequest_SendPushNotification>(
|
||||
'sendPushNotification'
|
||||
);
|
||||
const response = await typedRequest.fire(optionsArg);
|
||||
|
||||
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
||||
console.log('sendPushNotification response', response);
|
||||
}
|
||||
|
||||
return response.status;
|
||||
}
|
||||
}
|
@ -10,13 +10,17 @@ export class SzSmsConnector {
|
||||
}
|
||||
|
||||
public async sendSms(messageArg: plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms['request']) {
|
||||
if (process.env.SERVEZONE_PLATFORMCLIENT_DEBUG) {
|
||||
if (this.platformClientRef.debugMode) {
|
||||
logger.log('info', `sent sms to ${messageArg.toNumber}}
|
||||
body:
|
||||
${messageArg.messageText.split('\n').map(line => ` ${line}`).join('\n')}
|
||||
|
||||
`);
|
||||
}
|
||||
|
||||
if (this.platformClientRef.debugMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
const typedrequest = this.platformClientRef.typedsocket.createTypedRequest<plugins.servezoneInterfaces.platformservice.sms.IRequest_SendSms>(
|
||||
'sendSms'
|
||||
|
Reference in New Issue
Block a user