add a method for retrieving an user's userpage.
This commit is contained in:
parent
fb3d2e88dd
commit
8d99ff1070
|
@ -31,6 +31,7 @@ func Start(conf common.Conf, db *sql.DB) {
|
||||||
gv1.GET("/users/self", Method(v1.UserSelfGET, db, common.PrivilegeRead))
|
gv1.GET("/users/self", Method(v1.UserSelfGET, db, common.PrivilegeRead))
|
||||||
gv1.GET("/users/whatid/:username", Method(v1.UserWhatsTheIDGET, db, common.PrivilegeRead))
|
gv1.GET("/users/whatid/:username", Method(v1.UserWhatsTheIDGET, db, common.PrivilegeRead))
|
||||||
gv1.GET("/users/full/:id", Method(v1.UserFullGET, db, common.PrivilegeRead))
|
gv1.GET("/users/full/:id", Method(v1.UserFullGET, db, common.PrivilegeRead))
|
||||||
|
gv1.GET("/users/userpage/:id", Method(v1.UserUserpageGET, db, common.PrivilegeRead))
|
||||||
gv1.GET("/badges", Method(v1.BadgesGET, db, common.PrivilegeRead))
|
gv1.GET("/badges", Method(v1.BadgesGET, db, common.PrivilegeRead))
|
||||||
gv1.GET("/badges/:id", Method(v1.BadgeByIDGET, db, common.PrivilegeRead))
|
gv1.GET("/badges/:id", Method(v1.BadgeByIDGET, db, common.PrivilegeRead))
|
||||||
|
|
||||||
|
|
|
@ -268,3 +268,21 @@ LIMIT 1
|
||||||
r.Data = fd
|
r.Data = fd
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserUserpageGET gets an user's userpage, as in the customisable thing.
|
||||||
|
func UserUserpageGET(md common.MethodData) (r common.Response) {
|
||||||
|
var userpage string
|
||||||
|
err := md.DB.QueryRow("SELECT userpage_content FROM users_stats WHERE id = ? LIMIT 1", md.C.Param("id")).Scan(&userpage)
|
||||||
|
switch {
|
||||||
|
case err == sql.ErrNoRows:
|
||||||
|
r.Code = 404
|
||||||
|
r.Message = "No user with that user ID!"
|
||||||
|
case err != nil:
|
||||||
|
md.C.Error(err)
|
||||||
|
r = Err500
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r.Code = 200
|
||||||
|
r.Data = userpage
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user