Plan 3
This commit is contained in:
@@ -190,6 +190,37 @@ func (s *Store) Respond(ctx context.Context, actor string, resolutions []Resolut
|
||||
})
|
||||
}
|
||||
|
||||
func dismissTaskInbox(ctx context.Context, tx *sql.Tx, emit emitFunc, taskID, actor string) error {
|
||||
ids := []string{}
|
||||
rows, err := tx.QueryContext(ctx, `SELECT id FROM inbox_items WHERE task_id = ? AND state = ?`, taskID, string(api.Open))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for rows.Next() {
|
||||
id := ""
|
||||
err = rows.Scan(&id)
|
||||
if err != nil {
|
||||
rows.Close()
|
||||
return err
|
||||
}
|
||||
ids = append(ids, id)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
for _, id := range ids {
|
||||
_, err = tx.ExecContext(ctx, `UPDATE inbox_items SET state = ?, resolved_by = ?, resolved_at = ?, snoozed_until = NULL WHERE id = ?`,
|
||||
string(api.Dismissed), actor, now(), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = emitItem(ctx, tx, emit, "inbox.updated", id, actor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Store) AwaitingHuman(ctx context.Context, sessionID string) (int, error) {
|
||||
n := 0
|
||||
err := s.db.QueryRowContext(ctx, `
|
||||
|
||||
Reference in New Issue
Block a user