func (api *Api) pluginUnsubsribe(rw http.ResponseWriter, r *http.Request, user *account.User) { service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(service.Team, user) if err != nil { handleError(rw, err) return } plugin, err := account.FindPluginByNameAndService(mux.Vars(r)["plugin_name"], *service) if err != nil { handleError(rw, err) return } if err = plugin.Delete(); err != nil { handleError(rw, err) return } Ok(rw, plugin) }
func (api *Api) pluginSubsribe(rw http.ResponseWriter, r *http.Request, user *account.User) { service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(service.Team, user) if err != nil { handleError(rw, err) return } plugin := account.Plugin{} if err := json.NewDecoder(r.Body).Decode(&plugin); err != nil { handleError(rw, errors.ErrBadRequest) return } err = plugin.Save(*service) if err != nil { handleError(rw, err) return } Ok(rw, plugin) }
func (api *Api) serviceUpdate(rw http.ResponseWriter, r *http.Request, user *account.User) { service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(service.Team, user) if err != nil { handleError(rw, err) return } if err := json.NewDecoder(r.Body).Decode(&service); err != nil { handleError(rw, errors.ErrBadRequest) return } // It is not allowed to change the subdomain yet. service.Subdomain = mux.Vars(r)["subdomain"] err = service.Update() if err != nil { handleError(rw, err) return } go api.EventNotifier(newServiceEvent("service.update", *service)) Ok(rw, service) }
func (api *Api) serviceInfo(rw http.ResponseWriter, r *http.Request, user *account.User) { service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"]) if err != nil { handleError(rw, err) return } _, err = findTeamAndCheckUser(service.Team, user) if err != nil { handleError(rw, err) return } Ok(rw, service) }
func (api *Api) serviceDelete(rw http.ResponseWriter, r *http.Request, user *account.User) { service, err := account.FindServiceBySubdomain(mux.Vars(r)["subdomain"]) if err != nil { handleError(rw, err) return } if err = service.Delete(*user); err != nil { handleError(rw, err) return } go api.EventNotifier(newServiceEvent("service.delete", *service)) Ok(rw, service) }