Start a workflow from the iPhone Action button
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user