fn(account$0, content$1, after_time_ms$9, then$2) =>
match @std.base64-to-bytes(text: $0.account_id) {
#none(_) =>
$2(accepted: false, text: "The account id of the MCP account is not Base64"),
#some(account_id_bytes$3) =>
#read_time<@definy.service-io>({
then: fn(now_ms$4) =>
let inner$5 = @cbor.encode(
item: @definy.event-inner-cbor(
account_id_bytes: $3,
time_seconds: @std.max(
a: @core.divide(left: $4, right: 1000),
b: @core.plus(left: @core.divide(left: $9, right: 1000), right: 1)
),
content: $1
)
);
#sign_mcp_account<@definy.service-io>({
message: $5,
then: fn(signature$6) =>
match $6 {
#none(_) =>
$2(
accepted: false,
text: "The MCP account could not sign (DEFINY_MCP_ACCOUNT_SECRET_KEY is not set)"
),
#some(bytes$7) =>
@definy.service-io-then-respond(
io: @definy.submit-event(
request: #object<@definy.json>([
{
key: "signedEventBytes",
value: #string<@definy.json>(@std.bytes-to-base64(bytes: @cbor.encode(item: @definy.signed-event-cbor(signature: $7, event_binary: $5))))
}
])
),
respond: fn(response$8) =>
$2(accepted: @core.equal(left: $8.status, right: 200), text: @definy.http-body-text(body: $8.body))
)
}
})
})
}