fn(signed_event_bytes$0, event$1, facts$2) =>
let rejections$3 = @core.check-event(content: $1.content, facts: $2);
match @core.list-get(list: $3, index: 0) {
#none(_) =>
@definy.store-read-missing-content-hashes(
content_hashes: $1.referenced_content_hashes,
then: fn(missing$1024) =>
match @core.list-get(list: $1024, index: 0) {
#some(_) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{key: "eventHash", value: #string<@definy.json>($1.event_hash)},
{key: "status", value: #string<@definy.json>("missing_content")},
{
key: "missingContentHashes",
value: #array<@definy.json>(@definy.json-string-array(items: $1024, index: 0))
}
])
),
#none(_) =>
@definy.check-snapshot(
signed_event_bytes: $0,
then: fn(errors$1025, commit$1027) =>
match @core.list-get(list: $1025, index: 0) {
#none(_) =>
@definy.store-write-event(
signed_event_bytes: $0,
event_hash: $1.event_hash,
account_id: $1.account_id,
event_type: @definy.event-type-name(content: $1.content),
time_ms: $1.time_ms,
then: fn(event_hash$1026) =>
match $1027 {
#none(_) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{key: "eventHash", value: #string<@definy.json>($1026)},
{key: "status", value: #string<@definy.json>("accepted")},
{
key: "missingContentHashes",
value: #array<@definy.json>(@definy.json-string-array(items: [], index: 0))
}
])
),
#some(_) =>
#write_cached_commits({
version: @definy.snapshot-cache-version,
entries: [
{event_hash: $1.event_hash, commit: $1027},
@definy.snapshot-cache-entry-summary(entry: {event_hash: $1.event_hash, commit: $1027})
],
then: fn(written$1028) =>
@definy.json-response(
status: 200,
body: #object<@definy.json>([
{key: "eventHash", value: #string<@definy.json>($1026)},
{key: "status", value: #string<@definy.json>("accepted")},
{
key: "missingContentHashes",
value: #array<@definy.json>(@definy.json-string-array(items: [], index: 0))
}
])
)
})
}
),
#some(_) =>
@definy.rpc-error(code: "invalid_argument", message: @definy.string-join-lines(items: $1025, index: 0, accum: ""))
}
)
}
),
#some(_) =>
@definy.rpc-error(code: "invalid_argument", message: @definy.event-rejection-lines(items: $3, index: 0, accum: ""))
}