• Is user organization message template validator

    Parameters

    • chatService: ChatDataService

      injected service use to handle the chat related operations

      • getMessageTemplateByIdAndNormalize
    • options: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          targetField: TargetField;
      }

      Options

      • authSecrets authenticate secret
      • authenticate injected authenticate function
      • targetField which field to get the message template id from
      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
      • targetField: TargetField
    • organizationAPI: Pick<OrganizationDefaultAdapterAPI, "getUserOrganizations">

      injected API use to handle the organization related operations

      • getUserOrganizations
    • 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 in the message template organization by applying the following steps in sequence:

    1. Authenticate the user (authenticate)

    2. Get message template by id and normalize (chatService.getMessageTemplateByIdAndNormalize)

    3. Check if the message template exists

    4. Check if the message template is admin message template

    5. Get user organizations (organizationAPI.getUserOrganizations)

    6. Check if the user is in the message template organization

    Throws

    401 NBError Unauthorized

    • user do not have permission to use this message template

    Throws

    403 NBError Forbidden

    • user not found

    Throws

    404 NBError Not Found

    • message template not found

Generated using TypeDoc