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

airbits-notif-utils

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

airbits-notif-utils - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

82

index.js
var MongoRepository = require("airbits-data").MongoRepository;
const http = require('http');
var rp = require('request-promise');
exports.NotificationManager = function(restheartUser, restheartPass, restheartUrl, dbName, fsmkey, fsmApiUrl){
exports.NotificationManager = function (restheartUser, restheartPass, restheartUrl, dbName, fsmkey, fsmApiUrl) {
var userRepo = new MongoRepository(restheartUser, restheartPass, restheartUrl, dbName, "users");

@@ -10,13 +10,24 @@ const firebaseKey = fsmkey;

this.registerUserNotificationId = (userId, subscriptionId) =>{
return new Promise((resolve, reject)=>{
this.registerUserNotificationId = (userId, subscriptionId) => {
return new Promise((resolve, reject) => {
console.log("registrando notif Id: " + subscriptionId);
const subId = {"subscriptionId": subscriptionId};
userRepo.update(userId,subId)
.then((result)=>{
sendNotification(subscriptionId);
resolve({"message": "subscription registered"});
const subId = {
"subscriptionId": subscriptionId
};
userRepo.update(userId, subId)
.then((result) => {
console.log("todo tranka la actualizacion de la db. ahora sending notif");
sendNotification(subscriptionId)
.then((notifRes) => {
console.log("listo la notif!")
resolve({
"message": "subscription registered"
});
})
.catch((err) => {
reject(err);
});
})
.catch((err)=>{
.catch((err) => {
reject(err);

@@ -27,23 +38,36 @@ });

function sendNotification(subscriptionId){
const postOptions = {
host: 'https://fcm.googleapis.com',
port: '80',
path: '/fcm/send',
method: 'POST',
headers: {
'Authorization': "key=" + firebaseKey
}
};
let request = https.request(https_options, (response) =>{
console.log("respondio fsm:"+ JSON.stringify(response));
function sendNotification(subscriptionId) {
console.log("dentro de sendNotif. sale promise");
return new Promise((resolve, reject) => {
const body = {
"to": subscriptionId,
"title": "notif from lambda",
"body": "nada"
};
var options = {
method: 'POST',
uri: 'https://fcm.googleapis.com/fcm/send',
headers: {
'Authorization': "key=" + firebaseKey
},
body: body,
json: true // Automatically stringifies the body to JSON
};
rp(options)
.then(function (parsedBody) {
resolve(parsedBody);
})
.catch(function (err) {
reject(err);
});
});
}
}
{
"name": "airbits-notif-utils",
"version": "1.0.5",
"version": "1.0.6",
"description": "notification utilities for xens app",

@@ -9,4 +9,6 @@ "main": "index.js",

"dependencies": {
"airbits-data": "^1.0.4"
"airbits-data": "^1.0.4",
"request": "^2.83.0",
"request-promise": "^4.2.2"
}
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc