• Is user match topic owner validator

    Parameters

    • chatService: ChatDataService

      injected service use to handle the chat related operations

      • getOneTopic
    • options: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          topicField: TargetField;
      }

      Options

      • authSecrets authenticate secret
      • authenticate injected authenticate function
      • topicField which field to get the topic id from
      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
      • topicField: TargetField
    • organizationApi: Pick<OrganizationDefaultAdapterAPI, "getUserOrganizationRole">
    • 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 is the topic owner by applying the following steps in sequence:

    1. Authenticate the user (authenticate)

    2. Get topic by id (chatService.getOneTopic)

    3. Check if the topic exists

    4. If ownerType is user, check if the user id is in the topic ownerIds

    5. If ownerType is organization, check if the user is the owner or admin of one of the organization ownerIds

    Throws

    403 NBError Forbidden

    • check user subscription validator need token type to be user token
    • user is not the topic owner

    Throws

    404 NBError Not Found

    • topicId: ${topicId} not found.

Generated using TypeDoc