import { Button , Composite , Text } from '@wireapp/protocol-messaging' ; import { CompositeContent , LegalHoldStatus } from '../content' ; import type { CompositeMessage } from './OtrMessage' ; import { MessageBuilder } from './MessageBuilder' ; export class CompositeContentBuilder { private readonly content : CompositeContent = { } ; private readonly payloadBundle : CompositeMessage ; private readonly items : Composite . IItem [ ] = [ ] ; constructor ( payloadBundle ) { this . payloadBundle = payloadBundle ; } build ( ) { this . payloadBundle . content = this . content ; this . payloadBundle . content . items = this . items ; return this . payloadBundle ; } withReadConfirmation ( expectsReadConfirmation = false ) { this . content . expectsReadConfirmation = expectsReadConfirmation ; return this ; } withLegalHoldStatus ( legalHoldStatus = LegalHoldStatus . UNKNOWN ) { this . content . legalHoldStatus = legalHoldStatus ; return this ; } addText ( text ) { this . items . push ( Composite . Item . create ( { text } ) ) ; return this ; } addButton ( buttonText , id = MessageBuilder . createId ( ) ) { this . items . push ( Composite . Item . create ( { button : Button . create ( { id , text : buttonText } ) } ) ) ; return this ; } }