Skip to content

Commit

Permalink
Merge pull request #63 from pushme-tgxn/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tgxn committed Apr 3, 2024
2 parents 2e1f044 + 9266cc1 commit 613f3a0
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
1 change: 0 additions & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
version: "3.5"

networks:
pushme-net:
Expand Down
13 changes: 13 additions & 0 deletions public/delete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<h1>Account Deletion Policy</h1>
<p>Last updated: April 03, 2024</p>
<p>
You can delete your account via the app, on the "Settings" page.
</p>
<p>
If you need help with this button, please contact us at the address below. Thanks.
</p>
<h1>Contact Us</h1>
<p>If you have any questions about this Policy, You can contact us:</p>
<ul>
<li>By email: pushme+deletion@tgxn.net</li>
</ul>
45 changes: 45 additions & 0 deletions src/module/grafana.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const { getTopicBySecretKey } = require("../services/topic");

const { createPushToTopic, pushToTopicDevices } = require("../services/push");

const { appLogger } = require("../middleware/logging.js");

const createGrafanaPushRequest = async (request, response, next) => {
try {
console.log("inputPayload", request.body);
let { title, state, message } = request.body;
console.log("inputPayload", { title, state, message });

const pushPayload = {
categoryId: "simple.push",
title: `Grafana: ${title}`,
body: message,
};

const foundTopic = await getTopicBySecretKey(request.params.topicSecret);
if (!foundTopic) {
return next(new Error("Topic secret key does not exist"));
}
appLogger.debug("foundTopic", foundTopic.dataValues.id);

const createdPush = await createPushToTopic(foundTopic);
appLogger.info("createPush", createdPush.dataValues);

// respond early
response
.status(200)
.json({
success: true,
pushIdent: createdPush.dataValues.pushIdent,
})
.send();

await pushToTopicDevices(foundTopic, createdPush, pushPayload);
} catch (error) {
next(error);
}
};

module.exports = {
createGrafanaPushRequest,
};
2 changes: 2 additions & 0 deletions src/routes/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const {
} = require("../controllers/push");

const { createUpTimeKumaPushRequest } = require("../module/uptimekuma");
const { createGrafanaPushRequest } = require("../module/grafana");

const router = express.Router();

Expand All @@ -21,6 +22,7 @@ router.get("/", authorize(), getUserPushHistory);
// push to topic with secret
router.post("/:topicSecret", createPushRequest);
router.post("/:topicSecret/uptimekuma", createUpTimeKumaPushRequest);
router.post("/:topicSecret/grafana", createGrafanaPushRequest);

// get information on a push request
router.post("/:pushIdent/receipt", recordPushReceipt); // when the notification is recieved
Expand Down

0 comments on commit 613f3a0

Please sign in to comment.