-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: #310 - webrtc call added for audio * feat: #310 -e2e encrypted oneway audio call * feat: #310 -e2e encrypted oneway audio call added * fix: react hook warning * fix: few code smell
- Loading branch information
Showing
23 changed files
with
704 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import express, { Request, Response } from 'express'; | ||
import asyncHandler from '../../middleware/asyncHandler'; | ||
import { WebrtcSessionResponse } from '../messaging/types'; | ||
import channelValid from '../chatLink/utils/validateChannel'; | ||
import getClientInstance from '../../socket.io/clients'; | ||
import { SOCKET_TOPIC, socketEmit } from '../../socket.io'; | ||
const router = express.Router({ mergeParams: true }); | ||
|
||
const clients = getClientInstance(); | ||
|
||
router.post( | ||
"/", | ||
asyncHandler(async (req: Request, res: Response): Promise<Response<WebrtcSessionResponse>> => { | ||
const { description, sender, channel } = req.body; | ||
|
||
if (!description) { | ||
return res.send(400); | ||
} | ||
|
||
const { valid } = await channelValid(channel); | ||
|
||
if (!valid) { | ||
return res.sendStatus(404); | ||
} | ||
|
||
if (!clients.isSenderInChannel(channel, sender)) { | ||
console.error('Sender is not in channel'); | ||
return res.status(401).send({ error: "Permission denied" }); | ||
} | ||
|
||
const receiver = clients.getReceiverIDBySenderID(sender, channel); | ||
if(!receiver) { | ||
console.error('No receiver is in the channel'); | ||
return res.status(406).send({ error: "No user available to accept call" }); | ||
} | ||
|
||
const receiverSid = clients.getSIDByIDs(receiver, channel).sid; | ||
socketEmit<SOCKET_TOPIC.WEBRTC_SESSION_DESCRIPTION>(SOCKET_TOPIC.WEBRTC_SESSION_DESCRIPTION, receiverSid, description); | ||
return res.send({ status: "ok" }); | ||
}) | ||
); | ||
|
||
export default router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,15 @@ | ||
import React, { useContext } from "react"; | ||
import { ThemeContext } from "../../ThemeContext"; | ||
import styles from "./Style.module.css"; | ||
import React from "react"; | ||
import Button from "../Button"; | ||
|
||
const DeleteChatLink = ({ handleDeleteLink }: any) => { | ||
const [darkMode] = useContext(ThemeContext); | ||
|
||
const deleteHandler = async () => { | ||
if (window.confirm("Delete chat link forever?")) await handleDeleteLink(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<div | ||
className={`${styles.deleteButton} ${!darkMode && styles.lightModeDelete}`} | ||
role="button" | ||
onClick={deleteHandler} | ||
> | ||
Delete | ||
</div> | ||
<Button onClick={deleteHandler} label = "Delete" type="secondary"/> | ||
</div> | ||
); | ||
}; | ||
) | ||
} | ||
|
||
export default DeleteChatLink; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.