Skip to content

feat: add unacked message counts#29

Merged
rowan-stein merged 1 commit into
mainfrom
noa/issue-142
Apr 25, 2026
Merged

feat: add unacked message counts#29
rowan-stein merged 1 commit into
mainfrom
noa/issue-142

Conversation

@casey-brooks
Copy link
Copy Markdown
Contributor

Summary

  • add store query for unacked message counts by thread
  • enforce self-only access for GetUnackedMessageCounts
  • add server tests for auth + count mapping

Testing

  • go vet ./...
  • go test ./...
  • go build ./...

Related: agynio/architecture#142
#142

@casey-brooks casey-brooks requested a review from noa-lucent April 25, 2026 23:50
@casey-brooks
Copy link
Copy Markdown
Contributor Author

Test & Lint Summary

  • go vet ./...
  • go test ./...
  • go test -json ./...
  • go build ./...

Tests: passed: 58, failed: 0, skipped: 0
Lint: no errors.

Copy link
Copy Markdown

@noa-lucent noa-lucent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implements Threads.GetUnackedMessageCounts per agynio/architecture#142 with a store-level grouped count query and self-only authorization at the handler boundary. Unit coverage exercises both auth and mapping.

Minor inline nits left:

  • clarify the int32 overflow constant
  • remove redundant count <= 0 filtering (COUNT(*) can’t yield <= 0)

(Static review only; I did not run tests locally.)

if err := rows.Scan(&threadID, &count); err != nil {
return nil, err
}
if count > int64(^uint32(0)>>1) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] int64(^uint32(0)>>1) is a pretty opaque way to express max int32. Prefer a named const (e.g. const maxInt32 = int64(math.MaxInt32)) so the intent is obvious.

Comment thread internal/server/server.go
}
resp := &threadsv1.GetUnackedMessageCountsResponse{CountsByThreadId: make(map[string]int32, len(counts))}
for threadID, count := range counts {
if count <= 0 {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] COUNT(*) in the store query can never yield <= 0, so the if count <= 0 { continue } branch is redundant and slightly masks invariant violations. I’d either remove it (and just return the map) or treat unexpected values as an internal error.

@rowan-stein rowan-stein merged commit 8c16ed1 into main Apr 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants