diff --git a/src/controllers/CallsController.ts b/src/controllers/CallsController.ts index b98054f..1958822 100644 --- a/src/controllers/CallsController.ts +++ b/src/controllers/CallsController.ts @@ -40,6 +40,18 @@ export class CallsController { }) } + /** + * Check out whether a call is currently happening for a given + * conversation + * + * @param convID The ID of the conversation to check + * @return {boolean} True if there is an ongoing call / false else + */ + public static IsHavingCall(convID: number) : boolean { + return UserWebSocketController.active_clients + .find((f) => f.activeCalls.has(convID)) !== undefined; + } + /** * Join a call * diff --git a/src/controllers/ConversationsController.ts b/src/controllers/ConversationsController.ts index 6bb73ee..66377ba 100644 --- a/src/controllers/ConversationsController.ts +++ b/src/controllers/ConversationsController.ts @@ -6,6 +6,7 @@ import { removeHTMLNodes } from "../utils/StringUtils"; import { ConversationMessage } from "../entities/ConversationMessage"; import { UnreadConversation } from "../entities/UnreadConversation"; import { CallsHelper } from "../helpers/CallsHelper"; +import { CallsController } from "./CallsController"; /** * Conversations controller @@ -372,7 +373,8 @@ export class ConversationsController { saw_last_message: c.sawLastMessage ? 1 : 0, members: [...c.members], can_have_call: CallsHelper.CanHaveCall(c), - can_have_video_call: CallsHelper.CanHaveVideoCAll(c) + can_have_video_call: CallsHelper.CanHaveVideoCAll(c), + has_call_now: CallsController.IsHavingCall(c.id) }; }