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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user