|
|
- package Friends
-
- import (
- "encoding/json"
- "net/http"
-
- "git.tovijaeschke.xyz/tovi/Envelope/Backend/Api/Auth"
- "git.tovijaeschke.xyz/tovi/Envelope/Backend/Database"
- "git.tovijaeschke.xyz/tovi/Envelope/Backend/Models"
- )
-
- func EncryptedFriendRequestList(w http.ResponseWriter, r *http.Request) {
- var (
- userSession Models.Session
- friends []Models.FriendRequest
- returnJson []byte
- err error
- )
-
- userSession, err = Auth.CheckCookie(r)
- if err != nil {
- http.Error(w, "Forbidden", http.StatusUnauthorized)
- return
- }
-
- friends, err = Database.GetFriendRequestsByUserId(userSession.UserID.String())
- if err != nil {
- http.Error(w, "Error", http.StatusInternalServerError)
- return
- }
-
- returnJson, err = json.MarshalIndent(friends, "", " ")
- if err != nil {
- http.Error(w, "Error", http.StatusInternalServerError)
- return
- }
-
- w.WriteHeader(http.StatusOK)
- w.Write(returnJson)
- }
|