open-im-server icon indicating copy to clipboard operation
open-im-server copied to clipboard

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

Open zengyun261 opened this issue 1 year ago • 5 comments

Why this feature?

我想使用Server API给群内指定成员发送消息(事件通知),但是好像没有一个适合的方法 如果使用私聊发送会产生新的会话 使用/msg/send_business_notification比较符合需求,但是这个似乎不能持久化,用户不在线,这个消息就丢失了

Suggested Solution

。。。

Additional Information

No response

zengyun261 avatar Sep 09 '24 17:09 zengyun261

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.

OpenIM-Robot avatar Sep 09 '24 17:09 OpenIM-Robot

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

zengyun261 avatar Sep 09 '24 19:09 zengyun261

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?

OpenIM-Robot avatar Sep 09 '24 19:09 OpenIM-Robot

@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 就行了

Hookers avatar Sep 21 '24 10:09 Hookers

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.

OpenIM-Robot avatar Sep 21 '24 10:09 OpenIM-Robot

This feature is already supported in the commercial version.

skiffer-git avatar Nov 21 '24 12:11 skiffer-git