Skip to content

Commit 6187732

Browse files
committed
Check for missing event_id in send_event response
because it is an optional field as of MSC4157
1 parent cc57a7f commit 6187732

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/embedded.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ export class RoomWidgetClient extends MatrixClient {
300300
}
301301

302302
room.updatePendingEvent(event, EventStatus.SENT, response.event_id);
303+
if (!response.event_id) {
304+
throw new Error("'event_id' absent from response to an event request");
305+
}
303306
return { event_id: response.event_id };
304307
}
305308

@@ -309,7 +312,11 @@ export class RoomWidgetClient extends MatrixClient {
309312
content: any,
310313
stateKey = "",
311314
): Promise<ISendEventResponse> {
312-
return await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);
315+
const response = await this.widgetApi.sendStateEvent(eventType, stateKey, content, roomId);
316+
if (response.event_id === undefined) {
317+
throw new Error("'event_id' absent from response to an event request");
318+
}
319+
return { event_id: response.event_id };
313320
}
314321

315322
/**

0 commit comments

Comments
 (0)