@@ -121,6 +121,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
121121 this . allowedCapabilities . add ( `org.matrix.msc2762.timeline:${ inRoomId } ` ) ;
122122 this . allowedCapabilities . add ( MatrixCapabilities . MSC4157SendDelayedEvent ) ;
123123 this . allowedCapabilities . add ( MatrixCapabilities . MSC4157UpdateDelayedEvent ) ;
124+ this . allowedCapabilities . add ( MatrixCapabilities . MSC4354SendStickyEvent ) ;
124125
125126 this . allowedCapabilities . add (
126127 WidgetEventCapability . forStateEvent ( EventDirection . Receive , EventType . RoomName ) . raw ,
@@ -344,6 +345,31 @@ export class StopGapWidgetDriver extends WidgetDriver {
344345 return { roomId, eventId : r . event_id } ;
345346 }
346347
348+ /**
349+ * @experimental Part of MSC4354
350+ * @see {@link WidgetDriver#sendStickyEvent }
351+ */
352+ public async sendStickyEvent (
353+ stickyDurationMs : number ,
354+ eventType : string ,
355+ content : unknown ,
356+ targetRoomId ?: string | null ,
357+ ) : Promise < ISendEventDetails > {
358+ const client = MatrixClientPeg . get ( ) ;
359+ const roomId = targetRoomId || SdkContextClass . instance . roomViewStore . getRoomId ( ) ;
360+
361+ if ( ! client || ! roomId ) throw new Error ( "Not in a room or not attached to a client" ) ;
362+
363+ const r = await client . _unstable_sendStickyEvent (
364+ roomId ,
365+ stickyDurationMs ,
366+ null ,
367+ eventType as keyof TimelineEvents ,
368+ content as TimelineEvents [ keyof TimelineEvents ] & { msc4354_sticky_key : string } ,
369+ ) ;
370+ return { roomId, eventId : r . event_id } ;
371+ }
372+
347373 /**
348374 * @experimental Part of MSC4140 & MSC4157
349375 * @see {@link WidgetDriver#sendDelayedEvent }
@@ -421,6 +447,48 @@ export class StopGapWidgetDriver extends WidgetDriver {
421447 } ;
422448 }
423449
450+ /**
451+ * @experimental Part of MSC4354
452+ * @see {@link WidgetDriver#sendStickyEvent }
453+ */
454+ public async sendDelayedStickyEvent (
455+ delay : number | null ,
456+ parentDelayId : string | null ,
457+ stickyDurationMs : number ,
458+ eventType : string ,
459+ content : unknown ,
460+ targetRoomId ?: string | null ,
461+ ) : Promise < ISendDelayedEventDetails > {
462+ const client = MatrixClientPeg . get ( ) ;
463+ const roomId = targetRoomId || SdkContextClass . instance . roomViewStore . getRoomId ( ) ;
464+
465+ if ( ! client || ! roomId ) throw new Error ( "Not in a room or not attached to a client" ) ;
466+
467+ let delayOpts ;
468+ if ( delay !== null ) {
469+ delayOpts = {
470+ delay,
471+ ...( parentDelayId !== null && { parent_delay_id : parentDelayId } ) ,
472+ } ;
473+ } else if ( parentDelayId !== null ) {
474+ delayOpts = {
475+ parent_delay_id : parentDelayId ,
476+ } ;
477+ } else {
478+ throw new Error ( "Must provide at least one of delay or parentDelayId" ) ;
479+ }
480+
481+ const r = await client . _unstable_sendStickyDelayedEvent (
482+ roomId ,
483+ stickyDurationMs ,
484+ delayOpts ,
485+ null ,
486+ eventType as keyof TimelineEvents ,
487+ content as TimelineEvents [ keyof TimelineEvents ] & { msc4354_sticky_key : string } ,
488+ ) ;
489+ return { roomId, delayId : r . delay_id } ;
490+ }
491+
424492 /**
425493 * @experimental Part of MSC4140 & MSC4157
426494 */
0 commit comments