Fix inbox questions vanishing
This commit is contained in:
@@ -32,33 +32,6 @@ func DeliverableResponse(t api.InboxResponseType) bool {
|
||||
|
||||
func (s *Store) CreateInboxItem(ctx context.Context, item api.InboxItem) error {
|
||||
return s.write(ctx, func(tx *sql.Tx, emit emitFunc) error {
|
||||
superseded := []string{}
|
||||
rows, err := tx.QueryContext(ctx, `SELECT id FROM inbox_items WHERE thread_id = ? AND state = ?`, item.ThreadId, string(api.Open))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for rows.Next() {
|
||||
id := ""
|
||||
err = rows.Scan(&id)
|
||||
if err != nil {
|
||||
rows.Close()
|
||||
return err
|
||||
}
|
||||
superseded = append(superseded, id)
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
for _, id := range superseded {
|
||||
_, err = tx.ExecContext(ctx, `UPDATE inbox_items SET state = ? WHERE id = ?`, string(api.Superseded), id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
err = emitItem(ctx, tx, emit, "inbox.updated", id, agentActor)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(item.Payload)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user