fix: make reminder actions use real resources

This commit is contained in:
Codex Local
2026-08-30 21:22:21 +08:00
parent dcf0fc0d7f
commit 78e0a19acb
7 changed files with 103 additions and 31 deletions
+4 -2
View File
@@ -15,6 +15,7 @@ var ErrCursorUnavailable = errors.New("web event cursor is unavailable")
type Event struct {
ID int64 `json:"id"`
Type string `json:"type"`
HouseholdID string `json:"household_id"`
ResourceType string `json:"resource_type"`
ResourceID string `json:"resource_id"`
SubjectID string `json:"subject_id,omitempty"`
@@ -65,9 +66,10 @@ func (s *Service) ListAfter(ctx context.Context, principal identity.Principal, c
limit = 100
}
rows, err := s.pool.Query(ctx, `
SELECT we.id,we.event_type,we.resource_type,we.resource_public_id::text,
SELECT we.id,we.event_type,h.public_id::text,we.resource_type,we.resource_public_id::text,
COALESCE(sp.public_id::text,''),we.status,we.occurred_at
FROM web_event we
JOIN household h ON h.id=we.household_id AND h.tenant_id=we.tenant_id
JOIN household_member hm ON hm.tenant_id=we.tenant_id AND hm.household_id=we.household_id AND hm.status='active'
JOIN user_account ua ON ua.id=hm.user_id AND ua.tenant_id=we.tenant_id AND ua.status='active'
LEFT JOIN subject_profile sp ON sp.id=we.subject_id AND sp.tenant_id=we.tenant_id
@@ -80,7 +82,7 @@ func (s *Service) ListAfter(ctx context.Context, principal identity.Principal, c
items := make([]Event, 0)
for rows.Next() {
var item Event
if err := rows.Scan(&item.ID, &item.Type, &item.ResourceType, &item.ResourceID, &item.SubjectID, &item.Status, &item.OccurredAt); err != nil {
if err := rows.Scan(&item.ID, &item.Type, &item.HouseholdID, &item.ResourceType, &item.ResourceID, &item.SubjectID, &item.Status, &item.OccurredAt); err != nil {
return nil, err
}
items = append(items, item)
@@ -67,7 +67,7 @@ func TestServiceCursorIsolationCleanupAndPresenceExpiry(t *testing.T) {
t.Fatalf("cross-user cursor error=%v", err)
}
items, err := service.ListAfter(ctx, owner, ids[0], 1)
if err != nil || len(items) != 1 || items[0].ID != ids[1] || items[0].SubjectID != "10000000-0000-0000-0000-000000000411" {
if err != nil || len(items) != 1 || items[0].ID != ids[1] || items[0].HouseholdID != "10000000-0000-0000-0000-000000000211" || items[0].SubjectID != "10000000-0000-0000-0000-000000000411" {
t.Fatalf("events=%+v err=%v", items, err)
}
allItems, err := service.ListAfter(ctx, owner, 0, 0)