mirror of
https://github.com/IT4Change/gradido.git
synced 2026-03-01 12:44:43 +00:00
change return-type of execute method
This commit is contained in:
parent
3ea21a4708
commit
1536d092e9
@ -17,7 +17,7 @@ export interface SendEmailCommandParams {
|
|||||||
memo?: string;
|
memo?: string;
|
||||||
amount?: string;
|
amount?: string;
|
||||||
}
|
}
|
||||||
export class SendEmailCommand extends BaseCommand<{ success: boolean }> {
|
export class SendEmailCommand extends BaseCommand<Record<string, unknown> | boolean | null | Error> {
|
||||||
static readonly SEND_MAIL_COMMAND = 'SEND_MAIL_COMMAND';
|
static readonly SEND_MAIL_COMMAND = 'SEND_MAIL_COMMAND';
|
||||||
protected requiredFields: string[] = ['mailType', 'senderComUuid', 'senderGradidoId', 'receiverComUuid', 'receiverGradidoId'];
|
protected requiredFields: string[] = ['mailType', 'senderComUuid', 'senderGradidoId', 'receiverComUuid', 'receiverGradidoId'];
|
||||||
protected sendEmailCommandParams: SendEmailCommandParams;
|
protected sendEmailCommandParams: SendEmailCommandParams;
|
||||||
@ -39,9 +39,10 @@ export class SendEmailCommand extends BaseCommand<{ success: boolean }> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async execute(): Promise<{ success: boolean }> {
|
async execute(): Promise<Record<string, unknown> | boolean | null | Error> {
|
||||||
const methodLogger = createLogger(`execute`)
|
const methodLogger = createLogger(`execute`)
|
||||||
methodLogger.debug(`execute() sendEmailCommandParams=${JSON.stringify(this.sendEmailCommandParams)}`)
|
methodLogger.debug(`execute() sendEmailCommandParams=${JSON.stringify(this.sendEmailCommandParams)}`)
|
||||||
|
let result: Record<string, unknown> | boolean | null | Error;
|
||||||
if (!this.validate()) {
|
if (!this.validate()) {
|
||||||
throw new Error('Invalid command parameters');
|
throw new Error('Invalid command parameters');
|
||||||
}
|
}
|
||||||
@ -78,7 +79,7 @@ export class SendEmailCommand extends BaseCommand<{ success: boolean }> {
|
|||||||
methodLogger.debug(`emailParams=${JSON.stringify(emailParams)}`)
|
methodLogger.debug(`emailParams=${JSON.stringify(emailParams)}`)
|
||||||
switch(this.sendEmailCommandParams.mailType) {
|
switch(this.sendEmailCommandParams.mailType) {
|
||||||
case 'sendTransactionReceivedEmail':
|
case 'sendTransactionReceivedEmail':
|
||||||
await sendTransactionReceivedEmail(emailParams);
|
result = await sendTransactionReceivedEmail(emailParams);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error(`Unknown mail type: ${this.sendEmailCommandParams.mailType}`);
|
throw new Error(`Unknown mail type: ${this.sendEmailCommandParams.mailType}`);
|
||||||
@ -86,7 +87,7 @@ export class SendEmailCommand extends BaseCommand<{ success: boolean }> {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Example: const result = await emailService.sendEmail(this.params);
|
// Example: const result = await emailService.sendEmail(this.params);
|
||||||
return { success: true };
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
methodLogger.error('Error executing SendEmailCommand:', error);
|
methodLogger.error('Error executing SendEmailCommand:', error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user