mirror of
https://github.com/notherealmarco/WASAPhoto.git
synced 2025-05-05 12:22:35 +02:00
Add user profile and search in the frontend, fix PutFollow, DeleteFollow behavior in the backend
This commit is contained in:
parent
c4611b92f8
commit
a2d7eb8d13
9 changed files with 367 additions and 16 deletions
|
@ -72,14 +72,14 @@ func (rt *_router) GetFollowersFollowing(w http.ResponseWriter, r *http.Request,
|
|||
func (rt *_router) PutFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params, ctx reqcontext.RequestContext) {
|
||||
|
||||
uid := ps.ByName("user_id")
|
||||
followed := ps.ByName("follower_uid")
|
||||
follower := ps.ByName("follower_uid")
|
||||
|
||||
// send error if the user has no permission to perform this action
|
||||
if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, uid, rt.db, w, rt.baseLogger, http.StatusNotFound) {
|
||||
if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, follower, rt.db, w, rt.baseLogger, http.StatusNotFound) {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := rt.db.FollowUser(uid, followed)
|
||||
status, err := rt.db.FollowUser(follower, uid)
|
||||
|
||||
if err != nil {
|
||||
helpers.SendInternalError(err, "Database error: FollowUser", w, rt.baseLogger)
|
||||
|
@ -102,14 +102,14 @@ func (rt *_router) PutFollow(w http.ResponseWriter, r *http.Request, ps httprout
|
|||
func (rt *_router) DeleteFollow(w http.ResponseWriter, r *http.Request, ps httprouter.Params, ctx reqcontext.RequestContext) {
|
||||
|
||||
uid := ps.ByName("user_id")
|
||||
followed := ps.ByName("follower_uid")
|
||||
follower := ps.ByName("follower_uid")
|
||||
|
||||
// send error if the user has no permission to perform this action
|
||||
if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, uid, rt.db, w, rt.baseLogger, http.StatusNotFound) {
|
||||
if !authorization.SendAuthorizationError(ctx.Auth.UserAuthorized, follower, rt.db, w, rt.baseLogger, http.StatusNotFound) {
|
||||
return
|
||||
}
|
||||
|
||||
status, err := rt.db.UnfollowUser(uid, followed)
|
||||
status, err := rt.db.UnfollowUser(follower, uid)
|
||||
|
||||
if err != nil {
|
||||
helpers.SendInternalError(err, "Database error: UnfollowUser", w, rt.baseLogger)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue