• Does user have organization with topic permission validator

    Parameters

    • chatService: ChatDataService

      injected service used to handle the chat related operations

      • getOneTopic
      • getSubscriptions
    • organizationAPI: Pick<OrganizationDefaultAdapterAPI, "isUserInOrganization">

      injected connector used to handle the organization communication

    • options: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          permissions: string[];
          topicIdField: TargetField;
      }

      Option

      • organizationIdField which field to get the organization id from
      • permissions which permissions to check
      • topicIdField which field to get the topic id from
      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
      • permissions: string[]
      • topicIdField: TargetField
    • 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 logged in user has any topic permission by applying the following steps in sequence:

    1. Authenticate the user (authenticate)

    2. Get topic by id (chatService.getOneTopic)

    3. Get subscriptions by topicId and permissions (chatService.getSubscriptions)

    4. Check if user is in any organizationId returned from these

    5. Return 200 if the user has organization with the topic permission

    Throws

    403 NBError Forbidden

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

    Throws

    404 NBError Not Found

    • topic: ${topicId} not found.

Generated using TypeDoc