chore: package path changes

Signed-off-by: withchao <993506633@qq.com>
pull/672/head
withchao 2 years ago
parent 4fc70a7815
commit 0ed80222fe

@ -16,6 +16,7 @@ package msgtransfer
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"strconv" "strconv"
"strings" "strings"
"sync" "sync"
@ -141,8 +142,8 @@ func (och *OnlineHistoryRedisConsumerHandler) Run(channelID int) {
"modifyMsgList", "modifyMsgList",
len(modifyMsgList), len(modifyMsgList),
) )
conversationIDMsg := utils.GetChatConversationIDByMsg(ctxMsgList[0].message) conversationIDMsg := msgprocessor.GetChatConversationIDByMsg(ctxMsgList[0].message)
conversationIDNotification := utils.GetNotificationConversationID(ctxMsgList[0].message) conversationIDNotification := msgprocessor.GetNotificationConversationID(ctxMsgList[0].message)
och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList) och.handleMsg(ctx, msgChannelValue.uniqueKey, conversationIDMsg, storageMsgList, notStorageMsgList)
och.handleNotification( och.handleNotification(
ctx, ctx,
@ -172,7 +173,7 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
totalMsgs []*ContextMsg, totalMsgs []*ContextMsg,
) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) { ) (storageMsgList, notStorageMsgList, storageNotificatoinList, notStorageNotificationList, modifyMsgList []*sdkws.MsgData) {
isStorage := func(msg *sdkws.MsgData) bool { isStorage := func(msg *sdkws.MsgData) bool {
options2 := utils.Options(msg.Options) options2 := msgprocessor.Options(msg.Options)
if options2.IsHistory() { if options2.IsHistory() {
return true return true
} else { } else {
@ -183,28 +184,28 @@ func (och *OnlineHistoryRedisConsumerHandler) getPushStorageMsgList(
} }
} }
for _, v := range totalMsgs { for _, v := range totalMsgs {
options := utils.Options(v.message.Options) options := msgprocessor.Options(v.message.Options)
if !options.IsNotNotification() { if !options.IsNotNotification() {
// clone msg from notificationMsg // clone msg from notificationMsg
if options.IsSendMsg() { if options.IsSendMsg() {
msg := proto.Clone(v.message).(*sdkws.MsgData) msg := proto.Clone(v.message).(*sdkws.MsgData)
// 消息 // 消息
if v.message.Options != nil { if v.message.Options != nil {
msg.Options = utils.NewMsgOptions() msg.Options = msgprocessor.NewMsgOptions()
} }
if options.IsOfflinePush() { if options.IsOfflinePush() {
v.message.Options = utils.WithOptions( v.message.Options = msgprocessor.WithOptions(
utils.Options(v.message.Options), v.message.Options,
utils.WithOfflinePush(false), msgprocessor.WithOfflinePush(false),
) )
msg.Options = utils.WithOptions(utils.Options(msg.Options), utils.WithOfflinePush(true)) msg.Options = msgprocessor.WithOptions(msg.Options, msgprocessor.WithOfflinePush(true))
} }
if options.IsUnreadCount() { if options.IsUnreadCount() {
v.message.Options = utils.WithOptions( v.message.Options = msgprocessor.WithOptions(
utils.Options(v.message.Options), v.message.Options,
utils.WithUnreadCount(false), msgprocessor.WithUnreadCount(false),
) )
msg.Options = utils.WithOptions(utils.Options(msg.Options), utils.WithUnreadCount(true)) msg.Options = msgprocessor.WithOptions(msg.Options, msgprocessor.WithUnreadCount(true))
} }
storageMsgList = append(storageMsgList, msg) storageMsgList = append(storageMsgList, msg)
} }

@ -17,6 +17,7 @@ package config
import ( import (
_ "embed" _ "embed"
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -24,7 +25,6 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/OpenIMSDK/protocol/constant" "github.com/OpenIMSDK/protocol/constant"
"github.com/OpenIMSDK/tools/utils"
) )
//go:embed version //go:embed version
@ -42,20 +42,20 @@ const (
DefaultFolderPath = "../config/" DefaultFolderPath = "../config/"
) )
func GetOptionsByNotification(cfg NotificationConf) utils.Options { func GetOptionsByNotification(cfg NotificationConf) msgprocessor.Options {
opts := utils.NewOptions() opts := msgprocessor.NewOptions()
if cfg.UnreadCount { if cfg.UnreadCount {
opts = utils.WithOptions(opts, utils.WithUnreadCount(true)) opts = msgprocessor.WithOptions(opts, msgprocessor.WithUnreadCount(true))
} }
if cfg.OfflinePush.Enable { if cfg.OfflinePush.Enable {
opts = utils.WithOptions(opts, utils.WithOfflinePush(true)) opts = msgprocessor.WithOptions(opts, msgprocessor.WithOfflinePush(true))
} }
switch cfg.ReliabilityLevel { switch cfg.ReliabilityLevel {
case constant.UnreliableNotification: case constant.UnreliableNotification:
case constant.ReliableNotificationNoMsg: case constant.ReliableNotificationNoMsg:
opts = utils.WithOptions(opts, utils.WithHistory(true), utils.WithPersistent()) opts = msgprocessor.WithOptions(opts, msgprocessor.WithHistory(true), msgprocessor.WithPersistent())
} }
opts = utils.WithOptions(opts, utils.WithSendMsg(cfg.IsSendMsg)) opts = msgprocessor.WithOptions(opts, msgprocessor.WithSendMsg(cfg.IsSendMsg))
return opts return opts
} }

@ -16,6 +16,7 @@ package cache
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"strconv" "strconv"
"time" "time"
@ -374,7 +375,7 @@ func (c *msgCache) GetMessagesBySeq(
failedSeqs = append(failedSeqs, seqs[i]) failedSeqs = append(failedSeqs, seqs[i])
} else { } else {
msg := sdkws.MsgData{} msg := sdkws.MsgData{}
err = utils.String2Pb(cmd.Val(), &msg) err = msgprocessor.String2Pb(cmd.Val(), &msg)
if err == nil { if err == nil {
if msg.Status != constant.MsgDeleted { if msg.Status != constant.MsgDeleted {
seqMsgs = append(seqMsgs, &msg) seqMsgs = append(seqMsgs, &msg)
@ -394,7 +395,7 @@ func (c *msgCache) SetMessageToCache(ctx context.Context, conversationID string,
var failedMsgs []*sdkws.MsgData var failedMsgs []*sdkws.MsgData
for _, msg := range msgs { for _, msg := range msgs {
key := c.getMessageCacheKey(conversationID, msg.Seq) key := c.getMessageCacheKey(conversationID, msg.Seq)
s, err := utils.Pb2String(msg) s, err := msgprocessor.Pb2String(msg)
if err != nil { if err != nil {
return 0, errs.Wrap(err) return 0, errs.Wrap(err)
} }
@ -535,7 +536,7 @@ func (c *msgCache) DelMsgFromCache(ctx context.Context, userID string, seqs []in
return err return err
} }
msg.Status = constant.MsgDeleted msg.Status = constant.MsgDeleted
s, err := utils.Pb2String(&msg) s, err := msgprocessor.Pb2String(&msg)
if err != nil { if err != nil {
return errs.Wrap(err) return errs.Wrap(err)
} }

@ -16,6 +16,7 @@ package controller
import ( import (
"context" "context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/msgprocessor"
"time" "time"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache" "github.com/OpenIMSDK/Open-IM-Server/pkg/common/db/cache"
@ -236,7 +237,7 @@ func (c *conversationDatabase) FindRecvMsgNotNotifyUserIDs(ctx context.Context,
func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error { func (c *conversationDatabase) CreateGroupChatConversation(ctx context.Context, groupID string, userIDs []string) error {
cache := c.cache.NewCache() cache := c.cache.NewCache()
conversationID := utils.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID) conversationID := msgprocessor.GetConversationIDBySessionType(constant.SuperGroupChatType, groupID)
if err := c.tx.Transaction(func(tx any) error { if err := c.tx.Transaction(func(tx any) error {
existConversationUserIDs, err := c.conversationDB.FindUserID(ctx, userIDs, []string{conversationID}) existConversationUserIDs, err := c.conversationDB.FindUserID(ctx, userIDs, []string{conversationID})
if err != nil { if err != nil {

@ -16,6 +16,7 @@ package startrpc
import ( import (
"fmt" "fmt"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"net" "net"
"strconv" "strconv"
"time" "time"

Loading…
Cancel
Save