Fix source updating

This commit is contained in:
nemunaire 2020-12-01 16:28:54 +01:00
parent 55db4db0c8
commit d8b123f38a
3 changed files with 9 additions and 12 deletions

View File

@ -39,12 +39,11 @@ import (
)
type FormState struct {
Id int64 `json:"_id,omitempty"`
IdB []byte `json:"_id,omitempty"`
Name string `json:"_comment"`
State int32 `json:"state"`
Recall *int64 `json:"recall,omitempty"`
Redirect *string `json:"redirect,omitempty"`
Id interface{} `json:"_id,omitempty"`
Name string `json:"_comment"`
State int32 `json:"state"`
Recall *int64 `json:"recall,omitempty"`
Redirect *string `json:"redirect,omitempty"`
}
type FormResponse struct {
@ -57,7 +56,6 @@ func formDoState(cfg *config.Options, req *RequestResources, fs *FormState, data
req.Session.GetValue(fmt.Sprintf("form-%d", *fs.Recall), data)
req.Session.GetValue(fmt.Sprintf("form-%d-name", *fs.Recall), &fs.Name)
req.Session.GetValue(fmt.Sprintf("form-%d-id", *fs.Recall), &fs.Id)
req.Session.GetValue(fmt.Sprintf("form-%d-idb", *fs.Recall), &fs.IdB)
req.Session.GetValue(fmt.Sprintf("form-%d-next", *fs.Recall), &fs.Redirect)
}
@ -74,7 +72,6 @@ func formDoState(cfg *config.Options, req *RequestResources, fs *FormState, data
key, recallid := req.Session.FindNewKey("form-")
req.Session.SetValue(key, data)
req.Session.SetValue(key+"-id", fs.Id)
req.Session.SetValue(key+"-idb", fs.IdB)
if fs.Redirect != nil {
req.Session.SetValue(key+"-next", *fs.Redirect)
}

View File

@ -86,7 +86,7 @@ func getServiceSettingsState(cfg *config.Options, req *RequestResources, body io
return APIErrorResponse{
err: err,
}
} else if ups.Id == 0 {
} else if ups.Id == nil {
// Append a new Service
if err = req.Zone.AppendService(string(req.Ps.ByName("subdomain")), req.Domain.DomainName, &happydns.ServiceCombined{Service: ups.Service}); err != nil {
return APIErrorResponse{
@ -106,7 +106,7 @@ func getServiceSettingsState(cfg *config.Options, req *RequestResources, body io
}
} else {
// Update an existing Service
if err = req.Zone.EraseServiceWithoutMeta(string(req.Ps.ByName("subdomain")), req.Domain.DomainName, ups.IdB, ups); err != nil {
if err = req.Zone.EraseServiceWithoutMeta(string(req.Ps.ByName("subdomain")), req.Domain.DomainName, ups.Id.([]byte), ups); err != nil {
return APIErrorResponse{
err: err,
}

View File

@ -91,7 +91,7 @@ func getSourceSettingsState(cfg *config.Options, req *RequestResources, body io.
return APIErrorResponse{
err: err,
}
} else if uss.Id == 0 {
} else if uss.Id == nil {
// Create a new Source
if s, err := storage.MainStore.CreateSource(req.User, src, uss.Name); err != nil {
return APIErrorResponse{
@ -107,7 +107,7 @@ func getSourceSettingsState(cfg *config.Options, req *RequestResources, body io.
}
} else {
// Update an existing Source
if s, err := storage.MainStore.GetSource(req.User, uss.Id); err != nil {
if s, err := storage.MainStore.GetSource(req.User, int64(uss.Id.(float64))); err != nil {
return APIErrorResponse{
err: err,
}