• Does user have any subscription permission validator

    Parameters

    • chatService: ChatDataService

      injected service use to handle the chat related operations

      • getOneSubscription
      • getOneTopic
      • getSubscriptions
    • options: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          permissions: string[];
          subscriptionIdField: TargetField;
      }

      Options

      • authSecrets authenticate secret
      • authenticate injected authenticate function
      • permissions which permissions to check
      • subscriptionIdField which field to get the subscription id from
      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
      • permissions: string[]
      • subscriptionIdField: 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 user has any subscription permission by applying the following steps in sequence:

    1. Authenticate the user (authenticate)

    2. Get subscription by id (chatService.getOneSubscription)

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

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

    5. Return 200 if the user has any subscription permission

    Throws

    403 NBError Forbidden

    • check user subscription validator need token type to be user token
    • user not subscribed to the topic: ${subscription.topicId}

    Throws

    404 NBError Not Found

    • subscription: ${subscriptionId} not found.
    • topic: ${subscription.topicId} not found.

Generated using TypeDoc