mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 10:25:52 +02:00
refactor: notification module
This commit is contained in:
parent
34fa4eb204
commit
ab46d1de7e
41 changed files with 3989 additions and 2411 deletions
|
@ -2,15 +2,16 @@ package site
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
|
||||
"github.com/0xJacky/Nginx-UI/internal/helper"
|
||||
"github.com/0xJacky/Nginx-UI/internal/nginx"
|
||||
"github.com/0xJacky/Nginx-UI/internal/notification"
|
||||
"github.com/go-resty/resty/v2"
|
||||
"github.com/uozi-tech/cosy/logger"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// Enable enables a site by creating a symlink in sites-enabled
|
||||
|
@ -72,14 +73,14 @@ func syncEnable(name string) {
|
|||
SetHeader("X-Node-Secret", node.Token).
|
||||
Post(fmt.Sprintf("/api/sites/%s/enable", name))
|
||||
if err != nil {
|
||||
notification.Error("Enable Remote Site Error", err.Error())
|
||||
notification.Error("Enable Remote Site Error", err.Error(), nil)
|
||||
return
|
||||
}
|
||||
if resp.StatusCode() != http.StatusOK {
|
||||
notification.Error("Enable Remote Site Error", NewSyncResult(node.Name, name, resp).String())
|
||||
notification.Error("Enable Remote Site Error", "Enable site %{name} on %{node} failed", NewSyncResult(node.Name, name, resp))
|
||||
return
|
||||
}
|
||||
notification.Success("Enable Remote Site Success", NewSyncResult(node.Name, name, resp).String())
|
||||
notification.Success("Enable Remote Site Success", "Enable site %{name} on %{node} successfully", NewSyncResult(node.Name, name, resp))
|
||||
}()
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue