chore: checkpoint assessment and inbox integration

This commit is contained in:
TakuyaYagam1 committed 2026-10-08 17:47:30 +03:00
1 parent 88a31ba0d5
commit 5c52fd8b91
31 files changed
+4608 -181

No files matched your search

@@ -0,0 +1,70 @@
package outbound
import (
"context"
"errors"
"time"
"github.com/google/uuid"
"lincodex/backend/internal/domain"
)
var (
// ErrNotificationInboxEntryNotFound covers a missing event and an event
// owned by a different recipient or organization context.
ErrNotificationInboxEntryNotFound = errors.New("notification inbox entry not found")
// ErrNotificationInboxEventConflict reports an event ID reused with
// different immutable recipient or source metadata.
ErrNotificationInboxEventConflict = errors.New("notification inbox event metadata conflicts")
)
const MaxNotificationInboxPageSize = 100
// NotificationInboxRepository stores recipient-scoped event references and
// read state. Implementations can bind these methods to a transaction; the
// standalone PostgreSQL store uses one SQL statement per operation.
type NotificationInboxRepository interface {
// Store inserts one recipient-specific event. It returns false for an
// identical event already stored under the same recipient and event ID.
Store(ctx context.Context, entry domain.NotificationInboxEntry) (created bool, err error)
// List returns one newest-first page for the exact recipient. A nil
// OrganizationID means all organization contexts of that recipient.
List(ctx context.Context, query NotificationInboxListQuery) (NotificationInboxPage, error)
// MarkRead records the first read time in exact recipient and organization
// context. Missing and unauthorized identities share one not-found result.
MarkRead(
ctx context.Context,
recipientUserID uuid.UUID,
organizationID uuid.UUID,
eventID uuid.UUID,
at time.Time,
) (domain.NotificationInboxEntry, error)
}
// NotificationInboxListQuery selects a bounded recipient-owned page.
type NotificationInboxListQuery struct {
RecipientUserID uuid.UUID
OrganizationID *uuid.UUID
After *NotificationInboxPosition
Limit int32
}
// NotificationInboxPosition continues a newest-first inbox page.
type NotificationInboxPosition struct {
OccurredAt time.Time
EventID uuid.UUID
}
// NotificationInboxPage is a bounded page plus whether another row exists.
type NotificationInboxPage struct {
Items []domain.NotificationInboxEntry
HasMore bool
}
// NotificationInboxPositionOf returns the continuation key for an entry.
func NotificationInboxPositionOf(entry domain.NotificationInboxEntry) NotificationInboxPosition {
return NotificationInboxPosition{OccurredAt: entry.OccurredAt(), EventID: entry.EventID()}
}