Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zjwshisb committed Jan 11, 2025
1 parent 7f41fc3 commit 7d16c28
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions api/backend/v1/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ type ChatWaitingUser struct {
}

type ChatSimpleMessage struct {
Id uint `json:"id"`
Type string `json:"type"`
Time *gtime.Time `json:"time"`
Content string `json:"content"`
Expand Down
1 change: 1 addition & 0 deletions internal/controller/backend/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func (c cChat) CancelTransfer(ctx context.Context, _ *v1.CancelTransferReq) (res
admin := service.AdminCtx().GetUser(ctx)
transfer, err := service.ChatTransfer().First(ctx, g.Map{
"to_admin_id": admin.Id,
"id": ghttp.RequestFromCtx(ctx).GetRouter("id").Int(),
})
if err != nil {
return
Expand Down
3 changes: 2 additions & 1 deletion internal/logic/chat/admin_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (m *adminManager) broadcastWaitingUser(ctx context.Context, customerId uint
messages, err := service.ChatMessage().All(ctx, do.CustomerChatMessages{
Source: consts.MessageSourceUser,
SessionId: sessionIds,
}, nil, "id")
}, nil, "id desc")
if err != nil {
return err
}
Expand All @@ -178,6 +178,7 @@ func (m *adminManager) broadcastWaitingUser(ctx context.Context, customerId uint
}
for _, m := range messages {
userMap[m.UserId].Messages = append(userMap[m.UserId].Messages, v1.ChatSimpleMessage{
Id: m.Id,
Type: m.Type,
Time: m.ReceivedAt,
Content: m.Content,
Expand Down
7 changes: 3 additions & 4 deletions internal/logic/chat/chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package chat

import (
"context"
api2 "gf-chat/api"
baseApi "gf-chat/api"
api "gf-chat/api/backend/v1"
"gf-chat/internal/consts"
"gf-chat/internal/model"
Expand Down Expand Up @@ -160,14 +160,13 @@ func (s sChat) Accept(ctx context.Context, admin model.CustomerAdmin, sessionId
}
}
messagesLength := len(messages)
var lastMsg *api2.ChatMessage
var lastMsg *baseApi.ChatMessage
if messagesLength > 0 {
lastMessage := messages[0]
v, err := service.ChatMessage().ToApi(ctx, lastMessage)
lastMsg, err = service.ChatMessage().ToApi(ctx, lastMessage)
if err != nil {
return nil, err
}
lastMsg = v
}
err = service.ChatRelation().AddUser(ctx, admin.Id, session.UserId)
if err != nil {
Expand Down

0 comments on commit 7d16c28

Please sign in to comment.