Add webRTC handlers
- Bind webRCT callbacks from socket
- Handle incoming account message for webRTC
GitLab: #53
Change-Id: I4ed28e7ca41e8e3870968819c75ffad249a188d0
diff --git a/server/src/routers/account-router.ts b/server/src/routers/account-router.ts
index c870f83..6ef7aa6 100644
--- a/server/src/routers/account-router.ts
+++ b/server/src/routers/account-router.ts
@@ -18,19 +18,12 @@
import { Request, Router } from 'express';
import asyncHandler from 'express-async-handler';
import { ParamsDictionary } from 'express-serve-static-core';
-import { AccountDetails, HttpStatusCode } from 'jami-web-common';
+import { AccountDetails, AccountTextMessage, 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();
@@ -76,16 +69,12 @@
res.sendStatus(HttpStatusCode.NoContent);
});
-accountRouter.post(
- '/send-account-message',
- (req: Request<ParamsDictionary, string, 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();
+accountRouter.post('/send-account-message', (req: Request<ParamsDictionary, any, AccountTextMessage>, res) => {
+ const { from, to, message } = req.body;
+ if (!from || !to || !message) {
+ res.status(HttpStatusCode.BadRequest).send('Missing arguments in request');
+ return;
}
-);
+ jamid.sendAccountTextMessage(from, to, JSON.stringify(message));
+ res.end();
+});