@auxcode/auxta 1.3.23-beta.7 → 1.3.23-beta.9
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.
- package/build/cjs/macros/helpers/emailHelper.d.ts +2 -0
- package/build/cjs/macros/helpers/emailHelper.js +27 -10
- package/build/esm/macros/helpers/emailHelper.d.ts +2 -0
- package/build/esm/macros/helpers/emailHelper.js +27 -10
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { gmail_v1 } from "googleapis";
|
|
2
2
|
export declare class EmailHelper {
|
|
3
3
|
verifyEmail(from_name: string, from_email: string, subject: string, body: string, reply?: boolean, reply_body?: string): Promise<void>;
|
|
4
|
+
sendEmail(to: string, subject: string, body: string): Promise<void>;
|
|
4
5
|
private replyEmail;
|
|
6
|
+
private static send;
|
|
5
7
|
private getHeader;
|
|
6
8
|
private getBody;
|
|
7
9
|
private getCurrentUserEmail;
|
|
@@ -57,6 +57,7 @@ class EmailHelper {
|
|
|
57
57
|
if (reply && reply_body) {
|
|
58
58
|
yield this.replyEmail(gmailResponse.data.id.toString(), gmailResponse.data.threadId.toString(), reply_body);
|
|
59
59
|
}
|
|
60
|
+
return;
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
break;
|
|
@@ -68,6 +69,17 @@ class EmailHelper {
|
|
|
68
69
|
yield log_service_1.default.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
|
|
69
70
|
});
|
|
70
71
|
}
|
|
72
|
+
sendEmail(to, subject, body) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
const options = {
|
|
75
|
+
to: to,
|
|
76
|
+
from: this.getCurrentUserEmail(),
|
|
77
|
+
subject: subject,
|
|
78
|
+
html: body
|
|
79
|
+
};
|
|
80
|
+
yield EmailHelper.send(options);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
71
83
|
replyEmail(id, threadId, body) {
|
|
72
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
85
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
@@ -88,19 +100,24 @@ class EmailHelper {
|
|
|
88
100
|
inReplyTo: [message_messageID],
|
|
89
101
|
html: body
|
|
90
102
|
};
|
|
91
|
-
|
|
92
|
-
const message = yield mailComposer.compile().build();
|
|
93
|
-
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
94
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
95
|
-
userId: "me",
|
|
96
|
-
requestBody: {
|
|
97
|
-
threadId: threadId,
|
|
98
|
-
raw: encodeMessage
|
|
99
|
-
}
|
|
100
|
-
});
|
|
103
|
+
yield EmailHelper.send(options, threadId);
|
|
101
104
|
}
|
|
102
105
|
});
|
|
103
106
|
}
|
|
107
|
+
static send(options, threadId) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const mailComposer = new MailComposer(options);
|
|
110
|
+
const message = yield mailComposer.compile().build();
|
|
111
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
112
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
113
|
+
userId: "me",
|
|
114
|
+
requestBody: {
|
|
115
|
+
threadId: threadId,
|
|
116
|
+
raw: encodeMessage
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
104
121
|
getHeader(value, headers) {
|
|
105
122
|
for (const header of headers.data.payload.headers) {
|
|
106
123
|
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { gmail_v1 } from "googleapis";
|
|
2
2
|
export declare class EmailHelper {
|
|
3
3
|
verifyEmail(from_name: string, from_email: string, subject: string, body: string, reply?: boolean, reply_body?: string): Promise<void>;
|
|
4
|
+
sendEmail(to: string, subject: string, body: string): Promise<void>;
|
|
4
5
|
private replyEmail;
|
|
6
|
+
private static send;
|
|
5
7
|
private getHeader;
|
|
6
8
|
private getBody;
|
|
7
9
|
private getCurrentUserEmail;
|
|
@@ -51,6 +51,7 @@ export class EmailHelper {
|
|
|
51
51
|
if (reply && reply_body) {
|
|
52
52
|
yield this.replyEmail(gmailResponse.data.id.toString(), gmailResponse.data.threadId.toString(), reply_body);
|
|
53
53
|
}
|
|
54
|
+
return;
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
break;
|
|
@@ -62,6 +63,17 @@ export class EmailHelper {
|
|
|
62
63
|
yield log.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.FAILED);
|
|
63
64
|
});
|
|
64
65
|
}
|
|
66
|
+
sendEmail(to, subject, body) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
const options = {
|
|
69
|
+
to: to,
|
|
70
|
+
from: this.getCurrentUserEmail(),
|
|
71
|
+
subject: subject,
|
|
72
|
+
html: body
|
|
73
|
+
};
|
|
74
|
+
yield EmailHelper.send(options);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
65
77
|
replyEmail(id, threadId, body) {
|
|
66
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
79
|
yield AuxGoogleAuth.setup();
|
|
@@ -82,19 +94,24 @@ export class EmailHelper {
|
|
|
82
94
|
inReplyTo: [message_messageID],
|
|
83
95
|
html: body
|
|
84
96
|
};
|
|
85
|
-
|
|
86
|
-
const message = yield mailComposer.compile().build();
|
|
87
|
-
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
88
|
-
yield AuxGoogleAuth.gmailClient.users.messages.send({
|
|
89
|
-
userId: "me",
|
|
90
|
-
requestBody: {
|
|
91
|
-
threadId: threadId,
|
|
92
|
-
raw: encodeMessage
|
|
93
|
-
}
|
|
94
|
-
});
|
|
97
|
+
yield EmailHelper.send(options, threadId);
|
|
95
98
|
}
|
|
96
99
|
});
|
|
97
100
|
}
|
|
101
|
+
static send(options, threadId) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
const mailComposer = new MailComposer(options);
|
|
104
|
+
const message = yield mailComposer.compile().build();
|
|
105
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
106
|
+
yield AuxGoogleAuth.gmailClient.users.messages.send({
|
|
107
|
+
userId: "me",
|
|
108
|
+
requestBody: {
|
|
109
|
+
threadId: threadId,
|
|
110
|
+
raw: encodeMessage
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
98
115
|
getHeader(value, headers) {
|
|
99
116
|
for (const header of headers.data.payload.headers) {
|
|
100
117
|
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|