mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-26 21:22:16 +08:00
fix: server can return isEnd to control fetch messages when sdk pull messages end normally.
This commit is contained in:
commit
3e02bdbdf1
2
go.mod
2
go.mod
@ -15,7 +15,7 @@ require (
|
|||||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/openimsdk/protocol v0.0.72-alpha.63
|
github.com/openimsdk/protocol v0.0.72-alpha.63
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.47
|
github.com/openimsdk/tools v0.0.50-alpha.50
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/prometheus/client_golang v1.18.0
|
github.com/prometheus/client_golang v1.18.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -349,8 +349,8 @@ github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrk
|
|||||||
github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
||||||
github.com/openimsdk/protocol v0.0.72-alpha.63 h1:IyPBibEvwBtTmD8DSrlqcekfEXe74k4+KeeHsgdhGh0=
|
github.com/openimsdk/protocol v0.0.72-alpha.63 h1:IyPBibEvwBtTmD8DSrlqcekfEXe74k4+KeeHsgdhGh0=
|
||||||
github.com/openimsdk/protocol v0.0.72-alpha.63/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
|
github.com/openimsdk/protocol v0.0.72-alpha.63/go.mod h1:Iet+piS/jaS+kWWyj6EEr36mk4ISzIRYjoMSVA4dq2M=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.47 h1:Cfe2va/g6WhLjOoQqZkjrdlEDq1dUsfcQsdUB5oADVA=
|
github.com/openimsdk/tools v0.0.50-alpha.50 h1:+naDlvHcqJDj2NsCGnQd1LLQOET5IRPbrtmWbM/o7JQ=
|
||||||
github.com/openimsdk/tools v0.0.50-alpha.47/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
|
github.com/openimsdk/tools v0.0.50-alpha.50/go.mod h1:muCtxguNJv8lFwLei27UASu2Nvg4ERSeN0R4K5tivk0=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
|
|||||||
@ -173,6 +173,8 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|||||||
data = apistruct.AtElem{}
|
data = apistruct.AtElem{}
|
||||||
case constant.Custom:
|
case constant.Custom:
|
||||||
data = apistruct.CustomElem{}
|
data = apistruct.CustomElem{}
|
||||||
|
case constant.Quote:
|
||||||
|
data = apistruct.QuoteElem{}
|
||||||
case constant.Stream:
|
case constant.Stream:
|
||||||
data = apistruct.StreamMsgElem{}
|
data = apistruct.StreamMsgElem{}
|
||||||
case constant.OANotification:
|
case constant.OANotification:
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/openimsdk/tools/mw"
|
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -378,7 +377,7 @@ func (c *Client) activeHeartbeat(ctx context.Context) {
|
|||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mw.PanicStackToLog(ctx, r)
|
log.ZPanic(ctx, "activeHeartbeat Panic", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
log.ZDebug(ctx, "server initiative send heartbeat start.")
|
log.ZDebug(ctx, "server initiative send heartbeat start.")
|
||||||
|
|||||||
@ -204,7 +204,7 @@ func (m *MsgTransfer) Start(index int, config *Config) error {
|
|||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mw.PanicStackToLog(m.ctx, r)
|
log.ZPanic(m.ctx, "MsgTransfer Start Panic", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
if err := prommetrics.TransferInit(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
if err := prommetrics.TransferInit(listener); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
|
|||||||
@ -18,13 +18,13 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
|
||||||
"github.com/openimsdk/tools/mw"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
|
|
||||||
"github.com/IBM/sarama"
|
"github.com/IBM/sarama"
|
||||||
"github.com/go-redis/redis"
|
"github.com/go-redis/redis"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||||
@ -349,7 +349,7 @@ func (och *OnlineHistoryRedisConsumerHandler) handleNotification(ctx context.Con
|
|||||||
func (och *OnlineHistoryRedisConsumerHandler) HandleUserHasReadSeqMessages(ctx context.Context) {
|
func (och *OnlineHistoryRedisConsumerHandler) HandleUserHasReadSeqMessages(ctx context.Context) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mw.PanicStackToLog(ctx, r)
|
log.ZPanic(ctx, "HandleUserHasReadSeqMessages Panic", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@ -138,9 +138,16 @@ func (m *msgServer) clearConversation(ctx context.Context, conversationIDs []str
|
|||||||
}
|
}
|
||||||
isSyncSelf, isSyncOther := m.validateDeleteSyncOpt(deleteSyncOpt)
|
isSyncSelf, isSyncOther := m.validateDeleteSyncOpt(deleteSyncOpt)
|
||||||
if !isSyncOther {
|
if !isSyncOther {
|
||||||
if err := m.MsgDatabase.SetUserConversationsMinSeqs(ctx, userID, m.getMinSeqs(maxSeqs)); err != nil {
|
setSeqs := m.getMinSeqs(maxSeqs)
|
||||||
|
if err := m.MsgDatabase.SetUserConversationsMinSeqs(ctx, userID, setSeqs); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
ownerUserIDs := []string{userID}
|
||||||
|
for conversationID, seq := range setSeqs {
|
||||||
|
if err := m.Conversation.SetConversationMinSeq(ctx, ownerUserIDs, conversationID, seq); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
// notification 2 self
|
// notification 2 self
|
||||||
if isSyncSelf {
|
if isSyncSelf {
|
||||||
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: existConversationIDs}
|
tips := &sdkws.ClearConversationTips{UserID: userID, ConversationIDs: existConversationIDs}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ package msg
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/openimsdk/tools/mw"
|
|
||||||
|
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
|
||||||
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
"github.com/openimsdk/open-im-server/v3/pkg/msgprocessor"
|
||||||
@ -89,7 +88,7 @@ func (m *msgServer) setConversationAtInfo(nctx context.Context, msg *sdkws.MsgDa
|
|||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mw.PanicStackToLog(nctx, r)
|
log.ZPanic(nctx, "setConversationAtInfo Panic", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|||||||
@ -97,6 +97,8 @@ func (m *msgServer) GetSeqMessage(ctx context.Context, req *msg.GetSeqMessageReq
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var pullMsgs *sdkws.PullMsgs
|
var pullMsgs *sdkws.PullMsgs
|
||||||
|
pullMsgs.IsEnd = isEnd
|
||||||
|
pullMsgs.EndSeq = endSeq
|
||||||
if ok := false; conversationutil.IsNotificationConversationID(conv.ConversationID) {
|
if ok := false; conversationutil.IsNotificationConversationID(conv.ConversationID) {
|
||||||
pullMsgs, ok = resp.NotificationMsgs[conv.ConversationID]
|
pullMsgs, ok = resp.NotificationMsgs[conv.ConversationID]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
|||||||
@ -50,14 +50,14 @@ func (t *thirdServer) UploadLogs(ctx context.Context, req *third.UploadLogsReq)
|
|||||||
platform := constant.PlatformID2Name[int(req.Platform)]
|
platform := constant.PlatformID2Name[int(req.Platform)]
|
||||||
for _, fileURL := range req.FileURLs {
|
for _, fileURL := range req.FileURLs {
|
||||||
log := relationtb.Log{
|
log := relationtb.Log{
|
||||||
Platform: platform,
|
Platform: platform,
|
||||||
UserID: userID,
|
UserID: userID,
|
||||||
CreateTime: time.Now(),
|
CreateTime: time.Now(),
|
||||||
Url: fileURL.URL,
|
Url: fileURL.URL,
|
||||||
FileName: fileURL.Filename,
|
FileName: fileURL.Filename,
|
||||||
SystemType: req.AppFramework,
|
AppFramework: req.AppFramework,
|
||||||
Version: req.Version,
|
Version: req.Version,
|
||||||
Ex: req.Ex,
|
Ex: req.Ex,
|
||||||
}
|
}
|
||||||
for i := 0; i < 20; i++ {
|
for i := 0; i < 20; i++ {
|
||||||
id := genLogID()
|
id := genLogID()
|
||||||
|
|||||||
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
package apistruct
|
package apistruct
|
||||||
|
|
||||||
|
import "github.com/openimsdk/protocol/sdkws"
|
||||||
|
|
||||||
type PictureBaseInfo struct {
|
type PictureBaseInfo struct {
|
||||||
UUID string `mapstructure:"uuid"`
|
UUID string `mapstructure:"uuid"`
|
||||||
Type string `mapstructure:"type" validate:"required"`
|
Type string `mapstructure:"type" validate:"required"`
|
||||||
@ -90,6 +92,11 @@ type RevokeElem struct {
|
|||||||
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
RevokeMsgClientID string `mapstructure:"revokeMsgClientID" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type QuoteElem struct {
|
||||||
|
Text string `json:"text,omitempty"`
|
||||||
|
QuoteMessage *MsgStruct `json:"quoteMessage,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type OANotificationElem struct {
|
type OANotificationElem struct {
|
||||||
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
NotificationName string `mapstructure:"notificationName" json:"notificationName" validate:"required"`
|
||||||
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
|
NotificationFaceURL string `mapstructure:"notificationFaceURL" json:"notificationFaceURL"`
|
||||||
@ -103,6 +110,7 @@ type OANotificationElem struct {
|
|||||||
FileElem *FileElem `mapstructure:"fileElem" json:"fileElem"`
|
FileElem *FileElem `mapstructure:"fileElem" json:"fileElem"`
|
||||||
Ex string `mapstructure:"ex" json:"ex"`
|
Ex string `mapstructure:"ex" json:"ex"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MessageRevoked struct {
|
type MessageRevoked struct {
|
||||||
RevokerID string `mapstructure:"revokerID" json:"revokerID" validate:"required"`
|
RevokerID string `mapstructure:"revokerID" json:"revokerID" validate:"required"`
|
||||||
RevokerRole int32 `mapstructure:"revokerRole" json:"revokerRole" validate:"required"`
|
RevokerRole int32 `mapstructure:"revokerRole" json:"revokerRole" validate:"required"`
|
||||||
@ -111,3 +119,38 @@ type MessageRevoked struct {
|
|||||||
SessionType int32 `mapstructure:"sessionType" json:"sessionType" validate:"required"`
|
SessionType int32 `mapstructure:"sessionType" json:"sessionType" validate:"required"`
|
||||||
Seq uint32 `mapstructure:"seq" json:"seq" validate:"required"`
|
Seq uint32 `mapstructure:"seq" json:"seq" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MsgStruct struct {
|
||||||
|
ClientMsgID string `json:"clientMsgID,omitempty"`
|
||||||
|
ServerMsgID string `json:"serverMsgID,omitempty"`
|
||||||
|
CreateTime int64 `json:"createTime"`
|
||||||
|
SendTime int64 `json:"sendTime"`
|
||||||
|
SessionType int32 `json:"sessionType"`
|
||||||
|
SendID string `json:"sendID,omitempty"`
|
||||||
|
RecvID string `json:"recvID,omitempty"`
|
||||||
|
MsgFrom int32 `json:"msgFrom"`
|
||||||
|
ContentType int32 `json:"contentType"`
|
||||||
|
SenderPlatformID int32 `json:"senderPlatformID"`
|
||||||
|
SenderNickname string `json:"senderNickname,omitempty"`
|
||||||
|
SenderFaceURL string `json:"senderFaceUrl,omitempty"`
|
||||||
|
GroupID string `json:"groupID,omitempty"`
|
||||||
|
Content string `json:"content,omitempty"`
|
||||||
|
Seq int64 `json:"seq"`
|
||||||
|
IsRead bool `json:"isRead"`
|
||||||
|
Status int32 `json:"status"`
|
||||||
|
IsReact bool `json:"isReact,omitempty"`
|
||||||
|
IsExternalExtensions bool `json:"isExternalExtensions,omitempty"`
|
||||||
|
OfflinePush *sdkws.OfflinePushInfo `json:"offlinePush,omitempty"`
|
||||||
|
AttachedInfo string `json:"attachedInfo,omitempty"`
|
||||||
|
Ex string `json:"ex,omitempty"`
|
||||||
|
LocalEx string `json:"localEx,omitempty"`
|
||||||
|
TextElem *TextElem `json:"textElem,omitempty"`
|
||||||
|
PictureElem *PictureElem `json:"pictureElem,omitempty"`
|
||||||
|
SoundElem *SoundElem `json:"soundElem,omitempty"`
|
||||||
|
VideoElem *VideoElem `json:"videoElem,omitempty"`
|
||||||
|
FileElem *FileElem `json:"fileElem,omitempty"`
|
||||||
|
AtTextElem *AtElem `json:"atTextElem,omitempty"`
|
||||||
|
LocationElem *LocationElem `json:"locationElem,omitempty"`
|
||||||
|
CustomElem *CustomElem `json:"customElem,omitempty"`
|
||||||
|
QuoteElem *QuoteElem `json:"quoteElem,omitempty"`
|
||||||
|
}
|
||||||
|
|||||||
@ -19,13 +19,14 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Log struct {
|
type Log struct {
|
||||||
LogID string `bson:"log_id"`
|
LogID string `bson:"log_id"`
|
||||||
Platform string `bson:"platform"`
|
Platform string `bson:"platform"`
|
||||||
UserID string `bson:"user_id"`
|
UserID string `bson:"user_id"`
|
||||||
CreateTime time.Time `bson:"create_time"`
|
CreateTime time.Time `bson:"create_time"`
|
||||||
Url string `bson:"url"`
|
Url string `bson:"url"`
|
||||||
FileName string `bson:"file_name"`
|
FileName string `bson:"file_name"`
|
||||||
SystemType string `bson:"system_type"`
|
SystemType string `bson:"system_type"`
|
||||||
Version string `bson:"version"`
|
AppFramework string `bson:"app_framework"`
|
||||||
Ex string `bson:"ex"`
|
Version string `bson:"version"`
|
||||||
|
Ex string `bson:"ex"`
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,6 @@ package rpccache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/openimsdk/tools/mw"
|
|
||||||
|
|
||||||
"github.com/openimsdk/tools/log"
|
"github.com/openimsdk/tools/log"
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
@ -26,7 +25,7 @@ import (
|
|||||||
func subscriberRedisDeleteCache(ctx context.Context, client redis.UniversalClient, channel string, del func(ctx context.Context, key ...string)) {
|
func subscriberRedisDeleteCache(ctx context.Context, client redis.UniversalClient, channel string, del func(ctx context.Context, key ...string)) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
mw.PanicStackToLog(ctx, r)
|
log.ZPanic(ctx, "subscriberRedisDeleteCache Panic", r)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
for message := range client.Subscribe(ctx, channel).Channel() {
|
for message := range client.Subscribe(ctx, channel).Channel() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user