diff --git a/core/watch.go b/core/watch.go index 5da350e..42b23cc 100644 --- a/core/watch.go +++ b/core/watch.go @@ -1,10 +1,8 @@ package core import ( - "bytes" "context" "encoding/hex" - "encoding/json" "net/http" "os" "path" @@ -300,33 +298,7 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux * case "update": data.Service.prepare(mg) - old := mg.service() - - atomic.SwapPointer(&old.divisionsForUsersSerialized, data.Service.divisionsForUsersSerialized) - atomic.SwapPointer(&old.divisionsSerialized, data.Service.divisionsSerialized) - atomic.SwapPointer(&old.admins, data.Service.admins) - atomic.SwapPointer(&old.serviceSerialized, data.Service.serviceSerialized) - atomic.SwapPointer(&old.serviceSummarySerialized, data.Service.serviceSummarySerialized) - atomic.SwapPointer(&old.wl.emailptr, data.Service.wl.emailptr) - - old.Divisions = data.Service.Divisions - for _, div := range old.Divisions { - var req *http.Request - if div.State == DivisionState_FullOpen { - req, _ = http.NewRequest("POST", div.Url+"/maingate", nil) - } else if div.Maintenance != nil { - bt, _ := json.Marshal(div.Maintenance) - req, _ = http.NewRequest("POST", div.Url+"/maingate", bytes.NewBuffer(bt)) - } - - if req != nil { - // MG-X-API-TOKEN - req.Header.Add("MG-X-API-TOKEN", old.ServerApiTokens[0].Hex()) - if resp, err := http.DefaultClient.Do(req); err == nil { - resp.Body.Close() - } - } - } + atomic.StorePointer(&mg.serviceptr, unsafe.Pointer(data.Service)) } } else { logger.Error("watchServiceCollection stream.Decode failed :", err)