Skip to content

Commit 8ff358c

Browse files
committed
backend added better notification management
1 parent eb2b336 commit 8ff358c

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

backend/server.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ const { Expo } = require("expo-server-sdk");
33
const bodyParser = require('body-parser');
44
const cors = require('cors');
55

6-
let savedPushTokens = [];
76
const expo = new Expo();
87
const app = express();
98

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

12+
let savedPushTokens = [];
13+
let notification_array = [];
14+
1315
var port = process.env.port || 8080;
1416
var username = process.env.username || 'xss';
1517
var password = process.env.password || 'bomb';
@@ -64,7 +66,6 @@ app.listen(port, function() {
6466
app.post("/token", (req, res) => {
6567
if (req.body.token == undefined || req.body.username == undefined ||
6668
req.body.password == undefined) {
67-
console.log("here");
6869
res.send({ data: "ko" });
6970
return
7071
}
@@ -73,20 +74,36 @@ app.post("/token", (req, res) => {
7374
res.send({ data: "ok" });
7475
});
7576

77+
app.post("/notifications", (req, res) => {
78+
if (req.body.username == undefined || req.body.password == undefined) {
79+
res.send({ data: "ko" });
80+
return
81+
}
82+
res.send(notification_array);
83+
});
84+
7685
app.post("/message", (req, res) => {
7786
handlePushTokens(req.body);
87+
notification_array.push({
88+
'route': '/message',
89+
'content': req.body,
90+
'user-agent': req.headers['user-agent']
91+
});
7892
console.log(`Received message, with title: ${req.body.title}`);
7993
res.send(`Received message, with title: ${req.body.title}`);
8094
});
8195

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

88101
app.get("/pic", (req, res) => {
89-
console.log(req.headers['user-agent']);
102+
notification_array.push({
103+
'route': '/pic',
104+
'content': undefined,
105+
'user-agent': req.headers['user-agent']
106+
});
90107
handlePushTokens({title: "xss - picture", body: req.headers['user-agent']});
91108
res.sendFile(__dirname + "/public/1px.png");
92109
});

0 commit comments

Comments
 (0)