From 4616737483bf9c1889e54758788a13ae00cac2d0 Mon Sep 17 00:00:00 2001 From: cheetah Date: Fri, 2 Apr 2021 15:01:43 +0000 Subject: [PATCH] added readAck to the httpAPI, aswell as attachMetadata to make it clean --- index.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a1963d8..96c3f19 100644 --- a/index.js +++ b/index.js @@ -50,8 +50,23 @@ app.get('/api/message/recent', async (req, res) => { return res.json(msgs) }) -app.get('/api/message/ack/recv/:id', async (req, res) => { //TODO: make this fancy +app.get('/api/message/ack/recv/:id', async (req, res) => { types.ConnectorRegistry.reportDelivered({ id: req.params.id }, 'http') + require('../MessageManager').attachMetadata(req.params.id, { + ack: 'recv', + rssi: 0x00, + date: new Date(), + metadata: { http: true }, + }) + return res.json(true) +}) +app.get('/api/message/ack/read/:id', async (req, res) => { + types.MessageManager.markMessageRead(req.params.id) + require('../MessageManager').attachMetadata(req.params.id, { + ack: 'read', + date: new Date(), + metadata: { http: true }, + }) return res.json(true) })