From bf6d77a26715df973203be9a28616a2f6ae105ee Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Thu, 27 Feb 2025 16:17:00 +0800 Subject: [PATCH 1/2] feat: the default notification.yml is not configured properly (#3168) * pb * fix: Modifying other fields while setting IsPrivateChat does not take effect * fix: quote message error revoke * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * refactoring scheduled tasks * upgrading pkg tools * fix * fix * optimize log output * feat: support GetLastMessage * feat: support GetLastMessage * feat: s3 switch * feat: s3 switch * fix: GetUsersOnline * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: SendBusinessNotification supported configuration parameters * feat: seq conversion failed without exiting * fix: DeleteDoc crash * fix: fill send time * fix: fill send time * fix: crash caused by withdrawing messages from users who have left the group * fix: user msg timestamp * seq read config * seq read config * fix: the source message of the reference is withdrawn, and the referenced message is deleted * feat: optimize the default notification.yml * fix: shouldPushOffline --- config/notification.yml | 26 +++++++++++++------------- internal/push/push_handler.go | 5 ++++- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/config/notification.yml b/config/notification.yml index c3ae01539..4f58219be 100644 --- a/config/notification.yml +++ b/config/notification.yml @@ -31,7 +31,7 @@ joinGroupApplication: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: false + enable: true title: joinGroupApplication title desc: joinGroupApplication desc ext: joinGroupApplication ext @@ -51,7 +51,7 @@ groupApplicationAccepted: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: false + enable: true title: groupApplicationAccepted title desc: groupApplicationAccepted desc ext: groupApplicationAccepted ext @@ -61,7 +61,7 @@ groupApplicationRejected: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: false + enable: true title: groupApplicationRejected title desc: groupApplicationRejected desc ext: groupApplicationRejected ext @@ -198,7 +198,7 @@ friendApplicationAdded: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: false + enable: true title: Somebody applies to add you as a friend desc: Somebody applies to add you as a friend ext: Somebody applies to add you as a friend @@ -228,7 +228,7 @@ friendAdded: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: We have become friends desc: We have become friends ext: We have become friends @@ -238,7 +238,7 @@ friendDeleted: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: deleted a friend desc: deleted a friend ext: deleted a friend @@ -248,7 +248,7 @@ friendRemarkSet: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: Your friend's profile has been changed desc: Your friend's profile has been changed ext: Your friend's profile has been changed @@ -258,7 +258,7 @@ blackAdded: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: blocked a user desc: blocked a user ext: blocked a user @@ -268,7 +268,7 @@ blackDeleted: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: Remove a blocked user desc: Remove a blocked user ext: Remove a blocked user @@ -278,7 +278,7 @@ friendInfoUpdated: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: friend info updated desc: friend info updated ext: friend info updated @@ -289,7 +289,7 @@ userInfoUpdated: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: userInfo updated desc: userInfo updated ext: userInfo updated @@ -310,7 +310,7 @@ conversationChanged: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: conversation changed desc: conversation changed ext: conversation changed @@ -320,7 +320,7 @@ conversationSetPrivate: reliabilityLevel: 1 unreadCount: false offlinePush: - enable: true + enable: false title: burn after reading desc: burn after reading ext: burn after reading diff --git a/internal/push/push_handler.go b/internal/push/push_handler.go index 707782c70..418c4c7f2 100644 --- a/internal/push/push_handler.go +++ b/internal/push/push_handler.go @@ -187,7 +187,10 @@ func (c *ConsumerHandler) shouldPushOffline(_ context.Context, msg *sdkws.MsgDat if !isOfflinePush { return false } - if msg.ContentType == constant.SignalingNotification { + switch msg.ContentType { + case constant.RoomParticipantsConnectedNotification: + return false + case constant.RoomParticipantsDisconnectedNotification: return false } return true From b7f88138bdc3560669b2074e566e52e32b72fe03 Mon Sep 17 00:00:00 2001 From: OpenIM-Gordon <1432970085@qq.com> Date: Fri, 28 Feb 2025 16:22:00 +0800 Subject: [PATCH 2/2] feat: add a new message type: Markdown text (#3162) --- go.mod | 2 +- go.sum | 4 ++-- internal/api/msg.go | 3 +++ internal/rpc/msg/verify.go | 31 +++++++------------------------ pkg/apistruct/msg.go | 4 ++++ 5 files changed, 17 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index 20cf3b202..0bdf09340 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/gorilla/websocket v1.5.1 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 github.com/mitchellh/mapstructure v1.5.0 - github.com/openimsdk/protocol v0.0.72-alpha.74 + github.com/openimsdk/protocol v0.0.72-alpha.75 github.com/openimsdk/tools v0.0.50-alpha.74 github.com/pkg/errors v0.9.1 // indirect github.com/prometheus/client_golang v1.18.0 diff --git a/go.sum b/go.sum index 63dfe9236..e8f1300f4 100644 --- a/go.sum +++ b/go.sum @@ -347,8 +347,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y= github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM= github.com/openimsdk/gomake v0.0.15-alpha.2 h1:5Q8yl8ezy2yx+q8/ucU/t4kJnDfCzNOrkXcDACCqtyM= github.com/openimsdk/gomake v0.0.15-alpha.2/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI= -github.com/openimsdk/protocol v0.0.72-alpha.74 h1:cGycdzEOxjPuaeoQhIWEKKVf5zp1I+wx7ZnBemjCJJI= -github.com/openimsdk/protocol v0.0.72-alpha.74/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= +github.com/openimsdk/protocol v0.0.72-alpha.75 h1:WlmBn8g2Fvv21g8TEFVbolmbw2rU0sN9kj6sQaDK7cA= +github.com/openimsdk/protocol v0.0.72-alpha.75/go.mod h1:WF7EuE55vQvpyUAzDXcqg+B+446xQyEba0X35lTINmw= github.com/openimsdk/tools v0.0.50-alpha.74 h1:yh10SiMiivMEjicEQg+QAsH4pvaO+4noMPdlw+ew0Kc= github.com/openimsdk/tools v0.0.50-alpha.74/go.mod h1:n2poR3asX1e1XZce4O+MOWAp+X02QJRFvhcLCXZdzRo= github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= diff --git a/internal/api/msg.go b/internal/api/msg.go index 927247cca..1316de943 100644 --- a/internal/api/msg.go +++ b/internal/api/msg.go @@ -21,6 +21,7 @@ import ( "github.com/gin-gonic/gin" "github.com/go-playground/validator/v10" "github.com/mitchellh/mapstructure" + "github.com/openimsdk/open-im-server/v3/pkg/apistruct" "github.com/openimsdk/open-im-server/v3/pkg/authverify" "github.com/openimsdk/open-im-server/v3/pkg/common/config" @@ -175,6 +176,8 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM data = apistruct.AtElem{} case constant.Custom: data = apistruct.CustomElem{} + case constant.MarkdownText: + data = apistruct.MarkdownTextElem{} case constant.OANotification: data = apistruct.OANotificationElem{} req.SessionType = constant.NotificationChatType diff --git a/internal/rpc/msg/verify.go b/internal/rpc/msg/verify.go index f6c3147ba..a492232a4 100644 --- a/internal/rpc/msg/verify.go +++ b/internal/rpc/msg/verify.go @@ -16,13 +16,14 @@ package msg import ( "context" + "math/rand" + "strconv" + "time" + "github.com/openimsdk/open-im-server/v3/pkg/common/servererrs" "github.com/openimsdk/tools/utils/datautil" "github.com/openimsdk/tools/utils/encrypt" "github.com/openimsdk/tools/utils/timeutil" - "math/rand" - "strconv" - "time" "github.com/openimsdk/protocol/constant" "github.com/openimsdk/protocol/msg" @@ -137,27 +138,9 @@ func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) { msg.SendTime = timeutil.GetCurrentTimestampByMill() } switch msg.ContentType { - case constant.Text: - fallthrough - case constant.Picture: - fallthrough - case constant.Voice: - fallthrough - case constant.Video: - fallthrough - case constant.File: - fallthrough - case constant.AtText: - fallthrough - case constant.Merger: - fallthrough - case constant.Card: - fallthrough - case constant.Location: - fallthrough - case constant.Custom: - fallthrough - case constant.Quote: + case constant.Text, constant.Picture, constant.Voice, constant.Video, + constant.File, constant.AtText, constant.Merger, constant.Card, + constant.Location, constant.Custom, constant.Quote, constant.AdvancedText, constant.MarkdownText: case constant.Revoke: datautil.SetSwitchFromOptions(msg.Options, constant.IsUnreadCount, false) datautil.SetSwitchFromOptions(msg.Options, constant.IsOfflinePush, false) diff --git a/pkg/apistruct/msg.go b/pkg/apistruct/msg.go index 44f157b6d..d818e769c 100644 --- a/pkg/apistruct/msg.go +++ b/pkg/apistruct/msg.go @@ -83,6 +83,10 @@ type TextElem struct { Content string `json:"content" validate:"required"` } +type MarkdownTextElem struct { + Content string `mapstructure:"content" validate:"required"` +} + type StreamMsgElem struct { Type string `mapstructure:"type" validate:"required"` Content string `mapstructure:"content" validate:"required"`