on master help sign in
Remove unused eventType from PollEvent
ea274f2iko
client/ApiClient.fs+1−15
@@ -16,22 +16,8 @@ module ApiClient =
16 [<CLIMutable>]
16 [<CLIMutable>]
17 type EventPayload = { EncryptedBlob: string; Timestamp: int64 }
17 type EventPayload = { EncryptedBlob: string; Timestamp: int64 }
18
18
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−
33 [<CLIMutable>]
19 [<CLIMutable>]
34− type PollEvent = { Id: string; EventType: EventType; Payload: EventPayload }
20+ type PollEvent = { Id: string; Payload: EventPayload }
35
21
36 [<CLIMutable>]
22 [<CLIMutable>]
37 type PollResponse = { Cursor: int64; Events: PollEvent array; Authorized: bool; Heartbeat: bool }
23 type PollResponse = { Cursor: int64; Events: PollEvent array; Authorized: bool; Heartbeat: bool }
client/App.fs+1−6
@@ -607,12 +607,7 @@ module App =
607
607
608 let results =
608 let results =
609 response.Events
609 response.Events
610− |> Array.choose (fun evt ->
611− match evt.EventType with
612− | Message -> Some(decryptEvent session.Identity.PrivKey evt.Payload)
610+ |> Array.map (fun evt -> decryptEvent session.Identity.PrivKey evt.Payload)
613− | UnknownEvent s ->
614− log $"unknown event type: {s}"
615− None)
616
611
617 let events = results |> Array.choose Result.toOption |> Array.toList
612 let events = results |> Array.choose Result.toOption |> Array.toList
618
613
server.knot+4−5
@@ -222,11 +222,10 @@ sToMs = \s -> stripUnit s * 1000
222-- and stripped of trailing dots, with a deny-list filter (`isBadServerName`)
222-- and stripped of trailing dots, with a deny-list filter (`isBadServerName`)
223-- applied where SSRF is a concern.
223-- applied where SSRF is a concern.
224
224
225−-- One event in a /poll response. `eventType` is currently always "message"; the
225+-- One event in a /poll response. The payload is the opaque cipher blob plus
226−-- payload is the cipher blob plus delivery metadata for the recipient.
226+-- delivery metadata for the recipient; the server cannot read the blob.
227type PollEvent = {
227type PollEvent = {
228 id: MessageIdHex,
228 id: MessageIdHex,
229− eventType: Text,
230 payload: {encryptedBlob: BlobHex, timestamp: Timestamp, toKey: PubkeyHex, expiresAt: Timestamp}
229 payload: {encryptedBlob: BlobHex, timestamp: Timestamp, toKey: PubkeyHex, expiresAt: Timestamp}
231}
230}
232
231
@@ -1566,7 +1565,7 @@ pollOnce = \authorization cursor cursorWasReset clientIp serverGen respond t ->
1566
1565
1567-- One pass: collect events at `t`. If empty, retry-wait on `pollWakeup`
1566-- One pass: collect events at `t`. If empty, retry-wait on `pollWakeup`
1568-- (bumped by send/heartbeat) and re-collect once at the new wall time.
1567-- (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}
1570doPoll = \s t -> do
1569doPoll = \s t -> do
1571 let collectAt = \tnow -> atomic (do
1570 let collectAt = \tnow -> atomic (do
1572 msgs <- *messages
1571 msgs <- *messages
@@ -1582,7 +1581,7 @@ doPoll = \s t -> do
1582-- Pull this pubkey's unexpired messages newer than `cursor`, sort by
1581-- Pull this pubkey's unexpired messages newer than `cursor`, sort by
1583-- receivedAt, take up to `maxPollEvents`, and report `hasMore` if truncated.
1582-- receivedAt, take up to `maxPollEvents`, and report `hasMore` if truncated.
1584collectPollEvents : [Message] -> PubkeyHex -> Timestamp -> Timestamp -> {events: [PollEvent], cursor: Timestamp, hasMore: Bool}
1583collectPollEvents : [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))
1586
1585
1587-- Treat the supplied cursor as an ack: drop all messages with
1586-- Treat the supplied cursor as an ack: drop all messages with
1588-- receivedAt <= cursor, plus their pending forwards, and record federated
1587-- receivedAt <= cursor, plus their pending forwards, and record federated