@@ -154,6 +154,7 @@ import {
154154 UNSTABLE_MSC3088_ENABLED ,
155155 UNSTABLE_MSC3088_PURPOSE ,
156156 UNSTABLE_MSC3089_TREE_SUBTYPE ,
157+ UNSTABLE_MSC3912_RELATION_BASED_REDACTIONS ,
157158} from "./@types/event" ;
158159import { IdServerUnbindResult , IImageInfo , Preset , Visibility } from "./@types/partials" ;
159160import { EventMapper , eventMapperFor , MapperOpts } from "./event-mapper" ;
@@ -4355,20 +4356,20 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
43554356 * @returns Promise which resolves: TODO
43564357 * @returns Rejects: with an error response.
43574358 */
4358- public redactEvent (
4359+ public async redactEvent (
43594360 roomId : string ,
43604361 eventId : string ,
43614362 txnId ?: string | undefined ,
43624363 opts ?: IRedactOpts ,
43634364 ) : Promise < ISendEventResponse > ;
4364- public redactEvent (
4365+ public async redactEvent (
43654366 roomId : string ,
43664367 threadId : string | null ,
43674368 eventId : string ,
43684369 txnId ?: string | undefined ,
43694370 opts ?: IRedactOpts ,
43704371 ) : Promise < ISendEventResponse > ;
4371- public redactEvent (
4372+ public async redactEvent (
43724373 roomId : string ,
43734374 threadId : string | null ,
43744375 eventId ?: string ,
@@ -4382,9 +4383,20 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
43824383 threadId = null ;
43834384 }
43844385 const reason = opts ?. reason ;
4386+
4387+ if ( opts ?. with_relations && ! await this . supportsRelationBasedRedactions ( ) ) {
4388+ throw new Error (
4389+ "Server does not support relation based redactions "
4390+ + `roomId ${ roomId } eventId ${ eventId } txnId: ${ txnId } threadId ${ threadId } ` ,
4391+ ) ;
4392+ }
4393+
43854394 return this . sendCompleteEvent ( roomId , threadId , {
43864395 type : EventType . RoomRedaction ,
4387- content : { reason } ,
4396+ content : {
4397+ ...( opts ?. with_relations ? { with_relations : opts ?. with_relations } : { } ) ,
4398+ reason,
4399+ } ,
43884400 redacts : eventId ,
43894401 } , txnId as string ) ;
43904402 }
@@ -9265,6 +9277,11 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
92659277 return this . clientOpts ?. experimentalThreadSupport || false ;
92669278 }
92679279
9280+ public async supportsRelationBasedRedactions ( ) : Promise < boolean > {
9281+ return await this . doesServerSupportUnstableFeature ( UNSTABLE_MSC3912_RELATION_BASED_REDACTIONS . stable ! )
9282+ || await this . doesServerSupportUnstableFeature ( UNSTABLE_MSC3912_RELATION_BASED_REDACTIONS . unstable ! ) ;
9283+ }
9284+
92689285 /**
92699286 * Fetches the summary of a room as defined by an initial version of MSC3266 and implemented in Synapse
92709287 * Proposed at https://github.com/matrix-org/matrix-doc/pull/3266
0 commit comments