on master help sign in
Remove unused eventType from PollEvent
commitea274f2eef1e592391fc60c1b7d7aebc4cfc3692 authoriko <mail@iko.soy> dateSun 3 May 2026, 15:22 (5 months ago) parentc6fb6dd
3 files changed+6−26
client/ApiClient.fs+1−15 client/App.fs+1−6 server.knot+4−5
client/ApiClient.fs+1−15
@@ -16,22 +16,8 @@ module ApiClient =
1616 [<CLIMutable>]
1717 type EventPayload = { EncryptedBlob: string; Timestamp: int64 }
1818
19− [<JsonConverter(typeof<EventTypeConverter>)>]
20− type EventType = Message | UnknownEvent of string
21− and private EventTypeConverter() =
22− inherit JsonConverter<EventType>()
23− override _.Read(reader, _, _) =
24− match reader.GetString() with
25− | "message" -> Message
26− | s -> UnknownEvent s
27− override _.Write(writer, value, _) =
28− writer.WriteStringValue(
29− match value with
30− | Message -> "message"
31− | UnknownEvent s -> s)
32−
3319 [<CLIMutable>]
34− type PollEvent = { Id: string; EventType: EventType; Payload: EventPayload }
20+ type PollEvent = { Id: string; Payload: EventPayload }
3521
3622 [<CLIMutable>]
3723 type PollResponse = { Cursor: int64; Events: PollEvent array; Authorized: bool; Heartbeat: bool }
client/App.fs+1−6
@@ -607,12 +607,7 @@ module App =
607607
608608 let results =
609609 response.Events
610− |> Array.choose (fun evt ->
611− match evt.EventType with
612− | Message -> Some(decryptEvent session.Identity.PrivKey evt.Payload)
613− | UnknownEvent s ->
614− log $"unknown event type: {s}"
615− None)
610+ |> Array.map (fun evt -> decryptEvent session.Identity.PrivKey evt.Payload)
616611
617612 let events = results |> Array.choose Result.toOption |> Array.toList
618613
server.knot+4−5
@@ -222,11 +222,10 @@ sToMs = \s -> stripUnit s * 1000
222222-- and stripped of trailing dots, with a deny-list filter (`isBadServerName`)
223223-- applied where SSRF is a concern.
224224
225−-- One event in a /poll response. `eventType` is currently always "message"; the
226−-- payload is the cipher blob plus delivery metadata for the recipient.
225+-- One event in a /poll response. The payload is the opaque cipher blob plus
226+-- delivery metadata for the recipient; the server cannot read the blob.
227227type PollEvent = {
228228 id: MessageIdHex,
229− eventType: Text,
230229 payload: {encryptedBlob: BlobHex, timestamp: Timestamp, toKey: PubkeyHex, expiresAt: Timestamp}
231230}
232231
@@ -1566,7 +1565,7 @@ pollOnce = \authorization cursor cursorWasReset clientIp serverGen respond t ->
15661565
15671566-- One pass: collect events at `t`. If empty, retry-wait on `pollWakeup`
15681567-- (bumped by send/heartbeat) and re-collect once at the new wall time.
1569−doPoll : {clampedCursor: Int, pendingAcks: [AckedEntry], pubkey: PubkeyHex, startWakeup: Timestamp} -> Int<Ms> -> IO {r *pollWakeup, clock} {cursor: Int<Ms>, events: [{eventType: Text, id: MessageIdHex, payload: {encryptedBlob: BlobHex, expiresAt: Timestamp, timestamp: Timestamp, toKey: PubkeyHex}}], hasMore: Bool}
1568+doPoll : {clampedCursor: Int, pendingAcks: [AckedEntry], pubkey: PubkeyHex, startWakeup: Timestamp} -> Int<Ms> -> IO {r *pollWakeup, clock} {cursor: Int<Ms>, events: [{id: MessageIdHex, payload: {encryptedBlob: BlobHex, expiresAt: Timestamp, timestamp: Timestamp, toKey: PubkeyHex}}], hasMore: Bool}
15701569doPoll = \s t -> do
15711570 let collectAt = \tnow -> atomic (do
15721571 msgs <- *messages
@@ -1582,7 +1581,7 @@ doPoll = \s t -> do
15821581-- Pull this pubkey's unexpired messages newer than `cursor`, sort by
15831582-- receivedAt, take up to `maxPollEvents`, and report `hasMore` if truncated.
15841583collectPollEvents : [Message] -> PubkeyHex -> Timestamp -> Timestamp -> {events: [PollEvent], cursor: Timestamp, hasMore: Bool}
1585−collectPollEvents = \messages pubkey cursor t -> (\myMsgs -> (\limited -> {events: pluck limited (\m -> {id: m.messageId, eventType: "message", payload: {m.toKey, m.encryptedBlob, m.timestamp, m.expiresAt}}), cursor: fold (\acc m -> max acc m.receivedAt) cursor limited, hasMore: count myMsgs > count limited}) (takeRelation maxPollEvents (sortBy (\m -> m.receivedAt) myMsgs))) (filter messages (\m -> m.toKey == pubkey && m.expiresAt > t && m.receivedAt > cursor))
1584+collectPollEvents = \messages pubkey cursor t -> (\myMsgs -> (\limited -> {events: pluck limited (\m -> {id: m.messageId, payload: {m.toKey, m.encryptedBlob, m.timestamp, m.expiresAt}}), cursor: fold (\acc m -> max acc m.receivedAt) cursor limited, hasMore: count myMsgs > count limited}) (takeRelation maxPollEvents (sortBy (\m -> m.receivedAt) myMsgs))) (filter messages (\m -> m.toKey == pubkey && m.expiresAt > t && m.receivedAt > cursor))
15861585
15871586-- Treat the supplied cursor as an ack: drop all messages with
15881587-- receivedAt <= cursor, plus their pending forwards, and record federated