opt: add lock for mj task callback

This commit is contained in:
RockYang 2023-09-08 18:12:18 +08:00
parent 153b2bfa53
commit 583218a045
2 changed files with 2 additions and 2 deletions

View File

@ -93,7 +93,7 @@ func (h *ChatHandler) ChatHandle(c *gin.Context) {
Id: chatModel.Id,
Value: chatModel.Value,
Platform: types.Platform(chatModel.Platform)}
logger.Infof("New websocket connected, IP: %s, Username: %s", c.Request.RemoteAddr, session.Username)
logger.Infof("New websocket connected, IP: %s, Username: %s", c.ClientIP(), session.Username)
var chatRole model.ChatRole
res = h.db.First(&chatRole, roleId)
if res.Error != nil || !chatRole.Enable {

View File

@ -85,7 +85,7 @@ func (h *MidJourneyHandler) Notify(c *gin.Context) {
logger.Debugf("收到 MidJourney 回调请求:%+v", data)
h.lock.Lock()
defer h.lock.Unlock()
// the job is saved
var job model.MidJourneyJob
res := h.db.Where("message_id = ?", data.MessageId).First(&job)