refactor: agentic comment cleanup
This commit is contained in:
@@ -11,14 +11,12 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// PusherClient is the subset of the pusher gRPC service the notifier needs.
|
||||
// Defined here (rather than depending on the generated client interface) so
|
||||
// tests can supply a fake without standing up a gRPC server.
|
||||
// PusherClient is a narrow subset of the pusher gRPC service so tests can
|
||||
// supply a fake without standing up a real server.
|
||||
type PusherClient interface {
|
||||
IsOnline(ctx context.Context, in *pbpusher.IsOnlineRequest, opts ...grpc.CallOption) (*pbpusher.IsOnlineResponse, error)
|
||||
}
|
||||
|
||||
// NotifyInput is everything the notifier needs to know about a single newly-created particle.
|
||||
type NotifyInput struct {
|
||||
NetworkID string
|
||||
SenderHumanID string
|
||||
@@ -39,12 +37,11 @@ type NotifyInput struct {
|
||||
Body string
|
||||
}
|
||||
|
||||
// Notifier orchestrates the per-particle fanout:
|
||||
// 1. Resolve recipients (stream visibility ∩ network members, minus sender).
|
||||
// 2. Filter out anyone with an active WebSocket connection.
|
||||
// 3. Look up each remaining human's push tokens.
|
||||
// 4. POST a single batched request to Expo.
|
||||
// 5. Delete any token Expo reports as DeviceNotRegistered.
|
||||
// Notifier fans out one particle to Expo:
|
||||
// 1. Resolve recipients (visibility ∩ network members, minus sender).
|
||||
// 2. Drop anyone currently connected via WebSocket.
|
||||
// 3. Send a batched Expo request for the remainder's tokens.
|
||||
// 4. Prune tokens Expo reports as DeviceNotRegistered.
|
||||
type Notifier struct {
|
||||
networkR network.Reader
|
||||
tokens Service
|
||||
@@ -127,9 +124,8 @@ func (n *Notifier) queryOnline(ctx context.Context, humanIDs []string) (map[stri
|
||||
return resp.Online, nil
|
||||
}
|
||||
|
||||
// cleanupDeadTokens DELETEs any token Expo reports as DeviceNotRegistered.
|
||||
// This is the one feedback signal we honor — other ticket errors (e.g.
|
||||
// MessageTooBig, RateLimit) are logged but never retried.
|
||||
// DeviceNotRegistered is the one feedback signal we honor; other ticket
|
||||
// errors (MessageTooBig, RateLimit, …) are logged and dropped.
|
||||
func (n *Notifier) cleanupDeadTokens(ctx context.Context, msgs []Message, tickets []Ticket) {
|
||||
for i, t := range tickets {
|
||||
if i >= len(msgs) {
|
||||
@@ -160,12 +156,12 @@ func buildMessages(tokens []*PushToken, in NotifyInput) []Message {
|
||||
}
|
||||
|
||||
data := map[string]any{
|
||||
"kind": "particle_created",
|
||||
"network_id": in.NetworkID,
|
||||
"stream_id": in.StreamID,
|
||||
"particle_id": in.ParticleID,
|
||||
"sender_human_id": in.SenderHumanID,
|
||||
"particle_kind": in.ParticleKind,
|
||||
"kind": "particle_created",
|
||||
"network_id": in.NetworkID,
|
||||
"stream_id": in.StreamID,
|
||||
"particle_id": in.ParticleID,
|
||||
"sender_human_id": in.SenderHumanID,
|
||||
"particle_kind": in.ParticleKind,
|
||||
}
|
||||
|
||||
msgs := make([]Message, 0, len(tokens))
|
||||
|
||||
Reference in New Issue
Block a user