• Does organization have any message permission validator

    Parameters

    • chatService: ChatDataService

      injected service use to handle the chat related operations

      • getOneMessage
      • getOneTopic
      • getSubscriptions
    • options: {
          messageIdField: TargetField;
          organizationIdField: TargetField;
          permissions: string[];
      }

      Options

      • authSecrets authenticate secret
      • authenticate injected authenticate function
      • messageIdField which field to get the message id from
      • permissions which permissions to check
      • messageIdField: TargetField
      • organizationIdField: TargetField
      • permissions: string[]
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

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

    Returns Promise<number>

    200 Status OK

    Description

    This validator checks if the organization has any message permission by applying the following steps in sequence:

    1. Get organization from context

    2. Get message by id (chatService.getOneMessage)

    3. Get topic by topicId from message (chatService.getOneTopic)

    4. Get subscriptions by topicId, organizationId and permissions (chatService.getSubscriptions)

    5. Return 200 if the organization has any message permission

    Throws

    403 NBError Forbidden

    • organizationId: organizationId not provided.
    • organization not subscribed to the topic: ${message.topicId}

    Throws

    404 NBError Not Found

    • message: ${messageId} not found.
    • topic: ${message.topicId} not found.s

Generated using TypeDoc