@auxcode/auxta 1.3.23-beta.7 → 1.3.23-beta.8
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 +26 -10
- package/build/esm/macros/helpers/emailHelper.d.ts +2 -0
- package/build/esm/macros/helpers/emailHelper.js +26 -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;
|
|
@@ -68,6 +68,17 @@ class EmailHelper {
|
|
|
68
68
|
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
69
|
});
|
|
70
70
|
}
|
|
71
|
+
sendEmail(to, subject, body) {
|
|
72
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
73
|
+
const options = {
|
|
74
|
+
to: to,
|
|
75
|
+
from: this.getCurrentUserEmail(),
|
|
76
|
+
subject: subject,
|
|
77
|
+
html: body
|
|
78
|
+
};
|
|
79
|
+
yield EmailHelper.send(options);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
71
82
|
replyEmail(id, threadId, body) {
|
|
72
83
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
84
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
@@ -88,19 +99,24 @@ class EmailHelper {
|
|
|
88
99
|
inReplyTo: [message_messageID],
|
|
89
100
|
html: body
|
|
90
101
|
};
|
|
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
|
-
});
|
|
102
|
+
yield EmailHelper.send(options, threadId);
|
|
101
103
|
}
|
|
102
104
|
});
|
|
103
105
|
}
|
|
106
|
+
static send(options, threadId) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const mailComposer = new MailComposer(options);
|
|
109
|
+
const message = yield mailComposer.compile().build();
|
|
110
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
111
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.send({
|
|
112
|
+
userId: "me",
|
|
113
|
+
requestBody: {
|
|
114
|
+
threadId: threadId,
|
|
115
|
+
raw: encodeMessage
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
104
120
|
getHeader(value, headers) {
|
|
105
121
|
for (const header of headers.data.payload.headers) {
|
|
106
122
|
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;
|
|
@@ -62,6 +62,17 @@ export class EmailHelper {
|
|
|
62
62
|
yield log.push('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.FAILED);
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
+
sendEmail(to, subject, body) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const options = {
|
|
68
|
+
to: to,
|
|
69
|
+
from: this.getCurrentUserEmail(),
|
|
70
|
+
subject: subject,
|
|
71
|
+
html: body
|
|
72
|
+
};
|
|
73
|
+
yield EmailHelper.send(options);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
65
76
|
replyEmail(id, threadId, body) {
|
|
66
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
67
78
|
yield AuxGoogleAuth.setup();
|
|
@@ -82,19 +93,24 @@ export class EmailHelper {
|
|
|
82
93
|
inReplyTo: [message_messageID],
|
|
83
94
|
html: body
|
|
84
95
|
};
|
|
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
|
-
});
|
|
96
|
+
yield EmailHelper.send(options, threadId);
|
|
95
97
|
}
|
|
96
98
|
});
|
|
97
99
|
}
|
|
100
|
+
static send(options, threadId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
const mailComposer = new MailComposer(options);
|
|
103
|
+
const message = yield mailComposer.compile().build();
|
|
104
|
+
const encodeMessage = Buffer.from(message).toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
105
|
+
yield AuxGoogleAuth.gmailClient.users.messages.send({
|
|
106
|
+
userId: "me",
|
|
107
|
+
requestBody: {
|
|
108
|
+
threadId: threadId,
|
|
109
|
+
raw: encodeMessage
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
98
114
|
getHeader(value, headers) {
|
|
99
115
|
for (const header of headers.data.payload.headers) {
|
|
100
116
|
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|