Skip to content

Commit

Permalink
backend added better notification management
Browse files Browse the repository at this point in the history
  • Loading branch information
p4p1 committed Oct 29, 2020
1 parent eb2b336 commit 8ff358c
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ const { Expo } = require("expo-server-sdk");
const bodyParser = require('body-parser');
const cors = require('cors');

let savedPushTokens = [];
const expo = new Expo();
const app = express();

const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '/.env') })

let savedPushTokens = [];
let notification_array = [];

var port = process.env.port || 8080;
var username = process.env.username || 'xss';
var password = process.env.password || 'bomb';
Expand Down Expand Up @@ -64,7 +66,6 @@ app.listen(port, function() {
app.post("/token", (req, res) => {
if (req.body.token == undefined || req.body.username == undefined ||
req.body.password == undefined) {
console.log("here");
res.send({ data: "ko" });
return
}
Expand All @@ -73,20 +74,36 @@ app.post("/token", (req, res) => {
res.send({ data: "ok" });
});

app.post("/notifications", (req, res) => {
if (req.body.username == undefined || req.body.password == undefined) {
res.send({ data: "ko" });
return
}
res.send(notification_array);
});

app.post("/message", (req, res) => {
handlePushTokens(req.body);
notification_array.push({
'route': '/message',
'content': req.body,
'user-agent': req.headers['user-agent']
});
console.log(`Received message, with title: ${req.body.title}`);
res.send(`Received message, with title: ${req.body.title}`);
});

app.get("/stager", (req, res) => {
console.log(req.headers['user-agent']);
handlePushTokens({title: "xss - stager", body: req.headers['user-agent']});
console.log(req.headers);
res.sendFile(__dirname + "/public/stager.js");
});

app.get("/pic", (req, res) => {
console.log(req.headers['user-agent']);
notification_array.push({
'route': '/pic',
'content': undefined,
'user-agent': req.headers['user-agent']
});
handlePushTokens({title: "xss - picture", body: req.headers['user-agent']});
res.sendFile(__dirname + "/public/1px.png");
});
Expand Down

0 comments on commit 8ff358c

Please sign in to comment.