Skip to content

DeleteMessage

Source: src/AWS/IVSChat/DeleteMessage.ts

Moderate the bound room by deleting a message — the effectful call made from a deployed Lambda or Task. It broadcasts a DELETEMESSAGE event to every connected client, directing them to remove the message (id is the ID from the WebSocket SendMessage response); an optional reason is attached to the event.

Provide the DeleteMessageHttp implementation layer on the Function effect, bind the room in the init phase, then call the returned client at runtime. The binding grants ivschat:DeleteMessage on the room and injects its ARN as the roomIdentifier automatically.

// init
const room = yield* IVSChat.Room("LiveChat");
const deleteMessage = yield* IVSChat.DeleteMessage(room);
return {
fetch: Effect.gen(function* () {
// runtime
const { id } = yield* deleteMessage({
id: flaggedMessageId,
reason: "abusive content",
});
return HttpServerResponse.json({ deleted: id });
}),
};
// on the Function effect:
// .pipe(Effect.provide(IVSChat.DeleteMessageHttp))