package Friends import ( "net/http" "git.tovijaeschke.xyz/tovi/Envelope/Backend/Database" "git.tovijaeschke.xyz/tovi/Envelope/Backend/Models" "github.com/gorilla/mux" ) // RejectFriendRequest rejects friend requests func RejectFriendRequest(w http.ResponseWriter, r *http.Request) { var ( friendRequest Models.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) w.WriteHeader(http.StatusInternalServerError) return } err = Database.DeleteFriendRequest(&friendRequest) if err != nil { http.Error(w, "Error", http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError) return } w.WriteHeader(http.StatusNoContent) }