add getting user
This commit is contained in:
@@ -333,6 +333,7 @@ func HandleUserGetConnections(response http.ResponseWriter, request *http.Reques
|
||||
return
|
||||
}
|
||||
ctx := request.Context()
|
||||
|
||||
user, err := getUserByToken(ctx, request.FormValue("token"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
|
||||
@@ -314,6 +314,39 @@ func HandleUserModProfileBg(response http.ResponseWriter, request *http.Request)
|
||||
http.Error(response, "internal server error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
}
|
||||
|
||||
func HandleUserGetUser(response http.ResponseWriter, request *http.Request) {
|
||||
if !postValidCheckWithResponseOnFail(&response, request, postNormal) {
|
||||
return
|
||||
}
|
||||
ctx := request.Context()
|
||||
|
||||
_, err := getUserByToken(ctx, request.FormValue("token"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid token", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
targetId, err := convertions.ConvertStringUuid(request.FormValue("targetid"))
|
||||
if err != nil {
|
||||
http.Error(response, "invalid userid", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
target, err := getUserById(ctx, targetId)
|
||||
if err != nil {
|
||||
http.Error(response, "invalid userid", http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
json, err := json2.Marshal(target)
|
||||
if err != nil {
|
||||
http.Error(response, "json parse error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
|
||||
response.WriteHeader(http.StatusAccepted)
|
||||
response.Write(json)
|
||||
}
|
||||
|
||||
+12
-12
@@ -25,18 +25,18 @@ func (r Rgba) GetRandom() *Rgba {
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Mu sync.RWMutex
|
||||
Name string
|
||||
Pronouns string
|
||||
Description string
|
||||
Avatar string
|
||||
ProfileBg string
|
||||
PasswordHash string
|
||||
CreatedAt time.Time
|
||||
WsConn *websocket.Conn
|
||||
Id uuid.UUID
|
||||
Connections map[uuid.UUID]*Connection
|
||||
Color *Rgba
|
||||
Mu sync.RWMutex `json:"-"`
|
||||
Name string `json:"name"`
|
||||
Pronouns string `json:"pronouns"`
|
||||
Description string `json:"description"`
|
||||
Avatar string `json:"avatar"`
|
||||
ProfileBg string `json:"profileBg"`
|
||||
PasswordHash string `json:"passwordHash"`
|
||||
CreatedAt time.Time `json:"createdAt"`
|
||||
WsConn *websocket.Conn `json:"-"`
|
||||
Id uuid.UUID `json:"-"`
|
||||
Connections map[uuid.UUID]*Connection `json:"-"`
|
||||
Color *Rgba `json:"color"`
|
||||
}
|
||||
|
||||
type UserProfileUpdateList struct {
|
||||
|
||||
Reference in New Issue
Block a user