ztechno_core 0.0.58 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
1
- import { MailOptionsHtml, MailOptionsText, MailResponse, MailServiceOptions } from './typings/mail_types';
1
+ import { MailOptions, MailOptionsHtml, MailOptionsText, MailResponse, MailServiceOptions } from './typings/mail_types';
2
2
  export declare class ZMailService {
3
3
  private opt;
4
4
  protected get sql(): import('./sql_service').ZSqlService;
5
5
  constructor(opt: MailServiceOptions);
6
- send(mailOpts: MailOptionsText | MailOptionsHtml): Promise<MailResponse>;
6
+ protected allowSend(mailOpts: MailOptions): Promise<boolean>;
7
+ send(mailOpts: MailOptionsText | MailOptionsHtml): Promise<MailResponse | undefined>;
7
8
  }
@@ -14,7 +14,14 @@ class ZMailService {
14
14
  constructor(opt) {
15
15
  this.opt = opt;
16
16
  }
17
- send(mailOpts) {
17
+ async allowSend(mailOpts) {
18
+ return true;
19
+ }
20
+ async send(mailOpts) {
21
+ const allow = await this.allowSend(mailOpts);
22
+ if (!allow) {
23
+ return;
24
+ }
18
25
  const mailTransporter = nodemailer_1.default.createTransport({
19
26
  service: 'gmail',
20
27
  auth: this.opt.auth,
@@ -28,7 +35,7 @@ class ZMailService {
28
35
  dkim: this.opt.dkim ?? mailOpts.dkim,
29
36
  priority: mailOpts.priority,
30
37
  };
31
- return new Promise((resolve, reject) => {
38
+ return await new Promise((resolve, reject) => {
32
39
  mailTransporter.sendMail(mailDetails, function (err, data) {
33
40
  return err ? reject(err) : resolve(data);
34
41
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztechno_core",
3
- "version": "0.0.58",
3
+ "version": "0.0.59",
4
4
  "description": "Core files for ztechno framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",