Notify P2P participants after HTTP forwarding
This commit is contained in:
@@ -9028,6 +9028,47 @@ func broadcastHTTPForwardMessage(tenantID types.TenantID, msg *types.Message) {
|
||||
default:
|
||||
logs.Warn.Printf("im message forward: hub route queue full topic=%s seq=%d", msg.Topic, msg.SeqId)
|
||||
}
|
||||
broadcastHTTPForwardPresence(tenantID, msg, timestamp)
|
||||
}
|
||||
|
||||
func broadcastHTTPForwardPresence(tenantID types.TenantID, msg *types.Message, timestamp time.Time) {
|
||||
if globals.hub == nil || msg == nil || msg.SeqId <= 0 || msg.Topic == "" {
|
||||
return
|
||||
}
|
||||
uid1, uid2, err := types.ParseP2P(msg.Topic)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
from := types.ParseUid(msg.From).UserId()
|
||||
for _, rcpt := range []struct {
|
||||
uid types.Uid
|
||||
src string
|
||||
}{
|
||||
{uid: uid1, src: uid2.UserId()},
|
||||
{uid: uid2, src: uid1.UserId()},
|
||||
} {
|
||||
actor := from
|
||||
if actor == rcpt.uid.UserId() {
|
||||
actor = ""
|
||||
}
|
||||
select {
|
||||
case globals.hub.routeSrv <- &ServerComMessage{
|
||||
TenantID: tenantID,
|
||||
RcptTo: rcpt.uid.UserId(),
|
||||
Timestamp: timestamp,
|
||||
Pres: &MsgServerPres{
|
||||
Topic: "me",
|
||||
What: "msg",
|
||||
Src: rcpt.src,
|
||||
SeqId: msg.SeqId,
|
||||
AcsActor: actor,
|
||||
SkipTopic: msg.Topic,
|
||||
},
|
||||
}:
|
||||
default:
|
||||
logs.Warn.Printf("im message forward: hub presence queue full topic=%s seq=%d user=%s", msg.Topic, msg.SeqId, rcpt.uid.UserId())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func forwardedMessageHead(msg *types.Message, clientMid string) types.KVMap {
|
||||
|
||||
Reference in New Issue
Block a user