- package Friends
-
- import (
- "net/http"
-
- "git.tovijaeschke.xyz/tovi/Envelope/Backend/Database"
-
- "github.com/gorilla/mux"
- )
-
- // RejectFriendRequest rejects friend requests
- func RejectFriendRequest(w http.ResponseWriter, r *http.Request) {
- var (
- friendRequest Database.FriendRequest
- urlVars map[string]string
- friendRequestID string
- ok bool
- err error
- )
-
- urlVars = mux.Vars(r)
- friendRequestID, ok = urlVars["requestID"]
- if !ok {
- http.Error(w, "Not Found", http.StatusNotFound)
- return
- }
-
- friendRequest, err = Database.GetFriendRequestByID(friendRequestID)
- if err != nil {
- http.Error(w, "Error", http.StatusInternalServerError)
- return
- }
-
- err = (&friendRequest).DeleteFriendRequest()
- if err != nil {
- http.Error(w, "Error", http.StatusInternalServerError)
- return
- }
-
- w.WriteHeader(http.StatusNoContent)
- }
|