Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Send a message to the specified member in the group, other members will not receive this message #2605

Open
zengyun261 opened this issue Sep 9, 2024 · 5 comments
Labels
enhancement New feature or request feature Categorizes issue or PR as related to a new feature.

Comments

@zengyun261
Copy link

zengyun261 commented Sep 9, 2024

Why this feature?

I’d like to use the Server API to send a message (event notification) to specific members within a group, but it seems there isn't an ideal method available. If I use private messaging, it creates a new conversation. The /msg/send_business_notification endpoint is closer to what I need, but it doesn't seem to support persistence, meaning if the user is offline, the message is lost.

Suggested Solution

。。。

Additional Information

No response

@zengyun261 zengyun261 added the enhancement New feature or request label Sep 9, 2024
@OpenIM-Robot OpenIM-Robot changed the title [FEATURE REQUEST] 发送消息给群内指定成员,其他成员不收到此消息 [FEATURE REQUEST] Send a message to the specified member in the group, other members will not receive this message Sep 9, 2024
@OpenIM-Robot
Copy link

Hello! Thank you for filing an issue.

If this is a bug report, please include relevant logs to help us debug the problem.

Join slack 🤖 to connect and communicate with our developers.

@zengyun261
Copy link
Author

能否给/msg/send_business_notification增加个选项,用来支持离线分发

@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


Can you add an option to /msg/send_business_notification to support offline distribution?

@Hookers
Copy link

Hookers commented Sep 21, 2024

@zengyun261 兄弟 我是一个读过源码的路人,看你说的这个方法里的实现是

sendMsgReq := msg.SendMsgReq{
		MsgData: &sdkws.MsgData{
			SendID: req.SendUserID,
			RecvID: req.RecvUserID,
			Content: []byte(jsonutil.StructToJsonString(&sdkws.NotificationElem{
				Detail: jsonutil.StructToJsonString(&struct {
					Key  string `json:"key"`
					Data string `json:"data"`
				}{Key: req.Key, Data: req.Data}),
			})),
			MsgFrom:     constant.SysMsgType,
			ContentType: constant.BusinessNotification,
			SessionType: constant.SingleChatType,
			CreateTime:  timeutil.GetCurrentTimestampByMill(),
			ClientMsgID: idutil.GetMsgIDByMD5(mcontext.GetOpUserID(c)),
			Options: config.GetOptionsByNotification(config.NotificationConfig{
				IsSendMsg:        false,
				ReliabilityLevel: 1,
				UnreadCount:      false,
			}),
		},
	}
	respPb, err := m.Client.SendMsg(c, &sendMsgReq)

我觉得你要是着急解决的话,可以试着自己手动调用 send_msg,传参和上面的类似,然后只用把 ReliabilityLevel 改成 2 就行了

@OpenIM-Robot
Copy link

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


@zengyun261 Brother, I am a passerby who has read the source code. The implementation of the method you mentioned is
sendMsgReq := msg.SendMsgReq{
MsgData: &sdkws.MsgData{
SendID: req.SendUserID,
RecvID: req.RecvUserID,
Content: []byte(jsonutil.StructToJsonString(&sdkws.NotificationElem{
Detail: jsonutil.StructToJsonString(&struct {
Key string json:"key"
Data string json:"data"
}{Key: req.Key, Data: req.Data}),
})),
MsgFrom: constant.SysMsgType,
ContentType: constant.BusinessNotification,
SessionType: constant.SingleChatType,
CreateTime: timeutil.GetCurrentTimestampByMill(),
ClientMsgID: idutil.GetMsgIDByMD5(mcontext.GetOpUserID(c)),
Options: config.GetOptionsByNotification(config.NotificationConfig{
IsSendMsg: false,
ReliabilityLevel: 1,
UnreadCount: false,
}),
},
}
respPb, err := m.Client.SendMsg(c, &sendMsgReq)

I think if you are in a hurry to solve it, you can try calling send_msg manually. The parameters are similar to the above, and then just change the ReliabilityLevel to 2.

@skiffer-git skiffer-git added the feature Categorizes issue or PR as related to a new feature. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

4 participants