notification

test-errcode
wangchuxiao 1 year ago
parent e045f562e7
commit 727a28d993

@ -20,7 +20,7 @@ import (
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
if err != nil {
panic(err)
// panic(err)
}
return &Third{conn: conn, discov: discov}
}

@ -3,9 +3,41 @@ package msg
import (
"context"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/msg"
)
func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadReq) (resp *msg.MarkMsgsAsReadResp, err error) {
return
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, []string{req.ConversationID})
if err != nil {
return
}
var recvID string
if conversations[0].ConversationType == constant.SingleChatType || conversations[0].ConversationType == constant.NotificationChatType {
if req.UserID == conversations[0].OwnerUserID {
recvID = conversations[0].UserID
} else {
recvID = conversations[0].OwnerUserID
}
} else if conversations[0].ConversationType == constant.SuperGroupChatType {
recvID = conversations[0].GroupID
}
err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.ConversationID, req.UserID, req.Seqs)
if err != nil {
return
}
if err = m.sendMarkAsReadNotification(ctx, req.ConversationID, req.UserID, recvID, req.Seqs); err != nil {
return
}
return &msg.MarkMsgsAsReadResp{}, nil
}
func (m *msgServer) sendMarkAsReadNotification(ctx context.Context, conversationID string, sendID, recvID string, seqs []int64) error {
// tips := &sdkws.MarkAsReadTips{
// MarkAsReadUserID: sendID,
// ConversationID: conversationID,
// Seqs: seqs,
// }
// m.notificationSender.NotificationWithSesstionType(ctx)
return nil
}

@ -34,6 +34,8 @@ type CommonMsgDatabase interface {
BatchInsertChat2DB(ctx context.Context, conversationID string, msgs []*sdkws.MsgData, currentMaxSeq int64) error
// 撤回消息
RevokeMsg(ctx context.Context, conversationID string, seq int64, revoke *unRelationTb.RevokeModel) error
// mark as read
MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, seqs []int64) error
// 刪除redis中消息缓存
DeleteMessageFromCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) error
// incrSeq然后批量插入缓存
@ -297,6 +299,10 @@ func (db *commonMsgDatabase) RevokeMsg(ctx context.Context, conversationID strin
return db.BatchInsertBlock(ctx, conversationID, []any{revoke}, updateKeyRevoke, seq)
}
func (db *commonMsgDatabase) MarkSingleChatMsgsAsRead(ctx context.Context, userID string, conversationID string, seqs []int64) error {
return db.msgDocDatabase.MarkSingleChatMsgsAsRead(ctx, userID, conversationID, seqs)
}
func (db *commonMsgDatabase) DeleteMessageFromCache(ctx context.Context, conversationID string, msgs []*sdkws.MsgData) error {
return db.cache.DeleteMessageFromCache(ctx, conversationID, msgs)
}

@ -78,6 +78,7 @@ type MsgDocModelInterface interface {
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, conversationID string, seqs []int64) error
}
func (MsgDocModel) TableName() string {

File diff suppressed because it is too large Load Diff

@ -181,11 +181,12 @@ message MsgData {
int64 sendTime = 15;
int64 createTime = 16;
int32 status = 17;
map<string, bool> options = 18;
OfflinePushInfo offlinePushInfo = 19;
repeated string atUserIDList = 20;
string attachedInfo = 21;
string ex = 22;
bool isRead = 18;
map<string, bool> options = 19;
OfflinePushInfo offlinePushInfo = 20;
repeated string atUserIDList = 21;
string attachedInfo = 22;
string ex = 23;
}
message PushMessages{
map<string, PullMsgs> msgs = 1;
@ -453,6 +454,12 @@ message DeleteMsgsTips {
repeated int64 seqs = 3;
}
message MarkAsReadTips {
string markAsReadUserID = 1;
string conversationID = 2;
repeated int64 seqs = 3;
}
///////////////////signal//////////////
message SignalReq {
oneof payload {

Loading…
Cancel
Save