From 7bd5c6a2b4001936ef39675bfe8457b9c8fc0434 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 27 Oct 2022 11:59:35 -0400 Subject: [PATCH] remove repeating logging to reduce unnecessary verbosity --- common/notify.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/notify.go b/common/notify.go index a5cee48..5c738e4 100644 --- a/common/notify.go +++ b/common/notify.go @@ -25,7 +25,6 @@ type notifyService struct { } func (n *notifyService) SendNotify(path string, message map[string]interface{}) error { - url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/" + path body, err := json.Marshal(message) if err != nil { @@ -40,15 +39,13 @@ func (n *notifyService) SendNotify(path string, message map[string]interface{}) return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")") } return nil - } // disk: "sys_disk":{"size":56866869248,"avail":5855485952,"health":true,"used":48099700736} // usb: "sys_usb":[{"name": "sdc","size": 7747397632,"model": "DataTraveler_2.0","avail": 7714418688,"children": null}] func (n *notifyService) SendSystemStatusNotify(message map[string]interface{}) error { - url := strings.TrimSuffix(n.address, "/") + APICasaOSNotify + "/system_status" - fmt.Println(url) + body, err := json.Marshal(message) if err != nil { return err @@ -62,8 +59,8 @@ func (n *notifyService) SendSystemStatusNotify(message map[string]interface{}) e return errors.New("failed to send notify (status code: " + fmt.Sprint(response.StatusCode) + ")") } return nil - } + func NewNotifyService(runtimePath string) (NotifyService, error) { casaosAddressFile := filepath.Join(runtimePath, CasaOSURLFilename) @@ -79,7 +76,7 @@ func NewNotifyService(runtimePath string) (NotifyService, error) { return nil, err } - if response.StatusCode != 200 { + if response.StatusCode != http.StatusOK { return nil, errors.New("failed to ping casaos service") }