Make answering own the inbox state transition

This commit is contained in:
Ian Gulliver
2026-10-21 12:55:55 -07:00
parent b4a454bab1
commit 259ec5a8bf
3 changed files with 18 additions and 27 deletions
+3 -9
View File
@@ -111,17 +111,11 @@ func (s *Store) ListInbox(ctx context.Context, f InboxFilter) ([]api.InboxItem,
return items, nil
}
type Resolution struct {
Response api.InboxResponse
State api.InboxState
}
func (s *Store) Respond(ctx context.Context, actor string, resolutions []Resolution) error {
func (s *Store) Respond(ctx context.Context, actor string, responses []api.InboxResponse) error {
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
for _, r := range resolutions {
resp := r.Response
for _, resp := range responses {
res, err := tx.ExecContext(ctx, `UPDATE inbox_items SET state = ?, resolved_by = ?, resolved_at = ? WHERE id = ? AND state = ?`,
string(r.State), actor, now(), resp.ItemId, string(api.Open))
string(api.Answered), actor, now(), resp.ItemId, string(api.Open))
if err != nil {
return err
}