fix(core): update
This commit is contained in:
@ -6,7 +6,7 @@ export interface IMailgunNotification {
|
||||
'Received-Spf': string;
|
||||
From: string;
|
||||
'Return-Path': string;
|
||||
'Arc-Seal': string[],
|
||||
'Arc-Seal': string[];
|
||||
'Delivered-To': string;
|
||||
'X-Google-Dkim-Signature': string;
|
||||
To: string;
|
||||
@ -43,5 +43,5 @@ export interface IMailgunNotification {
|
||||
'stripped-signature': string;
|
||||
|
||||
// Lossless specific
|
||||
"X-Lossless-Auth": string;
|
||||
}
|
||||
'X-Lossless-Auth': string;
|
||||
}
|
||||
|
@ -12,14 +12,12 @@ export class MailgunAccount {
|
||||
public async getRequest(routeArg: string, binaryArg: boolean = false) {
|
||||
let requestUrl = routeArg;
|
||||
const needsBaseUrlPrefix = !routeArg.startsWith('https://');
|
||||
needsBaseUrlPrefix ? requestUrl = `${this.baseUrl}${routeArg}` : null;
|
||||
needsBaseUrlPrefix ? (requestUrl = `${this.baseUrl}${routeArg}`) : null;
|
||||
console.log(requestUrl);
|
||||
const requestOptions: plugins.smartrequest.ISmartRequestOptions = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:${this.apiToken}`
|
||||
)}`,
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
@ -38,9 +36,7 @@ export class MailgunAccount {
|
||||
requestUrl,
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(
|
||||
`api:${this.apiToken}`
|
||||
)}`
|
||||
Authorization: `Basic ${plugins.smartstring.base64.encode(`api:${this.apiToken}`)}`
|
||||
}
|
||||
},
|
||||
formFields
|
||||
@ -51,7 +47,11 @@ export class MailgunAccount {
|
||||
/**
|
||||
* sends a SmartMail
|
||||
*/
|
||||
public async sendSmartMail(smartmailArg: plugins.smartmail.Smartmail<interfaces.IMailgunMessage>, toArg: string, dataArg = {}) {
|
||||
public async sendSmartMail(
|
||||
smartmailArg: plugins.smartmail.Smartmail<interfaces.IMailgunMessage>,
|
||||
toArg: string,
|
||||
dataArg = {}
|
||||
) {
|
||||
const domain = smartmailArg.options.from.split('@')[1].replace('>', '');
|
||||
const formFields: plugins.smartrequest.IFormField[] = [
|
||||
{
|
||||
@ -105,7 +105,7 @@ export class MailgunAccount {
|
||||
const responseBody: interfaces.IMailgunMessage = response.body;
|
||||
const smartmail = new plugins.smartmail.Smartmail<interfaces.IMailgunMessage>({
|
||||
from: responseBody.From,
|
||||
body: responseBody["body-html"],
|
||||
body: responseBody['body-html'],
|
||||
subject: responseBody.Subject,
|
||||
creationObjectRef: responseBody
|
||||
});
|
||||
@ -115,17 +115,19 @@ export class MailgunAccount {
|
||||
for (const attachmentInfo of responseBody.attachments) {
|
||||
const attachmentName = attachmentInfo.name;
|
||||
const attachmentContents = await this.getRequest(attachmentInfo.url, true);
|
||||
smartmail.addAttachment(new plugins.smartfile.Smartfile({
|
||||
path: `./${attachmentName}`,
|
||||
base: `./${attachmentName}`,
|
||||
contentBuffer: attachmentContents.body
|
||||
}));
|
||||
smartmail.addAttachment(
|
||||
new plugins.smartfile.Smartfile({
|
||||
path: `./${attachmentName}`,
|
||||
base: `./${attachmentName}`,
|
||||
contentBuffer: attachmentContents.body
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return smartmail;
|
||||
}
|
||||
|
||||
|
||||
public async retrieveSmartMailFromNotifyPayload(notifyPayloadArg: any) {
|
||||
return await this.retrieveSmartMailFromMessageUrl(notifyPayloadArg['message-url']);
|
||||
}
|
||||
|
Reference in New Issue
Block a user