Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
SG.SetRootDir(__dirname);

/**
* Export the connector
*/
var loopback = require('loopback');
var PushConnector = require('./lib/push-connector');
exports = module.exports = PushConnector;
var SG = require('strong-globalize');
SG.SetRootDir(__dirname);

/**
* Export two model classes as properties
Expand Down
11 changes: 6 additions & 5 deletions lib/payload.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
var g = SG();

// this file has no tests so avoid refactor and ignore jshint for now
/*jshint ignore: start */
var serial,__hasProp = {}.hasOwnProperty;
var SG = require('strong-globalize');
var g = SG();

serial = 0;

Expand All @@ -16,7 +17,7 @@ Payload.prototype.locale_format = /^[a-z]{2}_[A-Z]{2}$/;
function Payload(data) {
var key, prefix, subkey, sum, type, value, _i, _len, _ref, _ref1;
if (typeof data !== 'object') {
throw new Error(g.t('Invalid payload'));
throw new Error(g.f('Invalid payload'));
}
this.id = serial++;
this.compiled = false;
Expand All @@ -28,7 +29,7 @@ function Payload(data) {
if (!__hasProp.call(data, key)) continue;
value = data[key];
if (typeof key !== 'string' || key.length === 0) {
throw new Error(g.t("Invalid field (empty)"));
throw new Error(g.f("Invalid field (empty)"));
}
if (typeof value !== 'string') {
throw new Error(g.f("Invalid value for `%s`", key));
Expand Down Expand Up @@ -68,7 +69,7 @@ function Payload(data) {
}).call(this)).length;
}
if (sum === 0) {
throw new Error(g.t('Empty payload'));
throw new Error(g.f('Empty payload'));
}
}

Expand Down
5 changes: 3 additions & 2 deletions lib/providers/apns.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
var g = SG();

var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
var debug = require('debug')('loopback:component:push:provider:apns');
var apn = require('apn');
var SG = require('strong-globalize');
var g = SG();

function ApnsProvider(pushSettings) {
pushSettings = pushSettings || {};
Expand Down
5 changes: 3 additions & 2 deletions lib/providers/gcm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
var g = SG();

var inherits = require('util').inherits;
var extend = require('util')._extend;
var EventEmitter = require('events').EventEmitter;
var gcm = require('node-gcm');
var debug = require('debug')('loopback:component:push:provider:gcm');
var SG = require('strong-globalize');
var g = SG();

function GcmProvider(pushSettings) {
var settings = pushSettings.gcm || {};
Expand Down
11 changes: 6 additions & 5 deletions lib/push-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// This file is licensed under the Artistic License 2.0.
// License text available at https://opensource.org/licenses/Artistic-2.0

var SG = require('strong-globalize');
var g = SG();

var assert = require('assert');
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
Expand All @@ -12,8 +15,6 @@ var providers = require('./providers');
var loopback = require('loopback');
var NodeCache = require('node-cache');
var debug = require('debug')('loopback:component:push:push-manager');
var SG = require('strong-globalize');
var g = SG();

var Installation = require('../models').Installation;
var Notification = require('../models').Notification;
Expand Down Expand Up @@ -279,7 +280,7 @@ PushManager.prototype.notify = function(installation, notification, cb) {
assert(cb, 'callback should be defined');

if(!(typeof notification === 'object' && notification)) {
return cb(new Error(g.t('notification must be an object')));
return cb(new Error(g.f('notification must be an object')));
}

var appId = installation.appId;
Expand Down Expand Up @@ -329,11 +330,11 @@ PushManager.prototype.notifyMany = function(appId, deviceType, deviceTokens, not
assert(cb, 'callback should be defined');

if(!(typeof notification === 'object' && notification)) {
return cb(new Error(g.t('notification must be an object')));
return cb(new Error(g.f('notification must be an object')));
}

if(!(Array.isArray(deviceTokens) && deviceTokens.length > 0)) {
return cb(new Error(g.t('deviceTokens must be an array')));
return cb(new Error(g.f('deviceTokens must be an array')));
}

// Normalize the notification from a plain object
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"mpns": "^2.1.0",
"node-cache": "^3.2.1",
"node-gcm": "^0.14.0",
"strong-globalize": "^2.5.6"
"strong-globalize": "^2.5.8"
},
"devDependencies": {
"chai": "^2.3.0",
Expand Down