Compare commits

...

2 Commits

Author SHA1 Message Date
Zack Schuster b3935e759e smtp/client: remove unnecessary callback invocation 2020-11-24 17:41:13 -08:00
Zack Schuster d1fca9efe3 smtp/connection: use WeakSet for greylist tracking 2020-11-24 16:56:08 -08:00
2 changed files with 4 additions and 10 deletions

View File

@ -63,9 +63,6 @@ export class SMTPClient {
} }
this.queue.push(stack); this.queue.push(stack);
this._poll(); this._poll();
if (this.queue.every((x) => x !== stack)) {
callback(null, message);
}
} else { } else {
callback(new Error(why), msg); callback(new Error(why), msg);
} }

View File

@ -120,10 +120,7 @@ export class SMTPConnection extends EventEmitter {
protected tls: boolean | SMTPSocketOptions = false; protected tls: boolean | SMTPSocketOptions = false;
protected port: number; protected port: number;
private greylistResponseTracker = new WeakMap< private greylistResponseTracker = new WeakSet<(...rest: any[]) => void>();
(...rest: any[]) => void,
boolean
>();
/** /**
* SMTP class written using python's (2.7) smtplib.py as a base. * SMTP class written using python's (2.7) smtplib.py as a base.
@ -411,9 +408,9 @@ export class SMTPConnection extends EventEmitter {
} else if ( } else if (
(code === 450 || code === 451) && (code === 450 || code === 451) &&
msg.message.toLowerCase().includes('greylist') && msg.message.toLowerCase().includes('greylist') &&
this.greylistResponseTracker.get(response) === false this.greylistResponseTracker.has(response) === false
) { ) {
this.greylistResponseTracker.set(response, true); this.greylistResponseTracker.add(response);
setTimeout(() => { setTimeout(() => {
this.send(cmd + CRLF, response); this.send(cmd + CRLF, response);
}, GREYLIST_DELAY); }, GREYLIST_DELAY);
@ -435,7 +432,7 @@ export class SMTPConnection extends EventEmitter {
} }
}; };
this.greylistResponseTracker.set(response, false); this.greylistResponseTracker.delete(response);
this.send(cmd + CRLF, response); this.send(cmd + CRLF, response);
} }