Send payload daemon-daemon
- Add type in inteface with jamid to send data via sendAccountTextMessage
- Add route to server
Gitlab: #52
Change-Id: I4694f37ae22097bf7776f2e3698d3c080b2cff02
diff --git a/server/src/routers/account-router.ts b/server/src/routers/account-router.ts
index 0798fa7..7344e85 100644
--- a/server/src/routers/account-router.ts
+++ b/server/src/routers/account-router.ts
@@ -15,13 +15,21 @@
* License along with this program. If not, see
* <https://www.gnu.org/licenses/>.
*/
-import { Router } from 'express';
-import { AccountDetails } from 'jami-web-common';
+import { Request, Router } from 'express';
+import { ParamsDictionary } from 'express-serve-static-core';
+import { AccountDetails, HttpStatusCode } from 'jami-web-common';
import { Container } from 'typedi';
import { Jamid } from '../jamid/jamid.js';
import { authenticateToken } from '../middleware/auth.js';
+interface SendAccountTextMessageApi {
+ from?: string;
+ to?: string;
+ type?: string;
+ data?: string;
+}
+
const jamid = Container.get(Jamid);
export const accountRouter = Router();
@@ -50,3 +58,13 @@
jamid.setAccountDetails(res.locals.accountId, newAccountDetails);
res.end();
});
+
+accountRouter.post('/send-account-message', (req: Request<ParamsDictionary, any, SendAccountTextMessageApi>, res) => {
+ const { from, to, type, data } = req.body;
+ if (!from || !to || !type || !data) {
+ res.status(HttpStatusCode.BadRequest).send('Missing arguments in request');
+ return;
+ }
+ jamid.sendAccountTextMessage(from, to, type, data);
+ res.end();
+});