@auxcode/auxta 1.3.29 → 1.3.31
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.
|
@@ -15,23 +15,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.EmailHelper = void 0;
|
|
16
16
|
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
17
|
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
18
|
-
const base64 = require('js-base64');
|
|
19
18
|
const AuxTA_1 = require("../../AuxTA");
|
|
19
|
+
const base64 = require('js-base64');
|
|
20
20
|
const MailComposer = require('nodemailer/lib/mail-composer');
|
|
21
21
|
class EmailHelper {
|
|
22
22
|
verifyEmail(from_name, from_email, subject, body, link = false) {
|
|
23
23
|
return __awaiter(this, void 0, void 0, function* () {
|
|
24
24
|
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
25
|
-
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
26
|
-
userId: "me",
|
|
27
|
-
maxResults: 3
|
|
28
|
-
});
|
|
29
|
-
const messagesIds = res.data.messages;
|
|
30
|
-
if (!messagesIds || messagesIds.length === 0) {
|
|
31
|
-
throw new Error('No messagesIds found.');
|
|
32
|
-
}
|
|
33
25
|
let timeoutCount = 12000;
|
|
34
26
|
while (timeoutCount <= 60000) {
|
|
27
|
+
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
28
|
+
userId: "me",
|
|
29
|
+
maxResults: 3
|
|
30
|
+
});
|
|
31
|
+
const messagesIds = res.data.messages;
|
|
32
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
33
|
+
throw new Error('No messagesIds found.');
|
|
34
|
+
}
|
|
35
35
|
for (const messageId of messagesIds) {
|
|
36
36
|
if (messageId.id) {
|
|
37
37
|
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
@@ -56,7 +56,11 @@ class EmailHelper {
|
|
|
56
56
|
});
|
|
57
57
|
if (link) {
|
|
58
58
|
const html_link = yield this.getUrl(message_body);
|
|
59
|
-
return {
|
|
59
|
+
return {
|
|
60
|
+
id: gmailResponse.data.id,
|
|
61
|
+
threadId: gmailResponse.data.threadId,
|
|
62
|
+
link: html_link
|
|
63
|
+
};
|
|
60
64
|
}
|
|
61
65
|
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
62
66
|
}
|
|
@@ -9,23 +9,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import log from "../../auxta/services/log.service";
|
|
11
11
|
import { AuxGoogleAuth } from "./AuxGoogleAuth";
|
|
12
|
-
const base64 = require('js-base64');
|
|
13
12
|
import { StepStatus } from "../../AuxTA";
|
|
13
|
+
const base64 = require('js-base64');
|
|
14
14
|
const MailComposer = require('nodemailer/lib/mail-composer');
|
|
15
15
|
export class EmailHelper {
|
|
16
16
|
verifyEmail(from_name, from_email, subject, body, link = false) {
|
|
17
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
yield AuxGoogleAuth.setup();
|
|
19
|
-
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
20
|
-
userId: "me",
|
|
21
|
-
maxResults: 3
|
|
22
|
-
});
|
|
23
|
-
const messagesIds = res.data.messages;
|
|
24
|
-
if (!messagesIds || messagesIds.length === 0) {
|
|
25
|
-
throw new Error('No messagesIds found.');
|
|
26
|
-
}
|
|
27
19
|
let timeoutCount = 12000;
|
|
28
20
|
while (timeoutCount <= 60000) {
|
|
21
|
+
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
22
|
+
userId: "me",
|
|
23
|
+
maxResults: 3
|
|
24
|
+
});
|
|
25
|
+
const messagesIds = res.data.messages;
|
|
26
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
27
|
+
throw new Error('No messagesIds found.');
|
|
28
|
+
}
|
|
29
29
|
for (const messageId of messagesIds) {
|
|
30
30
|
if (messageId.id) {
|
|
31
31
|
const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
@@ -50,7 +50,11 @@ export class EmailHelper {
|
|
|
50
50
|
});
|
|
51
51
|
if (link) {
|
|
52
52
|
const html_link = yield this.getUrl(message_body);
|
|
53
|
-
return {
|
|
53
|
+
return {
|
|
54
|
+
id: gmailResponse.data.id,
|
|
55
|
+
threadId: gmailResponse.data.threadId,
|
|
56
|
+
link: html_link
|
|
57
|
+
};
|
|
54
58
|
}
|
|
55
59
|
return { id: gmailResponse.data.id, threadId: gmailResponse.data.threadId, link: '' };
|
|
56
60
|
}
|