feat: update official docker images

This commit is contained in:
prafull-opensignlabs
2024-08-02 12:46:01 +05:30
parent 375dc86f0a
commit d4e0f05cef
16 changed files with 227 additions and 157 deletions
@@ -28,7 +28,7 @@ const refreshAccessToken = async refreshToken => {
// Function to create a raw email message
const makeEmail = async (to, from, subject, html, url, pdfName) => {
const protocol = new URL(process.env.SERVER_URL);
const publicUrl = new URL(process.env.SERVER_URL);
const htmlContent = html;
const boundary = 'boundary_' + Date.now().toString(16);
let str;
@@ -37,7 +37,7 @@ const makeEmail = async (to, from, subject, html, url, pdfName) => {
let Pdf = fs.createWriteStream('test.pdf');
const writeToLocalDisk = () => {
return new Promise((resolve, reject) => {
if (useLocal !== 'true' && protocol.hostname !== 'localhost') {
if (useLocal !== 'true' && publicUrl.protocol !== 'http:') {
https.get(url, async function (response) {
response.pipe(Pdf);
response.on('end', () => resolve('success'));
@@ -7,7 +7,8 @@ import { smtpenable, smtpsecure, updateMailCount, useLocal } from '../../Utils.j
import sendMailGmailProvider from './sendMailGmailProvider.js';
import { createTransport } from 'nodemailer';
async function sendMailProvider(req) {
const protocol = new URL(process.env.SERVER_URL);
const publicUrl = new URL(process.env.SERVER_URL);
const mailgunApiKey = process.env.MAILGUN_API_KEY;
try {
let transporterSMTP;
let mailgunClient;
@@ -23,18 +24,17 @@ async function sendMailProvider(req) {
},
});
} else {
const mailgun = new Mailgun(formData);
mailgunClient = mailgun.client({
username: 'api',
key: process.env.MAILGUN_API_KEY,
});
mailgunDomain = process.env.MAILGUN_DOMAIN;
if (mailgunApiKey) {
const mailgun = new Mailgun(formData);
mailgunClient = mailgun.client({ username: 'api', key: mailgunApiKey });
mailgunDomain = process.env.MAILGUN_DOMAIN;
}
}
if (req.params.url) {
let Pdf = fs.createWriteStream('test.pdf');
const writeToLocalDisk = () => {
return new Promise((resolve, reject) => {
if (useLocal !== 'true' && protocol.hostname !== 'localhost') {
if (useLocal !== 'true' && publicUrl.protocol !== 'http:') {
https.get(req.params.url, async function (response) {
response.pipe(Pdf);
response.on('end', () => resolve('success'));
@@ -108,20 +108,27 @@ async function sendMailProvider(req) {
return { status: 'success' };
}
} else {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
if (req.params?.extUserId) {
await updateMailCount(req.params.extUserId);
if (mailgunApiKey) {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
if (req.params?.extUserId) {
await updateMailCount(req.params.extUserId);
}
try {
fs.unlinkSync('./exports/certificate.pdf');
} catch (err) {
console.log('Err in unlink certificate sendmailv3');
}
return { status: 'success' };
}
} else {
try {
fs.unlinkSync('./exports/certificate.pdf');
} catch (err) {
console.log('Err in unlink certificate sendmailv3');
}
return {
status: 'success',
};
return { status: 'error' };
}
}
}
@@ -147,13 +154,17 @@ async function sendMailProvider(req) {
return { status: 'success' };
}
} else {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
if (req.params?.extUserId) {
await updateMailCount(req.params.extUserId);
if (mailgunApiKey) {
const res = await mailgunClient.messages.create(mailgunDomain, messageParams);
console.log('Res ', res);
if (res.status === 200) {
if (req.params?.extUserId) {
await updateMailCount(req.params.extUserId);
}
return { status: 'success' };
}
return { status: 'success' };
} else {
return { status: 'error' };
}
}
}