• Create message handler

    Parameters

    • authSecrets: AuthSecrets

      injected auth secrets use to handle the authentication

    • authenticate: AuthenticationFunction
    • chatService: ChatDataService

      injected service use to handle the chat related operations

      • createMessage
      • getOneMessageAndNormalize
    • socketAPI: undefined | SocketAPI<defaultChat.Message, defaultChat.Subscription>
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query].

    Returns Promise<adapter.AdapterHandlerResponse>

    201 Status Created

    • data: message

    Description

    This handler will create message by applying the following steps in sequence:

    1. Authenticate the request (authenticate)

    2. Create message (chatService.createMessage)

    2.1. If the user is authenticated, then mark the message as read (chatService.markMessageRead)

    1. Get message by id and normalize (chatService.getOneMessageAndNormalize)

    2. If socket server is attached, then do the following:

    4.1. Get subscriptions (chatService.getSubscriptions)

    4.2. Get private chat channels (getPrivateChatChannel)

    4.3. Emit message to the channels

    1. Return the message

    Throws

    500 NBError Internal Server Error

    • create message failed

Generated using TypeDoc