Send notification

This commit is contained in:
Link
2024-02-04 08:15:37 +00:00
parent 2fdbdcf1ec
commit 3db4be01c4
5 changed files with 59 additions and 1 deletions
+16
View File
@@ -1,6 +1,7 @@
package v1
import (
"context"
"crypto/ecdsa"
"encoding/base64"
json2 "encoding/json"
@@ -21,6 +22,7 @@ import (
"github.com/IceWhaleTech/CasaOS-Common/utils/common_err"
"github.com/IceWhaleTech/CasaOS-Common/utils/jwt"
"github.com/IceWhaleTech/CasaOS-Common/utils/logger"
"github.com/IceWhaleTech/CasaOS-UserService/common"
"github.com/IceWhaleTech/CasaOS-UserService/model"
"github.com/IceWhaleTech/CasaOS-UserService/model/system_model"
"github.com/IceWhaleTech/CasaOS-UserService/pkg/config"
@@ -508,6 +510,20 @@ func PostUserCustomConf(c *gin.Context) {
return
}
if name == "system" {
dataMap := make(map[string]string, 1)
dataMap["system"] = string(data)
response, err := service.MyService.MessageBus().PublishEventWithResponse(context.Background(), common.SERVICENAME, "zimaos:user:save_config", dataMap)
if err != nil {
logger.Error("failed to publish event to message bus", zap.Error(err), zap.Any("event", string(data)))
return
}
if response.StatusCode() != http.StatusOK {
logger.Error("failed to publish event to message bus", zap.String("status", response.Status()), zap.Any("response", response))
}
}
c.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: json2.RawMessage(string(data))})
}