You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/common/db/table/unrelation/extend_msg_set.go

69 lines
2.9 KiB

2 years ago
package unrelation
import (
2 years ago
"context"
2 years ago
"strconv"
"strings"
)
const (
CExtendMsgSet = "extend_msgs"
ExtendMsgMaxNum = 100
)
2 years ago
type ExtendMsgSetModel struct {
2 years ago
SourceID string `bson:"source_id" json:"sourceID"`
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
2 years ago
}
2 years ago
type KeyValueModel struct {
2 years ago
TypeKey string `bson:"type_key" json:"typeKey"`
Value string `bson:"value" json:"value"`
LatestUpdateTime int64 `bson:"latest_update_time" json:"latestUpdateTime"`
}
2 years ago
type ExtendMsgModel struct {
2 years ago
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"`
2 years ago
}
2 years ago
type ExtendMsgSetModelInterface interface {
CreateExtendMsgSet(ctx context.Context, set *ExtendMsgSetModel) error
GetAllExtendMsgSet(ctx context.Context, sourceID string, opts *GetAllExtendMsgSetOpts) (sets []*ExtendMsgSetModel, err error)
GetExtendMsgSet(ctx context.Context, sourceID string, sessionType int32, maxMsgUpdateTime int64) (*ExtendMsgSetModel, error)
InsertExtendMsg(ctx context.Context, sourceID string, sessionType int32, msg *ExtendMsgModel) error
2 years ago
InsertOrUpdateReactionExtendMsgSet(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
DeleteReactionExtendMsgSet(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, msgFirstModifyTime int64, reactionExtensionList map[string]*KeyValueModel) error
2 years ago
TakeExtendMsg(ctx context.Context, sourceID string, sessionType int32, clientMsgID string, maxMsgUpdateTime int64) (extendMsg *ExtendMsgModel, err error)
}
2 years ago
func (ExtendMsgSetModel) TableName() string {
2 years ago
return CExtendMsgSet
}
2 years ago
func (ExtendMsgSetModel) GetExtendMsgMaxNum() int32 {
2 years ago
return ExtendMsgMaxNum
}
2 years ago
func (ExtendMsgSetModel) GetSourceID(ID string, index int32) string {
2 years ago
return ID + ":" + strconv.Itoa(int(index))
}
2 years ago
func (e *ExtendMsgSetModel) SplitSourceIDAndGetIndex() int32 {
2 years ago
l := strings.Split(e.SourceID, ":")
index, _ := strconv.Atoi(l[len(l)-1])
return int32(index)
}
2 years ago
type GetAllExtendMsgSetOpts struct {
ExcludeExtendMsgs bool
}