New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

byteskode-sms

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

byteskode-sms - npm Package Compare versions

Comparing version

to
0.2.0

30

lib/message.js

@@ -12,2 +12,3 @@ 'use strict';

var _ = require('lodash');
var async = require('async');
var phone = require('phone');

@@ -190,3 +191,3 @@ var e164 = require('e164');

next();
} catch (e) {

@@ -234,2 +235,29 @@ next(e);

/**
* @name updateStatus
* @description update message status from sms sent response or deliveries report
* @param {Object[]} responses [description]
* @param {Function} done a callback to invoke on success or error
*/
MessageSchema.statics.updateStatuses = function(responses, done) {
//normalize responses
responses = [].concat(responses);
//prepare updates
responses = _.map(responses, function(message) {
return function(_next) {
Message
.findByIdAndUpdate(message._id,
_.omit(message, '_id'), {
new: true
}, _next);
};
});
responses = _.compact(responses);
async.parallel(responses, done);
};
//-------------------------------------------------

@@ -236,0 +264,0 @@ // initialize & register Message model

24

lib/sms.js

@@ -168,3 +168,9 @@ 'use strict';

message.intermediateReport = _config.intermediateReport;
message.notifyUrl = _config.callbackUrl;
//deduce callback notify url of the message
message.notifyUrl = [
_config.callback.baseUrl,
_config.callback.deliveries,
'?_method=PUT',
'&source=', this._id
].join('');
message.notifyContentType = 'application/json';

@@ -273,17 +279,5 @@ message.callbackData = this._id;

function updateSMSMessages(sms, messages, next) {
function updateSMSMessages(sms, responses, next) {
//prepare update messages update
messages = _.map(messages, function(message) {
return function(_next) {
Message
.findByIdAndUpdate(message._id,
_.omit(message, '_id'), {
new: true
}, _next);
};
});
messages = _.compact(messages);
async.parallel(messages, function(error, updates) {
Message.updateStatuses(responses, function(error, updates) {
next(error, sms, updates);

@@ -290,0 +284,0 @@ });

{
"name": "byteskode-sms",
"version": "0.1.0",
"version": "0.2.0",
"description": "byteskode infobip sms with mongoose persistence support",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -62,3 +62,6 @@ byteskode-sms

password: <infobip_password>,
callbackUrl: '<full_qualified_callback_url>',
callback: {
baseUrl:'http://example.com', //without leading foward slash
deliveries: '/sms-deliveries',
},
intermediateReport:true,

@@ -65,0 +68,0 @@ models: {