Skip to content

Commit

Permalink
Allow sending in name to edit server
Browse files Browse the repository at this point in the history
Related: #1195
  • Loading branch information
LordRalex committed Jul 26, 2023
1 parent 6b42571 commit 714cde7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions models/serverapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,8 @@ type ServerSearchResponse struct {
Servers []*ServerView `json:"servers"`
*response.Metadata
}

type ServerWithName struct {
pufferpanel.Server
Name string `json:"name"`
}
6 changes: 5 additions & 1 deletion web/api/servers.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func editServer(c *gin.Context) {

server := c.MustGet("server").(*models.Server)

postBody := &pufferpanel.Server{}
postBody := &models.ServerWithName{}
err = c.Bind(postBody)
if response.HandleError(c, err, http.StatusBadRequest) {
return
Expand All @@ -465,6 +465,10 @@ func editServer(c *gin.Context) {
}
server.IP = cast.ToString(ip)

if postBody.Name != "" {
server.Name = postBody.Name
}

err = ss.Update(server)
if response.HandleError(c, err, http.StatusInternalServerError) {
return
Expand Down

0 comments on commit 714cde7

Please sign in to comment.