Start a workflow from the iPhone Action button
This commit is contained in:
@@ -41,6 +41,37 @@ func (s *Server) UpdateDefaultModel(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSON(w, http.StatusOK, u)
|
||||
}
|
||||
|
||||
func (s *Server) UpdateQuickRun(w http.ResponseWriter, r *http.Request) {
|
||||
req := api.QuickRun{}
|
||||
if !readJSON(w, r, &req) {
|
||||
return
|
||||
}
|
||||
|
||||
if (req.ProjectId == "") != (req.Workflow == "") {
|
||||
writeError(w, http.StatusBadRequest, errors.New("project_id and workflow are set together"))
|
||||
return
|
||||
}
|
||||
if req.ProjectId != "" {
|
||||
_, err := s.store.GetProject(r.Context(), req.ProjectId)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
_, err = s.store.GetWorkflow(r.Context(), req.Workflow)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
u, err := s.store.UpdateQuickRun(r.Context(), actor(r), req)
|
||||
if err != nil {
|
||||
writeStoreError(w, err)
|
||||
return
|
||||
}
|
||||
writeJSON(w, http.StatusOK, u)
|
||||
}
|
||||
|
||||
func (s *Server) UpdateAway(w http.ResponseWriter, r *http.Request) {
|
||||
req := api.Away{}
|
||||
if !readJSON(w, r, &req) {
|
||||
|
||||
Reference in New Issue
Block a user