|
| 1 | +/* eslint-disable camelcase */ |
1 | 2 | const { GET_ALL_EVENTS_LIMIT_MIN, UNWANTED_PROPERTIES_FROM_100MS } = require("../constants/events");
|
2 |
| -const { INTERNAL_SERVER_ERROR } = require("../constants/errorMessages"); |
3 |
| - |
4 | 3 | const { EventTokenService, EventAPIService } = require("../services");
|
| 4 | +const { removeUnwantedProperties } = require("../utils/events"); |
5 | 5 | const eventQuery = require("../models/events");
|
6 |
| - |
7 | 6 | const logger = require("../utils/logger");
|
8 |
| -const { removeUnwantedProperties } = require("../utils/events"); |
9 | 7 |
|
10 | 8 | const tokenService = new EventTokenService();
|
11 | 9 | const apiService = new EventAPIService(tokenService);
|
@@ -102,7 +100,7 @@ const joinEvent = async (req, res) => {
|
102 | 100 | });
|
103 | 101 | } catch (error) {
|
104 | 102 | logger.error({ error });
|
105 |
| - return res.boom.badImplementation(INTERNAL_SERVER_ERROR); |
| 103 | + return res.status(500).send("Internal Server Error"); |
106 | 104 | }
|
107 | 105 | };
|
108 | 106 |
|
@@ -195,77 +193,11 @@ const endActiveEvent = async (req, res) => {
|
195 | 193 | }
|
196 | 194 | };
|
197 | 195 |
|
198 |
| -/** |
199 |
| - * Adds a peer to an event. |
200 |
| - * |
201 |
| - * @async |
202 |
| - * @function |
203 |
| - * @param {Object} req - The Express request object. |
204 |
| - * @param {Object} res - The Express response object. |
205 |
| - * @returns {Promise<Object>} The JSON response with the added peer data and a success message. |
206 |
| - * @throws {Object} The JSON response with an error message if an error occurred while adding the peer. |
207 |
| - */ |
208 |
| -const addPeerToEvent = async (req, res) => { |
209 |
| - try { |
210 |
| - const data = await eventQuery.addPeerToEvent({ |
211 |
| - peerId: req.body.peerId, |
212 |
| - name: req.body.name, |
213 |
| - role: req.body.role, |
214 |
| - joinedAt: req.body.joinedAt, |
215 |
| - eventId: req.params.id, |
216 |
| - }); |
217 |
| - return res.status(200).json({ |
218 |
| - data, |
219 |
| - message: `Selected Participant is added to the event.`, |
220 |
| - }); |
221 |
| - } catch (error) { |
222 |
| - logger.error({ error }); |
223 |
| - return res.status(500).json({ |
224 |
| - error: error.code, |
225 |
| - message: "You can't add selected Participant. Please ask Admin or Host for help.", |
226 |
| - }); |
227 |
| - } |
228 |
| -}; |
229 |
| - |
230 |
| -/** |
231 |
| - * Kicks out a peer from an event. |
232 |
| - * |
233 |
| - * @async |
234 |
| - * @function |
235 |
| - * @param {Object} req - The Express request object. |
236 |
| - * @param {Object} res - The Express response object. |
237 |
| - * @returns {Promise<Object>} The JSON response with a success message if the peer is successfully kicked out. |
238 |
| - * @throws {Object} The JSON response with an error message if an error occurred while kicking out the peer. |
239 |
| - */ |
240 |
| -const kickoutPeer = async (req, res) => { |
241 |
| - const { id } = req.params; |
242 |
| - const payload = { |
243 |
| - peer_id: req.body.peerId, |
244 |
| - reason: req.body.reason, |
245 |
| - }; |
246 |
| - |
247 |
| - try { |
248 |
| - await apiService.post(`/active-rooms/${id}/remove-peers`, payload); |
249 |
| - await eventQuery.kickoutPeer({ eventId: id, peerId: payload.peer_id, reason: req.body.reason }); |
250 |
| - return res.status(200).json({ |
251 |
| - message: `Selected Participant is removed from event.`, |
252 |
| - }); |
253 |
| - } catch (error) { |
254 |
| - logger.error({ error }); |
255 |
| - return res.status(500).json({ |
256 |
| - error: error.code, |
257 |
| - message: "You can't remove selected Participant from Remove, Please ask Admin or Host for help.", |
258 |
| - }); |
259 |
| - } |
260 |
| -}; |
261 |
| - |
262 | 196 | module.exports = {
|
263 | 197 | createEvent,
|
264 | 198 | getAllEvents,
|
265 | 199 | joinEvent,
|
266 | 200 | getEventById,
|
267 | 201 | updateEvent,
|
268 | 202 | endActiveEvent,
|
269 |
| - addPeerToEvent, |
270 |
| - kickoutPeer, |
271 | 203 | };
|
0 commit comments