mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-20 22:52:39 +02:00
feat: update official docker images
This commit is contained in:
@@ -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' };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user