nodebb-plugin-emailer-mailjet
Advanced tools
Comparing version 0.0.4 to 1.0.0
@@ -1,11 +0,8 @@ | ||
var fs = require('fs'), | ||
path = require('path'), | ||
var winston = module.parent.require('winston'); | ||
var Meta = module.parent.require('./meta'); | ||
winston = module.parent.require('winston'), | ||
Meta = module.parent.require('./meta'), | ||
var Emailer = {}; | ||
var Mailjet = require('node-mailjet'); | ||
var server; | ||
Emailer = {}, | ||
Mailjet = require('mailjet-sendemail'), | ||
server; | ||
Emailer.init = function(params, callback) { | ||
@@ -18,5 +15,3 @@ function render(req, res, next) { | ||
if (!err && settings && settings.apiKey && settings.secretKey) { | ||
server = new Mailjet(settings.apiKey, | ||
settings.secretKey | ||
); | ||
server = Mailjet.connect(settings.apiKey, settings.secretKey); | ||
} else { | ||
@@ -27,3 +22,3 @@ winston.error('[plugins/emailer-mailjet] API key or SECRET Key not set!'); | ||
params.router.get('/admin/plugins/emailer-mailjet', params.middleware.admin.buildHeader, render); | ||
params.router.get('/admin/plugins/emailer-mailjet', params.middleware.admin.buildHeader, render); | ||
params.router.get('/api/admin/plugins/emailer-mailjet', render); | ||
@@ -34,14 +29,32 @@ | ||
Emailer.send = function(data) { | ||
Emailer.send = function(data, callback) { | ||
if (!server) { | ||
return winston.error('[emailer.mailjet] Mailjet is not set up properly!') | ||
winston.error('[emailer.mailjet] Mailjet is not set up properly!') | ||
return callback(null, data); | ||
} | ||
server.sendContent(data.from, | ||
data.to, | ||
data.subject, | ||
'html', | ||
data.html | ||
); | ||
var sendEmail = server.post('send'); | ||
var emailData = { | ||
'FromEmail': data.from, | ||
'FromName': data.from_name, | ||
'Subject': data.subject, | ||
'Text-part': data.plaintext, | ||
'Html-part': data.html, | ||
'Recipients': [{ | ||
'Email': data.to | ||
}] | ||
}; | ||
sendEmail | ||
.request(emailData) | ||
.on('success', handleSuccess) | ||
.on('error', handleError); | ||
function handleSuccess(data) { | ||
callback(null, data); | ||
} | ||
function handleError(err) { | ||
callback(err); | ||
} | ||
}; | ||
@@ -61,2 +74,2 @@ | ||
module.exports = Emailer; | ||
module.exports = Emailer; |
{ | ||
"name": "nodebb-plugin-emailer-mailjet", | ||
"version": "0.0.4", | ||
"description": "An emailer plugin for NodeBB using Mailjet as a third party service", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet" | ||
}, | ||
"keywords": [ | ||
"nodebb", | ||
"plugin", | ||
"emailer", | ||
"mailjet" | ||
], | ||
"author": "Pichalite <pichalite.com@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet/issues" | ||
}, | ||
"homepage": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet", | ||
"dependencies": { | ||
"path": "~0.4.9", | ||
"mailjet-sendemail": "~1.1.4" | ||
}, | ||
"nbbpm": { | ||
"compatibility": "^0.6.0" | ||
} | ||
"name": "nodebb-plugin-emailer-mailjet", | ||
"version": "1.0.0", | ||
"description": "An emailer plugin for NodeBB using Mailjet as a third party service", | ||
"main": "index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet" | ||
}, | ||
"keywords": [ | ||
"nodebb", | ||
"plugin", | ||
"emailer", | ||
"mailjet" | ||
], | ||
"author": "Pichalite <pichalite.com@gmail.com>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet/issues" | ||
}, | ||
"homepage": "https://github.com/pichalite/nodebb-plugin-emailer-mailjet", | ||
"dependencies": { | ||
"node-mailjet": "~1.1.0" | ||
}, | ||
"nbbpm": { | ||
"compatibility": "^1.0.0" | ||
} | ||
} |
@@ -9,6 +9,6 @@ { | ||
,"hooks": [ | ||
{ "hook": "action:email.send", "method": "send" }, | ||
{ "hook": "filter:email.send", "method": "send" }, | ||
{ "hook": "filter:admin.header.build", "method": "admin.menu" }, | ||
{ "hook": "static:app.load", "method": "init" } | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
5162
1
71
0
0
+ Addednode-mailjet@~1.1.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedassertion-error@1.1.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedchai@3.5.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddeep-eql@0.1.3(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addednode-mailjet@1.1.0(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpsl@1.15.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@4.0.06.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addedtype-detect@0.1.11.0.0(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedmailjet-sendemail@~1.1.4
- Removedpath@~0.4.9
- Removedmailjet-sendemail@1.1.4(transitive)
- Removedpath@0.4.10(transitive)