mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
feat: use robot to migrate code
Signed-off-by: kubbot & kubecub <3293172751ysy@gmail.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package unrelation
|
||||
|
||||
type CommonUserModel struct {
|
||||
UserID string `bson:"user_id"`
|
||||
UserName string `bson:"user_name"`
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package unrelation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
)
|
||||
|
||||
const (
|
||||
CExtendMsgSet = "extend_msgs"
|
||||
|
||||
ExtendMsgMaxNum = 100
|
||||
)
|
||||
|
||||
type ExtendMsgSetModel struct {
|
||||
ConversationID string `bson:"source_id" json:"conversationID"`
|
||||
SessionType int32 `bson:"session_type" json:"sessionType"`
|
||||
ExtendMsgs map[string]ExtendMsgModel `bson:"extend_msgs" json:"extendMsgs"`
|
||||
ExtendMsgNum int32 `bson:"extend_msg_num" json:"extendMsgNum"`
|
||||
CreateTime int64 `bson:"create_time" json:"createTime"` // this block's create time
|
||||
MaxMsgUpdateTime int64 `bson:"max_msg_update_time" json:"maxMsgUpdateTime"` // index find msg
|
||||
}
|
||||
|
||||
type KeyValueModel struct {
|
||||
TypeKey string `bson:"type_key" json:"typeKey"`
|
||||
Value string `bson:"value" json:"value"`
|
||||
LatestUpdateTime int64 `bson:"latest_update_time" json:"latestUpdateTime"`
|
||||
}
|
||||
|
||||
type ExtendMsgModel struct {
|
||||
ReactionExtensionList map[string]KeyValueModel `bson:"reaction_extension_list" json:"reactionExtensionList"`
|
||||
ClientMsgID string `bson:"client_msg_id" json:"clientMsgID"`
|
||||
MsgFirstModifyTime int64 `bson:"msg_first_modify_time" json:"msgFirstModifyTime"` // this extendMsg create time
|
||||
AttachedInfo string `bson:"attached_info" json:"attachedInfo"`
|
||||
Ex string `bson:"ex" json:"ex"`
|
||||
}
|
||||
|
||||
type ExtendMsgSetModelInterface interface {
|
||||
CreateExtendMsgSet(ctx context.Context, set *ExtendMsgSetModel) error
|
||||
GetAllExtendMsgSet(ctx context.Context, conversationID string, opts *GetAllExtendMsgSetOpts) (sets []*ExtendMsgSetModel, err error)
|
||||
GetExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, maxMsgUpdateTime int64) (*ExtendMsgSetModel, error)
|
||||
InsertExtendMsg(ctx context.Context, conversationID string, sessionType int32, msg *ExtendMsgModel) error
|
||||
InsertOrUpdateReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
|
||||
DeleteReactionExtendMsgSet(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
|
||||
TakeExtendMsg(ctx context.Context, conversationID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *ExtendMsgModel, err error)
|
||||
}
|
||||
|
||||
func (ExtendMsgSetModel) TableName() string {
|
||||
return CExtendMsgSet
|
||||
}
|
||||
|
||||
func (ExtendMsgSetModel) GetExtendMsgMaxNum() int32 {
|
||||
return ExtendMsgMaxNum
|
||||
}
|
||||
|
||||
func (ExtendMsgSetModel) GetConversationID(ID string, index int32) string {
|
||||
return ID + ":" + strconv.Itoa(int(index))
|
||||
}
|
||||
|
||||
func (e *ExtendMsgSetModel) SplitConversationIDAndGetIndex() int32 {
|
||||
l := strings.Split(e.ConversationID, ":")
|
||||
index, _ := strconv.Atoi(l[len(l)-1])
|
||||
return int32(index)
|
||||
}
|
||||
|
||||
type GetAllExtendMsgSetOpts struct {
|
||||
ExcludeExtendMsgs bool
|
||||
}
|
||||
|
||||
func (ExtendMsgSetModel) Pb2Model(reactionExtensionList map[string]*sdkws.KeyValue) map[string]*KeyValueModel {
|
||||
r := make(map[string]*KeyValueModel)
|
||||
for key, value := range reactionExtensionList {
|
||||
r[key] = &KeyValueModel{
|
||||
TypeKey: value.TypeKey,
|
||||
Value: value.Value,
|
||||
LatestUpdateTime: value.LatestUpdateTime,
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package unrelation
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
const (
|
||||
singleGocMsgNum = 5000
|
||||
Msg = "msg"
|
||||
OldestList = 0
|
||||
NewestList = -1
|
||||
)
|
||||
|
||||
type MsgDocModel struct {
|
||||
DocID string `bson:"doc_id"`
|
||||
Msg []*MsgInfoModel `bson:"msgs"`
|
||||
}
|
||||
|
||||
type RevokeModel struct {
|
||||
ID string `bson:"id"`
|
||||
Role int32 `bson:"role"`
|
||||
UserID string `bson:"user_id"`
|
||||
Nickname string `bson:"nickname"`
|
||||
Time int64 `bson:"time"`
|
||||
}
|
||||
|
||||
type OfflinePushModel struct {
|
||||
Title string `bson:"title"`
|
||||
Desc string `bson:"desc"`
|
||||
Ex string `bson:"ex"`
|
||||
IOSPushSound string `bson:"ios_push_sound"`
|
||||
IOSBadgeCount bool `bson:"ios_badge_count"`
|
||||
}
|
||||
|
||||
type MsgDataModel struct {
|
||||
SendID string `bson:"send_id"`
|
||||
RecvID string `bson:"recv_id"`
|
||||
GroupID string `bson:"group_id"`
|
||||
ClientMsgID string `bson:"client_msg_id"`
|
||||
ServerMsgID string `bson:"server_msg_id"`
|
||||
SenderPlatformID int32 `bson:"sender_platform_id"`
|
||||
SenderNickname string `bson:"sender_nickname"`
|
||||
SenderFaceURL string `bson:"sender_face_url"`
|
||||
SessionType int32 `bson:"session_type"`
|
||||
MsgFrom int32 `bson:"msg_from"`
|
||||
ContentType int32 `bson:"content_type"`
|
||||
Content string `bson:"content"`
|
||||
Seq int64 `bson:"seq"`
|
||||
SendTime int64 `bson:"send_time"`
|
||||
CreateTime int64 `bson:"create_time"`
|
||||
Status int32 `bson:"status"`
|
||||
IsRead bool `bson:"is_read"`
|
||||
Options map[string]bool `bson:"options"`
|
||||
OfflinePush *OfflinePushModel `bson:"offline_push"`
|
||||
AtUserIDList []string `bson:"at_user_id_list"`
|
||||
AttachedInfo string `bson:"attached_info"`
|
||||
Ex string `bson:"ex"`
|
||||
}
|
||||
|
||||
type MsgInfoModel struct {
|
||||
Msg *MsgDataModel `bson:"msg"`
|
||||
Revoke *RevokeModel `bson:"revoke"`
|
||||
DelList []string `bson:"del_list"`
|
||||
IsRead bool `bson:"is_read"`
|
||||
}
|
||||
|
||||
type MsgDocModelInterface interface {
|
||||
PushMsgsToDoc(ctx context.Context, docID string, msgsToMongo []MsgInfoModel) error
|
||||
Create(ctx context.Context, model *MsgDocModel) error
|
||||
UpdateMsg(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
|
||||
PushUnique(ctx context.Context, docID string, index int64, key string, value any) (*mongo.UpdateResult, error)
|
||||
UpdateMsgContent(ctx context.Context, docID string, index int64, msg []byte) error
|
||||
IsExistDocID(ctx context.Context, docID string) (bool, error)
|
||||
FindOneByDocID(ctx context.Context, docID string) (*MsgDocModel, error)
|
||||
GetMsgBySeqIndexIn1Doc(ctx context.Context, userID, docID string, seqs []int64) ([]*MsgInfoModel, error)
|
||||
GetNewestMsg(ctx context.Context, conversationID string) (*MsgInfoModel, error)
|
||||
GetOldestMsg(ctx context.Context, conversationID string) (*MsgInfoModel, error)
|
||||
DeleteDocs(ctx context.Context, docIDs []string) error
|
||||
GetMsgDocModelByIndex(ctx context.Context, conversationID string, index, sort int64) (*MsgDocModel, error)
|
||||
DeleteMsgsInOneDocByIndex(ctx context.Context, docID string, indexes []int) error
|
||||
MarkSingleChatMsgsAsRead(ctx context.Context, userID string, docID string, indexes []int64) error
|
||||
}
|
||||
|
||||
func (MsgDocModel) TableName() string {
|
||||
return Msg
|
||||
}
|
||||
|
||||
func (MsgDocModel) GetSingleGocMsgNum() int64 {
|
||||
return singleGocMsgNum
|
||||
}
|
||||
|
||||
func (m *MsgDocModel) IsFull() bool {
|
||||
return m.Msg[len(m.Msg)-1].Msg != nil
|
||||
}
|
||||
|
||||
func (m MsgDocModel) GetDocID(conversationID string, seq int64) string {
|
||||
seqSuffix := (seq - 1) / singleGocMsgNum
|
||||
return m.indexGen(conversationID, seqSuffix)
|
||||
}
|
||||
|
||||
func (m MsgDocModel) GetDocIDSeqsMap(conversationID string, seqs []int64) map[string][]int64 {
|
||||
t := make(map[string][]int64)
|
||||
for i := 0; i < len(seqs); i++ {
|
||||
docID := m.GetDocID(conversationID, seqs[i])
|
||||
if value, ok := t[docID]; !ok {
|
||||
var temp []int64
|
||||
t[docID] = append(temp, seqs[i])
|
||||
} else {
|
||||
t[docID] = append(value, seqs[i])
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func (m MsgDocModel) GetMsgIndex(seq int64) int64 {
|
||||
return (seq - 1) % singleGocMsgNum
|
||||
}
|
||||
|
||||
func (m MsgDocModel) indexGen(conversationID string, seqSuffix int64) string {
|
||||
return conversationID + ":" + strconv.FormatInt(seqSuffix, 10)
|
||||
}
|
||||
|
||||
func (MsgDocModel) GenExceptionMessageBySeqs(seqs []int64) (exceptionMsg []*sdkws.MsgData) {
|
||||
for _, v := range seqs {
|
||||
msgModel := new(sdkws.MsgData)
|
||||
msgModel.Seq = v
|
||||
exceptionMsg = append(exceptionMsg, msgModel)
|
||||
}
|
||||
return exceptionMsg
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package unrelation
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const (
|
||||
CSuperGroup = "super_group"
|
||||
CUserToSuperGroup = "user_to_super_group"
|
||||
)
|
||||
|
||||
type SuperGroupModel struct {
|
||||
GroupID string `bson:"group_id" json:"groupID"`
|
||||
MemberIDs []string `bson:"member_id_list" json:"memberIDList"`
|
||||
}
|
||||
|
||||
func (SuperGroupModel) TableName() string {
|
||||
return CSuperGroup
|
||||
}
|
||||
|
||||
type UserToSuperGroupModel struct {
|
||||
UserID string `bson:"user_id" json:"userID"`
|
||||
GroupIDs []string `bson:"group_id_list" json:"groupIDList"`
|
||||
}
|
||||
|
||||
func (UserToSuperGroupModel) TableName() string {
|
||||
return CUserToSuperGroup
|
||||
}
|
||||
|
||||
type SuperGroupModelInterface interface {
|
||||
CreateSuperGroup(ctx context.Context, groupID string, initMemberIDs []string) error
|
||||
TakeSuperGroup(ctx context.Context, groupID string) (group *SuperGroupModel, err error)
|
||||
FindSuperGroup(ctx context.Context, groupIDs []string) (groups []*SuperGroupModel, err error)
|
||||
AddUserToSuperGroup(ctx context.Context, groupID string, userIDs []string) error
|
||||
RemoverUserFromSuperGroup(ctx context.Context, groupID string, userIDs []string) error
|
||||
GetSuperGroupByUserID(ctx context.Context, userID string) (*UserToSuperGroupModel, error)
|
||||
DeleteSuperGroup(ctx context.Context, groupID string) error
|
||||
RemoveGroupFromUser(ctx context.Context, groupID string, userIDs []string) error
|
||||
}
|
||||
Reference in New Issue
Block a user