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