smtp/client: fix MessageStack type

This commit is contained in:
Zack Schuster 2022-05-06 17:37:16 -07:00
parent 8cf66b9adf
commit f0728717b9
1 changed files with 6 additions and 10 deletions

View File

@ -15,13 +15,9 @@ export type MessageCallback<T = Message | MessageHeaders> = <
export interface MessageStack {
callback: MessageCallback;
message: Message;
attachment: MessageAttachment;
text: string;
returnPath: string;
returnPath?: string;
from: string;
to: ReturnType<typeof addressparser>;
cc: string[];
bcc: string[];
}
export class SMTPClient {
@ -103,13 +99,13 @@ export class SMTPClient {
/* ø */
}
) {
const [{ address: from }] = addressparser(message.header.from);
const stack = {
const [{ address: from = '' }] = addressparser(message.header.from);
const stack: MessageStack = {
message,
to: [] as ReturnType<typeof addressparser>,
to: [],
from,
callback: callback.bind(this),
} as MessageStack;
};
const {
header: { to, cc, bcc, 'return-path': returnPath },
@ -139,7 +135,7 @@ export class SMTPClient {
const parsedReturnPath = addressparser(returnPath);
if (parsedReturnPath.length > 0) {
const [{ address: returnPathAddress }] = parsedReturnPath;
stack.returnPath = returnPathAddress as string;
stack.returnPath = returnPathAddress;
}
}