prepareBroadcastableMessage sets the topic field in `msg` depending on the uid and subscription type.
(msg *ServerComMessage, uid types.Uid, isChanSub bool)
| 251 | |
| 252 | // prepareBroadcastableMessage sets the topic field in `msg` depending on the uid and subscription type. |
| 253 | func (t *Topic) prepareBroadcastableMessage(msg *ServerComMessage, uid types.Uid, isChanSub bool) { |
| 254 | // We are only interested in broadcastable messages. |
| 255 | if msg.Data == nil && msg.Pres == nil && msg.Info == nil { |
| 256 | return |
| 257 | } |
| 258 | |
| 259 | if (t.cat == types.TopicCatP2P && !uid.IsZero()) || (t.cat == types.TopicCatGrp && t.isChan) { |
| 260 | // For p2p topics topic name is dependent on receiver. |
| 261 | // Channel topics may be presented as grpXXX or chnXXX. |
| 262 | var topicName string |
| 263 | if isChanSub { |
| 264 | topicName = types.GrpToChn(t.xoriginal) |
| 265 | } else { |
| 266 | topicName = t.original(uid) |
| 267 | } |
| 268 | switch { |
| 269 | case msg.Data != nil: |
| 270 | msg.Data.Topic = topicName |
| 271 | case msg.Pres != nil: |
| 272 | msg.Pres.Topic = topicName |
| 273 | case msg.Info != nil: |
| 274 | msg.Info.Topic = topicName |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // Send channel messages anonymously. |
| 279 | if isChanSub && msg.Data != nil { |
| 280 | msg.Data.From = "" |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | // computePerUserAcsUnion computes want and given permissions unions over all topic's subscribers. |
| 285 | func (t *Topic) computePerUserAcsUnion() { |
no test coverage detected