mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-06 01:55:58 +08:00
RevokeMsg
This commit is contained in:
@@ -32,7 +32,7 @@ type CommonMsgDatabase interface {
|
||||
// 批量插入消息
|
||||
BatchInsertChat2DB(ctx context.Context, conversationID string, msgs []*sdkws.MsgData, currentMaxSeq int64) error
|
||||
// 撤回消息
|
||||
RevokeMsg(ctx context.Context, conversationID string, seq int64, msg []byte) error
|
||||
RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error
|
||||
// 刪除redis中消息缓存
|
||||
DeleteMessageFromCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) error
|
||||
// incrSeq然后批量插入缓存
|
||||
@@ -316,10 +316,10 @@ func (db *commonMsgDatabase) BatchInsertChat2DB(ctx context.Context, conversatio
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *commonMsgDatabase) RevokeMsg(ctx context.Context, conversationID string, seq int64, msg []byte) error {
|
||||
index := seq / db.msg.GetSingleGocMsgNum()
|
||||
docID := db.msg.IndexDocID(conversationID, index)
|
||||
return db.msgDocDatabase.UpdateMsgContent(ctx, docID, seq%db.msg.GetSingleGocMsgNum(), msg)
|
||||
func (db *commonMsgDatabase) RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error {
|
||||
msgs := []*unRelationTb.MsgInfoModel{{Revoke: revoke}}
|
||||
return db.BatchInsertBlock(ctx, conversationID, msgs, seq)
|
||||
//return db.msgDocDatabase.UpdateMsgContent(ctx, docID, seq%db.msg.GetSingleGocMsgNum(), msg)
|
||||
}
|
||||
|
||||
func (db *commonMsgDatabase) DeleteMessageFromCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) error {
|
||||
|
||||
@@ -80,6 +80,15 @@ func DistinctAnyGetComparable[E any, K comparable](es []E, fn func(e E) K) []K {
|
||||
|
||||
// Distinct 去重
|
||||
func Distinct[T comparable](ts []T) []T {
|
||||
if len(ts) < 2 {
|
||||
return ts
|
||||
} else if len(ts) == 2 {
|
||||
if ts[0] == ts[1] {
|
||||
return ts[:1]
|
||||
} else {
|
||||
return ts
|
||||
}
|
||||
}
|
||||
return DistinctAny(ts, func(t T) T {
|
||||
return t
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user