mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-04-28 14:29:19 +08:00
refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. (#3173)
* feat: add a field to specify whether to send a notification message when creating a group. * feat: add a field to specify whether to send a notification message when creating a group. * refactor: change sendNotification to sendMessage to avoid ambiguity regarding message sending behavior. --------- Co-authored-by: Monet Lee <monet_lee@163.com>
This commit is contained in:
@@ -57,11 +57,11 @@ func GetProjectRoot() (string, error) {
|
||||
return projectRoot, nil
|
||||
}
|
||||
|
||||
func GetOptionsByNotification(cfg NotificationConfig, sendNotification *bool) msgprocessor.Options {
|
||||
func GetOptionsByNotification(cfg NotificationConfig, sendMessage *bool) msgprocessor.Options {
|
||||
opts := msgprocessor.NewOptions()
|
||||
|
||||
if sendNotification != nil {
|
||||
cfg.IsSendMsg = *sendNotification
|
||||
if sendMessage != nil {
|
||||
cfg.IsSendMsg = *sendMessage
|
||||
}
|
||||
if cfg.IsSendMsg {
|
||||
opts = msgprocessor.WithOptions(opts, msgprocessor.WithUnreadCount(true))
|
||||
|
||||
@@ -179,8 +179,8 @@ func NewNotificationSender(conf *config.Notification, opts ...NotificationSender
|
||||
}
|
||||
|
||||
type notificationOpt struct {
|
||||
RpcGetUsername bool
|
||||
SendNotification *bool
|
||||
RpcGetUsername bool
|
||||
SendMessage *bool
|
||||
}
|
||||
|
||||
type NotificationOptions func(*notificationOpt)
|
||||
@@ -190,9 +190,9 @@ func WithRpcGetUserName() NotificationOptions {
|
||||
opt.RpcGetUsername = true
|
||||
}
|
||||
}
|
||||
func WithSendNotification(send *bool) NotificationOptions {
|
||||
func WithSendMessage(sendMessage *bool) NotificationOptions {
|
||||
return func(opt *notificationOpt) {
|
||||
opt.SendNotification = send
|
||||
opt.SendMessage = sendMessage
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,7 +238,7 @@ func (s *NotificationSender) send(ctx context.Context, sendID, recvID string, co
|
||||
if sendID == recvID && contentType == constant.HasReadReceipt {
|
||||
optionsConfig.ReliabilityLevel = constant.UnreliableNotification
|
||||
}
|
||||
options := config.GetOptionsByNotification(optionsConfig, notificationOpt.SendNotification)
|
||||
options := config.GetOptionsByNotification(optionsConfig, notificationOpt.SendMessage)
|
||||
s.SetOptionsByContentType(ctx, options, contentType)
|
||||
msg.Options = options
|
||||
// fill Notification OfflinePush by config
|
||||
|
||||
Reference in New Issue
Block a user