import { MatrixClient } from "../MatrixClient" ; import { MSC2716BatchSendResponse } from "../models/MSC2176" ; category export class UnstableAppserviceApis { private requestId = 0 ; constructor ( private client ) { } see https param { string } roomId param { string } prevEventId param { string } chunkId param { any [ ] } events param { any [ ] } stateEventsAtStart returns public async sendHistoricalEventBatch ( roomId , prevEventId , events , stateEventsAtStart = [ ] , chunkId ? ) { return this . client . doRequest ( "POST" , `/_matrix/client/unstable/org.matrix.msc2716/rooms/${ encodeURIComponent ( roomId ) }/batch_send` , { prev_event : prevEventId , chunk_id : chunkId , } , { events , state_events_at_start : stateEventsAtStart , } ) ; } param { string } roomId param { string } eventType param { string } content param { number } ts returns { Promise < string > } public async sendEventWithTimestamp ( roomId , eventType , content , ts ) { const txnId = `${ ( new Date ( ) . getTime ( ) ) }__inc_appts${ ++ this . requestId }` ; const response = await this . client . doRequest ( "PUT" , `/_matrix/client/r0/rooms/${ encodeURIComponent ( roomId ) }/send/${ encodeURIComponent ( eventType ) }/${ encodeURIComponent ( txnId ) }` , { ts } , content ) ; return response . event_id ; } param { string } roomId param { string } type param { string } stateKey param { string } content param { number } ts returns { Promise < string > } public async sendStateEventWithTimestamp ( roomId , type , stateKey , content , ts ) { const response = await this . client . doRequest ( "PUT" , `/_matrix/client/r0/rooms/${ encodeURIComponent ( roomId ) }/state/${ encodeURIComponent ( type ) }/${ encodeURIComponent ( stateKey ) }` , { ts } , content ) ; return response . event_id ; } }