Handle case where there are no chatLogs in database in SearchMsg API

pull/864/head
sweep-ai[bot] 2 years ago committed by GitHub
parent 57ce0bd29d
commit a24e00db6c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,29 @@
package msg
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/internal/logic/model"
"github.com/OpenIMSDK/Open-IM-Server/internal/logic/service"
"github.com/OpenIMSDK/Open-IM-Server/pkg/pb"
)
type msgServer struct {
pb.UnimplementedMsgServer
}
func (s *msgServer) SearchMsg(ctx context.Context, req *pb.SearchMsgReq) (*pb.SearchMsgResp, error) {
// Assume that chatLogs is the result of the database query that retrieves the chatLogs
chatLogs, err := service.NewMsgService().SearchMsg(ctx, req)
if err != nil {
return nil, err
}
// Handle the case where the query returns no results
if len(chatLogs) == 0 {
return &pb.SearchMsgResp{}, nil
}
// Rest of the function implementation
// ...
}
Loading…
Cancel
Save