Start a workflow from the iPhone Action button

This commit is contained in:
Ian Gulliver
2026-10-22 17:02:49 -07:00
parent f8fde62aab
commit 9df0c800dc
13 changed files with 724 additions and 370 deletions
+33
View File
@@ -134,6 +134,39 @@ func repointProjects(ctx context.Context, tx *sql.Tx, emit emitFunc, from, to, a
return err
}
}
return repointUsers(ctx, tx, emit, from, to, actor)
}
func repointUsers(ctx context.Context, tx *sql.Tx, emit emitFunc, from, to, actor string) error {
rows, err := tx.QueryContext(ctx, `
UPDATE users SET
quick_run_workflow = ?2,
quick_run_project = CASE WHEN ?2 = '' THEN NULL ELSE quick_run_project END
WHERE quick_run_workflow = ?1
RETURNING login`, from, to)
if err != nil {
return err
}
logins := []string{}
for rows.Next() {
login := ""
err = rows.Scan(&login)
if err != nil {
rows.Close()
return err
}
logins = append(logins, login)
}
err = errors.Join(rows.Err(), rows.Close())
if err != nil {
return err
}
for _, login := range logins {
err = emit(api.Event{Kind: "user.updated", Actor: actor, Payload: map[string]any{"login": login}})
if err != nil {
return err
}
}
return nil
}