|
|
|
@ -19,6 +19,7 @@ import (
|
|
|
|
|
"sort"
|
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/authverify"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/dbbuild"
|
|
|
|
|
"github.com/openimsdk/open-im-server/v3/pkg/rpcli"
|
|
|
|
|
|
|
|
|
@ -117,6 +118,9 @@ func Start(ctx context.Context, config *Config, client discovery.Conn, server gr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetConversation(ctx context.Context, req *pbconversation.GetConversationReq) (*pbconversation.GetConversationResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.OwnerUserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversations, err := c.conversationDatabase.FindConversations(ctx, req.OwnerUserID, []string{req.ConversationID})
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -130,7 +134,9 @@ func (c *conversationServer) GetConversation(ctx context.Context, req *pbconvers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetSortedConversationList(ctx context.Context, req *pbconversation.GetSortedConversationListReq) (resp *pbconversation.GetSortedConversationListResp, err error) {
|
|
|
|
|
log.ZDebug(ctx, "GetSortedConversationList", "seqs", req, "userID", req.UserID)
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
var conversationIDs []string
|
|
|
|
|
if len(req.ConversationIDs) == 0 {
|
|
|
|
|
conversationIDs, err = c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
|
|
|
@ -203,6 +209,9 @@ func (c *conversationServer) GetSortedConversationList(ctx context.Context, req
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbconversation.GetAllConversationsReq) (*pbconversation.GetAllConversationsResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.OwnerUserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversations, err := c.conversationDatabase.GetUserAllConversation(ctx, req.OwnerUserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -213,6 +222,9 @@ func (c *conversationServer) GetAllConversations(ctx context.Context, req *pbcon
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetConversations(ctx context.Context, req *pbconversation.GetConversationsReq) (*pbconversation.GetConversationsResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.OwnerUserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversations, err := c.getConversations(ctx, req.OwnerUserID, req.ConversationIDs)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -233,6 +245,9 @@ func (c *conversationServer) getConversations(ctx context.Context, ownerUserID s
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) SetConversation(ctx context.Context, req *pbconversation.SetConversationReq) (*pbconversation.SetConversationResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.GetConversation().GetUserID()); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
var conversation dbModel.Conversation
|
|
|
|
|
if err := datautil.CopyStructFields(&conversation, req.Conversation); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -247,10 +262,11 @@ func (c *conversationServer) SetConversation(ctx context.Context, req *pbconvers
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) SetConversations(ctx context.Context, req *pbconversation.SetConversationsReq) (*pbconversation.SetConversationsResp, error) {
|
|
|
|
|
if req.Conversation == nil {
|
|
|
|
|
return nil, errs.ErrArgs.WrapMsg("conversation must not be nil")
|
|
|
|
|
for _, userID := range req.UserIDs {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, userID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if req.Conversation.ConversationType == constant.WriteGroupChatType {
|
|
|
|
|
groupInfo, err := c.groupClient.GetGroupInfo(ctx, req.Conversation.GroupID)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -331,6 +347,9 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) UpdateConversationsByUser(ctx context.Context, req *pbconversation.UpdateConversationsByUserReq) (*pbconversation.UpdateConversationsByUserResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
m := make(map[string]any)
|
|
|
|
|
if req.Ex != nil {
|
|
|
|
|
m["ex"] = req.Ex.Value
|
|
|
|
@ -343,15 +362,8 @@ func (c *conversationServer) UpdateConversationsByUser(ctx context.Context, req
|
|
|
|
|
return &pbconversation.UpdateConversationsByUserResp{}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Get user IDs with "Do Not Disturb" enabled in super large groups.
|
|
|
|
|
func (c *conversationServer) GetRecvMsgNotNotifyUserIDs(ctx context.Context, req *pbconversation.GetRecvMsgNotNotifyUserIDsReq) (*pbconversation.GetRecvMsgNotNotifyUserIDsResp, error) {
|
|
|
|
|
return nil, errs.New("deprecated")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// create conversation without notification for msg redis transfer.
|
|
|
|
|
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context,
|
|
|
|
|
req *pbconversation.CreateSingleChatConversationsReq,
|
|
|
|
|
) (*pbconversation.CreateSingleChatConversationsResp, error) {
|
|
|
|
|
func (c *conversationServer) CreateSingleChatConversations(ctx context.Context, req *pbconversation.CreateSingleChatConversationsReq) (*pbconversation.CreateSingleChatConversationsResp, error) {
|
|
|
|
|
var conversation dbModel.Conversation
|
|
|
|
|
switch req.ConversationType {
|
|
|
|
|
case constant.SingleChatType:
|
|
|
|
@ -454,6 +466,9 @@ func (c *conversationServer) SetConversationMinSeq(ctx context.Context, req *pbc
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetConversationIDs(ctx context.Context, req *pbconversation.GetConversationIDsReq) (*pbconversation.GetConversationIDsResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversationIDs, err := c.conversationDatabase.GetConversationIDs(ctx, req.UserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -462,6 +477,9 @@ func (c *conversationServer) GetConversationIDs(ctx context.Context, req *pbconv
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req *pbconversation.GetUserConversationIDsHashReq) (*pbconversation.GetUserConversationIDsHashResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.OwnerUserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
hash, err := c.conversationDatabase.GetUserConversationIDsHash(ctx, req.OwnerUserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -469,10 +487,7 @@ func (c *conversationServer) GetUserConversationIDsHash(ctx context.Context, req
|
|
|
|
|
return &pbconversation.GetUserConversationIDsHashResp{Hash: hash}, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetConversationsByConversationID(
|
|
|
|
|
ctx context.Context,
|
|
|
|
|
req *pbconversation.GetConversationsByConversationIDReq,
|
|
|
|
|
) (*pbconversation.GetConversationsByConversationIDResp, error) {
|
|
|
|
|
func (c *conversationServer) GetConversationsByConversationID(ctx context.Context, req *pbconversation.GetConversationsByConversationIDReq) (*pbconversation.GetConversationsByConversationIDResp, error) {
|
|
|
|
|
conversations, err := c.conversationDatabase.GetConversationsByConversationID(ctx, req.ConversationIDs)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -526,10 +541,7 @@ func (c *conversationServer) conversationSort(conversations map[int64]string, re
|
|
|
|
|
resp.ConversationElems = append(resp.ConversationElems, cons...)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) getConversationInfo(
|
|
|
|
|
ctx context.Context,
|
|
|
|
|
chatLogs map[string]*sdkws.MsgData,
|
|
|
|
|
userID string) (map[string]*pbconversation.ConversationElem, error) {
|
|
|
|
|
func (c *conversationServer) getConversationInfo(ctx context.Context, chatLogs map[string]*sdkws.MsgData, userID string) (map[string]*pbconversation.ConversationElem, error) {
|
|
|
|
|
var (
|
|
|
|
|
sendIDs []string
|
|
|
|
|
groupIDs []string
|
|
|
|
@ -615,6 +627,11 @@ func (c *conversationServer) GetConversationNotReceiveMessageUserIDs(ctx context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) UpdateConversation(ctx context.Context, req *pbconversation.UpdateConversationReq) (*pbconversation.UpdateConversationResp, error) {
|
|
|
|
|
for _, userID := range req.UserIDs {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, userID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m := make(map[string]any)
|
|
|
|
|
if req.RecvMsgOpt != nil {
|
|
|
|
|
m["recv_msg_opt"] = req.RecvMsgOpt.Value
|
|
|
|
@ -661,6 +678,9 @@ func (c *conversationServer) UpdateConversation(ctx context.Context, req *pbconv
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetOwnerConversation(ctx context.Context, req *pbconversation.GetOwnerConversationReq) (*pbconversation.GetOwnerConversationResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
total, conversations, err := c.conversationDatabase.GetOwnerConversation(ctx, req.UserID, req.Pagination)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -722,6 +742,9 @@ func (c *conversationServer) GetConversationsNeedClearMsg(ctx context.Context, _
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetNotNotifyConversationIDs(ctx context.Context, req *pbconversation.GetNotNotifyConversationIDsReq) (*pbconversation.GetNotNotifyConversationIDsResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversationIDs, err := c.conversationDatabase.GetNotNotifyConversationIDs(ctx, req.UserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@ -730,6 +753,9 @@ func (c *conversationServer) GetNotNotifyConversationIDs(ctx context.Context, re
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (c *conversationServer) GetPinnedConversationIDs(ctx context.Context, req *pbconversation.GetPinnedConversationIDsReq) (*pbconversation.GetPinnedConversationIDsResp, error) {
|
|
|
|
|
if err := authverify.CheckAccess(ctx, req.UserID); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
conversationIDs, err := c.conversationDatabase.GetPinnedConversationIDs(ctx, req.UserID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|