mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-25 19:22:46 +08:00
Merge remote-tracking branch 'origin/errcode' into errcode
This commit is contained in:
commit
996eefc1a0
@ -139,6 +139,10 @@ func (m *Message) GetConversationsHasReadAndMaxSeq(c *gin.Context) {
|
|||||||
a2r.Call(msg.MsgClient.GetConversationsHasReadAndMaxSeq, m.client, c)
|
a2r.Call(msg.MsgClient.GetConversationsHasReadAndMaxSeq, m.client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *Message) SetConversationHasReadSeq(c *gin.Context) {
|
||||||
|
a2r.Call(msg.MsgClient.SetConversationHasReadSeq, m.client, c)
|
||||||
|
}
|
||||||
|
|
||||||
func (m *Message) ClearConversationsMsg(c *gin.Context) {
|
func (m *Message) ClearConversationsMsg(c *gin.Context) {
|
||||||
a2r.Call(msg.MsgClient.ClearConversationsMsg, m.client, c)
|
a2r.Call(msg.MsgClient.ClearConversationsMsg, m.client, c)
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
|||||||
msgGroup.POST("/mark_msgs_as_read", m.MarkMsgsAsRead)
|
msgGroup.POST("/mark_msgs_as_read", m.MarkMsgsAsRead)
|
||||||
msgGroup.POST("/mark_conversation_as_read", m.MarkConversationAsRead)
|
msgGroup.POST("/mark_conversation_as_read", m.MarkConversationAsRead)
|
||||||
msgGroup.POST("/get_conversations_has_read_and_max_seq", m.GetConversationsHasReadAndMaxSeq)
|
msgGroup.POST("/get_conversations_has_read_and_max_seq", m.GetConversationsHasReadAndMaxSeq)
|
||||||
|
msgGroup.POST("/set_conversation_has_read_seq", m.SetConversationHasReadSeq)
|
||||||
|
|
||||||
msgGroup.POST("/clear_conversation_msg", m.ClearConversationsMsg)
|
msgGroup.POST("/clear_conversation_msg", m.ClearConversationsMsg)
|
||||||
msgGroup.POST("/user_clear_all_msg", m.UserClearAllMsg)
|
msgGroup.POST("/user_clear_all_msg", m.UserClearAllMsg)
|
||||||
|
@ -35,6 +35,23 @@ func (m *msgServer) GetConversationsHasReadAndMaxSeq(ctx context.Context, req *m
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *msgServer) SetConversationHasReadMaxSeq(ctx context.Context, req *msg.SetConversationHasReadMaxSeqReq) (resp *msg.SetConversationHasReadMaxSeqResp, err error) {
|
||||||
|
maxSeq, err := m.MsgDatabase.GetMaxSeq(ctx, req.ConversationID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.HasReadSeq > maxSeq {
|
||||||
|
return nil, errs.ErrArgs.Wrap("hasReadSeq must not be bigger than maxSeq")
|
||||||
|
}
|
||||||
|
if err := m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err = m.sendMarkAsReadNotification(ctx, req.ConversationID, constant.SingleChatType, req.UserID, req.UserID, nil, req.HasReadSeq); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return &msg.SetConversationHasReadMaxSeqResp{}, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadReq) (resp *msg.MarkMsgsAsReadResp, err error) {
|
func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadReq) (resp *msg.MarkMsgsAsReadResp, err error) {
|
||||||
if len(req.Seqs) < 1 {
|
if len(req.Seqs) < 1 {
|
||||||
return nil, errs.ErrArgs.Wrap("seqs must not be empty")
|
return nil, errs.ErrArgs.Wrap("seqs must not be empty")
|
||||||
@ -51,8 +68,7 @@ func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadR
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, req.Seqs)
|
if err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, req.Seqs); err != nil {
|
||||||
if err != nil {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
currentHasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
|
currentHasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
|
||||||
@ -72,6 +88,10 @@ func (m *msgServer) MarkMsgsAsRead(ctx context.Context, req *msg.MarkMsgsAsReadR
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkConversationAsReadReq) (resp *msg.MarkConversationAsReadResp, err error) {
|
func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkConversationAsReadReq) (resp *msg.MarkConversationAsReadResp, err error) {
|
||||||
|
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, []string{req.ConversationID})
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
hasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
|
hasReadSeq, err := m.MsgDatabase.GetHasReadSeq(ctx, req.UserID, req.ConversationID)
|
||||||
if err != nil && errors.Unwrap(err) != redis.Nil {
|
if err != nil && errors.Unwrap(err) != redis.Nil {
|
||||||
return
|
return
|
||||||
@ -81,13 +101,11 @@ func (m *msgServer) MarkConversationAsRead(ctx context.Context, req *msg.MarkCon
|
|||||||
for i := hasReadSeq + 1; i <= req.HasReadSeq; i++ {
|
for i := hasReadSeq + 1; i <= req.HasReadSeq; i++ {
|
||||||
seqs = append(seqs, i)
|
seqs = append(seqs, i)
|
||||||
}
|
}
|
||||||
conversations, err := m.Conversation.GetConversationsByConversationID(ctx, []string{req.ConversationID})
|
if len(seqs) > 0 {
|
||||||
if err != nil {
|
log.ZDebug(ctx, "MarkConversationAsRead", "seqs", seqs, "conversationID", req.ConversationID)
|
||||||
return
|
if err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, seqs); err != nil {
|
||||||
}
|
return
|
||||||
log.ZDebug(ctx, "MarkConversationAsRead", "seqs", seqs, "conversationID", req.ConversationID)
|
}
|
||||||
if err = m.MsgDatabase.MarkSingleChatMsgsAsRead(ctx, req.UserID, req.ConversationID, seqs); err != nil {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if req.HasReadSeq > hasReadSeq {
|
if req.HasReadSeq > hasReadSeq {
|
||||||
err = m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq)
|
err = m.MsgDatabase.SetHasReadSeq(ctx, req.UserID, req.ConversationID, req.HasReadSeq)
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package tokenverify
|
package tokenverify
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
|
||||||
"github.com/golang-jwt/jwt/v4"
|
"github.com/golang-jwt/jwt/v4"
|
||||||
"testing"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_ParseToken(t *testing.T) {
|
func Test_ParseToken(t *testing.T) {
|
||||||
config.Config.TokenPolicy.AccessSecret = "OpenIM_server"
|
config.Config.TokenPolicy.AccessSecret = "OpenIM_server"
|
||||||
claims1 := BuildClaims("123456", constant.AndroidPlatformStr, 10)
|
claims1 := BuildClaims("123456", constant.AndroidPadPlatformID, 10)
|
||||||
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims1)
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims1)
|
||||||
tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret))
|
tokenString, err := token.SignedString([]byte(config.Config.TokenPolicy.AccessSecret))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -185,6 +185,15 @@ message MarkConversationAsReadReq {
|
|||||||
message MarkConversationAsReadResp {
|
message MarkConversationAsReadResp {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message SetConversationHasReadSeqReq {
|
||||||
|
string conversationID = 1;
|
||||||
|
string userID = 2;
|
||||||
|
int64 hasReadSeq = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SetConversationHasReadSeqResp {
|
||||||
|
}
|
||||||
|
|
||||||
message DeleteSyncOpt {
|
message DeleteSyncOpt {
|
||||||
bool IsSyncSelf = 3;
|
bool IsSyncSelf = 3;
|
||||||
bool IsSyncOther = 4;
|
bool IsSyncOther = 4;
|
||||||
@ -284,6 +293,7 @@ service msg {
|
|||||||
// mark as read
|
// mark as read
|
||||||
rpc MarkMsgsAsRead(MarkMsgsAsReadReq) returns(MarkMsgsAsReadResp);
|
rpc MarkMsgsAsRead(MarkMsgsAsReadReq) returns(MarkMsgsAsReadResp);
|
||||||
rpc MarkConversationAsRead(MarkConversationAsReadReq) returns(MarkConversationAsReadResp);
|
rpc MarkConversationAsRead(MarkConversationAsReadReq) returns(MarkConversationAsReadResp);
|
||||||
|
rpc SetConversationHasReadSeq(SetConversationHasReadSeqReq) returns(SetConversationHasReadSeqResp);
|
||||||
// 修改消息
|
// 修改消息
|
||||||
rpc SetMessageReactionExtensions(SetMessageReactionExtensionsReq) returns(SetMessageReactionExtensionsResp);
|
rpc SetMessageReactionExtensions(SetMessageReactionExtensionsReq) returns(SetMessageReactionExtensionsResp);
|
||||||
rpc GetMessagesReactionExtensions(GetMessagesReactionExtensionsReq) returns(GetMessagesReactionExtensionsResp);
|
rpc GetMessagesReactionExtensions(GetMessagesReactionExtensionsReq) returns(GetMessagesReactionExtensionsResp);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user