• Does the attachment belong to the topic validator

    Parameters

    • attachmentService: Pick<AttachmentService, "getOneAttachment">

      injected service use to handle the attachment related operations

      • getOneAttachment
    • topicIdTargetField: TargetField
    • attachmentIdTargetField: TargetField
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

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

      • params.topicId is required
      • params.attachmentId is required

    Returns Promise<number>

    200 Status OK

    Description

    This validator will check if attachment belongs to the topic by applying the following steps in sequence:

    1. Get topicId and attachmentId from context

    2. Check if topicId or attachmentId exists in context

    3. Get attachment and check if type equals to topic and ownerId equals topicId from context (attachmentService.getOneAttachment)

    Throws

    400 NBError Bad Request

    • topicId or attachmentId not exist in request params

    Throws

    404 NBError Not Found

    • attachment not found for user

Generated using TypeDoc