Skip to content

Commit

Permalink
refactor(api): update integrations status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AiraNadih authored Oct 14, 2024
1 parent 4b43909 commit 08aca66
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
2 changes: 1 addition & 1 deletion internal/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
sr.HandleFunc("/users/{userID:[0-9]+}", handler.updateUser).Methods(http.MethodPut)
sr.HandleFunc("/users/{userID:[0-9]+}", handler.removeUser).Methods(http.MethodDelete)
sr.HandleFunc("/users/{userID:[0-9]+}/mark-all-as-read", handler.markUserAsRead).Methods(http.MethodPut)
sr.HandleFunc("/users/{userID:[0-9]+}/integrations/status", handler.getIntegrationsStatus).Methods(http.MethodGet)
sr.HandleFunc("/users/integrations/status", handler.getIntegrationsStatus).Methods(http.MethodGet)
sr.HandleFunc("/users/{username}", handler.userByUsername).Methods(http.MethodGet)
sr.HandleFunc("/me", handler.currentUser).Methods(http.MethodGet)
sr.HandleFunc("/categories", handler.createCategory).Methods(http.MethodPost)
Expand Down
6 changes: 1 addition & 5 deletions internal/api/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,7 @@ func (h *handler) markUserAsRead(w http.ResponseWriter, r *http.Request) {
}

func (h *handler) getIntegrationsStatus(w http.ResponseWriter, r *http.Request) {
userID := request.RouteInt64Param(r, "userID")
if userID != request.UserID(r) {
json.Forbidden(w, r)
return
}
userID := request.UserID(r)

if _, err := h.store.UserByID(userID); err != nil {
json.NotFound(w, r)
Expand Down

0 comments on commit 08aca66

Please sign in to comment.