Make answering own the inbox state transition
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user