Add POST users/self/userpage
This commit is contained in:
parent
6c8d7baee2
commit
1c2201317f
|
@ -118,6 +118,7 @@ func Start(conf common.Conf, dbO *sqlx.DB) *gin.Engine {
|
||||||
gv1.GET("/friends/add", Method(v1.FriendsAddGET, common.PrivilegeWrite))
|
gv1.GET("/friends/add", Method(v1.FriendsAddGET, common.PrivilegeWrite))
|
||||||
gv1.GET("/friends/del", Method(v1.FriendsDelGET, common.PrivilegeWrite))
|
gv1.GET("/friends/del", Method(v1.FriendsDelGET, common.PrivilegeWrite))
|
||||||
gv1.POST("/users/self/settings", Method(v1.UsersSelfSettingsPOST, common.PrivilegeWrite))
|
gv1.POST("/users/self/settings", Method(v1.UsersSelfSettingsPOST, common.PrivilegeWrite))
|
||||||
|
gv1.POST("/users/self/userpage", Method(v1.UserSelfUserpagePOST, common.PrivilegeWrite))
|
||||||
//gv1.POST("/beatmaps/rank_requests", Method(v1.BeatmapRankRequestsSubmitPOST, common.PrivilegeWrite))
|
//gv1.POST("/beatmaps/rank_requests", Method(v1.BeatmapRankRequestsSubmitPOST, common.PrivilegeWrite))
|
||||||
|
|
||||||
// Admin: beatmap
|
// Admin: beatmap
|
||||||
|
|
|
@ -333,6 +333,23 @@ func UserUserpageGET(md common.MethodData) common.CodeMessager {
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UserSelfUserpagePOST allows to change the current user's userpage.
|
||||||
|
func UserSelfUserpagePOST(md common.MethodData) common.CodeMessager {
|
||||||
|
var d struct {
|
||||||
|
Data *string `json:"data"`
|
||||||
|
}
|
||||||
|
md.RequestData.Unmarshal(&d)
|
||||||
|
if d.Data == nil {
|
||||||
|
return ErrMissingField("data")
|
||||||
|
}
|
||||||
|
_, err := md.DB.Exec("UPDATE users_stats SET userpage_content = ? WHERE id = ? LIMIT 1", *d.Data, md.ID())
|
||||||
|
if err != nil {
|
||||||
|
md.Err(err)
|
||||||
|
}
|
||||||
|
md.C.Request.URL.RawQuery += "&id=" + strconv.Itoa(md.ID())
|
||||||
|
return UserUserpageGET(md)
|
||||||
|
}
|
||||||
|
|
||||||
func whereClauseUser(md common.MethodData, tableName string) (*common.CodeMessager, string, interface{}) {
|
func whereClauseUser(md common.MethodData, tableName string) (*common.CodeMessager, string, interface{}) {
|
||||||
switch {
|
switch {
|
||||||
case md.Query("id") == "self":
|
case md.Query("id") == "self":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user