Add ntfy support maybe
This commit is contained in:
parent
c532f5386f
commit
6eed27b186
8
index.js
8
index.js
|
@ -7,6 +7,8 @@ const bcrypt = require("bcrypt");
|
|||
const sqlite3 = require("sqlite3").verbose();
|
||||
const db = new sqlite3.Database("database.db");
|
||||
const SQLiteStore = require('connect-sqlite3')(session);
|
||||
const ntfy = require("ntfy");
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -162,7 +164,7 @@ const createTicket = (title, description, status, user, priority) => {
|
|||
reject(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (config.ntfy) ntfy.publish({server: config.ntfy.server, authorization: config.ntfy.authorization, topic: config.ntfy.topic, title: `New Ticket`, message: `${title}: ${description}`, priority, tags: [user, new Date(timestamp).toISOString()]});
|
||||
resolve(this.lastID);
|
||||
}
|
||||
);
|
||||
|
@ -178,6 +180,7 @@ const deleteTicket = (id) => {
|
|||
reject(err);
|
||||
return;
|
||||
}
|
||||
if (config.ntfy) ntfy.publish({server: config.ntfy.server, authorization: config.ntfy.authorization, topic: config.ntfy.topic, title: `Ticket Deleted`, message: `Ticket ${id} has been deleted`, tags: [new Date().toISOString()]});
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
|
@ -370,6 +373,7 @@ app.post("/ticket/:id/:action", isAuthenticated, (req, res) => {
|
|||
console.error(err);
|
||||
return res.status(500).send("Internal Server Error");
|
||||
}
|
||||
if (config.ntfy) ntfy.publish({server: config.ntfy.server, authorization: config.ntfy.authorization, topic: config.ntfy.topic, title: `New Message on ticket ${req.params.id}`, message: `${req.body.message}`, tags: [req.session.userData.username, new Date(timestamp).toISOString()]});
|
||||
res.redirect(`/ticket/${req.params.id}`);
|
||||
});
|
||||
});
|
||||
|
@ -391,6 +395,7 @@ app.post("/ticket/:id/:action", isAuthenticated, (req, res) => {
|
|||
console.error(err);
|
||||
return res.status(500).send("Internal Server Error");
|
||||
}
|
||||
if(config.ntfy) ntfy.publish({server: config.ntfy.server, authorization: config.ntfy.authorization, topic: config.ntfy.topic, title: `Ticket ${req.params.id} status changed`, message: `Status changed to ${req.body.status}`, tags: [req.session.userData.username, new Date(Date.now()).toISOString()]});
|
||||
res.redirect(`/ticket/${req.params.id}`);
|
||||
});
|
||||
});
|
||||
|
@ -413,6 +418,7 @@ app.post("/ticket/:id/:action", isAuthenticated, (req, res) => {
|
|||
console.error(err);
|
||||
return res.status(500).send("Internal Server Error");
|
||||
}
|
||||
if(config.ntfy) ntfy.publish({server: config.ntfy.server, authorization: config.ntfy.authorization, topic: config.ntfy.topic, title: `Ticket ${req.params.id} priority changed`, message: `Priority changed to ${req.body.priority}`, tags: [req.session.userData.username, new Date(Date.now()).toISOString()]});
|
||||
res.redirect(`/ticket/${req.params.id}`);
|
||||
});
|
||||
});
|
||||
|
|
20
package-lock.json
generated
20
package-lock.json
generated
|
@ -16,6 +16,7 @@
|
|||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"express-session": "^1.18.0",
|
||||
"ntfy": "^1.5.3",
|
||||
"sqlite3": "^5.1.7"
|
||||
}
|
||||
},
|
||||
|
@ -1672,6 +1673,17 @@
|
|||
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ntfy": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/ntfy/-/ntfy-1.5.3.tgz",
|
||||
"integrity": "sha512-By98aWwKgoa2Lp31xtEZ6WqyROHfT2/f5S1/0L4xA095D5m+gDpy95adcQkm/kVkLLTDFDK603Xicj1YGXfR6w==",
|
||||
"dependencies": {
|
||||
"axios": "1.6.8"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 18.0"
|
||||
}
|
||||
},
|
||||
"node_modules/object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
|
@ -3677,6 +3689,14 @@
|
|||
"set-blocking": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"ntfy": {
|
||||
"version": "1.5.3",
|
||||
"resolved": "https://registry.npmjs.org/ntfy/-/ntfy-1.5.3.tgz",
|
||||
"integrity": "sha512-By98aWwKgoa2Lp31xtEZ6WqyROHfT2/f5S1/0L4xA095D5m+gDpy95adcQkm/kVkLLTDFDK603Xicj1YGXfR6w==",
|
||||
"requires": {
|
||||
"axios": "1.6.8"
|
||||
}
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
"ejs": "^3.1.10",
|
||||
"express": "^4.19.2",
|
||||
"express-session": "^1.18.0",
|
||||
"ntfy": "^1.5.3",
|
||||
"sqlite3": "^5.1.7"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue