fix p2p topic canonicalization and stale subscriptions
This commit is contained in:
+10
-11
@@ -262,8 +262,8 @@ func (t *Topic) prepareBroadcastableMessage(msg *ServerComMessage, uid types.Uid
|
||||
}
|
||||
|
||||
if (t.cat == types.TopicCatP2P && !uid.IsZero()) || (t.cat == types.TopicCatGrp && t.isChan) {
|
||||
// For p2p topics topic name is dependent on receiver.
|
||||
// Channel topics may be presented as grpXXX or chnXXX.
|
||||
// P2P topics are exposed by their canonical p2p... name. Channel topics
|
||||
// may be presented as grpXXX or chnXXX.
|
||||
var topicName string
|
||||
if isChanSub {
|
||||
topicName = types.GrpToChn(t.xoriginal)
|
||||
@@ -2867,14 +2867,15 @@ func (t *Topic) replyGetSub(sess *Session, asUid types.Uid, authLevel auth.Level
|
||||
banned = true
|
||||
}
|
||||
|
||||
// Reporting user's subscriptions to other topics. P2P topic name is the
|
||||
// UID of the other user.
|
||||
// Reporting user's subscriptions to other topics. P2P topic names are
|
||||
// reported by their canonical p2p... names; usr... remains accepted as
|
||||
// an input alias only.
|
||||
with := sub.GetWith()
|
||||
canViewLastSeen := true
|
||||
if with != "" {
|
||||
mts.Topic = with
|
||||
mts.Topic = sub.Topic
|
||||
canViewLastSeen = imCanViewLastSeen(t.tenantID, asUid, types.ParseUserId(with))
|
||||
mts.Online = t.perSubs[with].online && !deleted && presencer
|
||||
mts.Online = t.perSubs[sub.Topic].online && !deleted && presencer
|
||||
if !deleted && presencer {
|
||||
mts.Online = redisUserOnline(t.tenantID, types.ParseUserId(with), mts.Online)
|
||||
}
|
||||
@@ -4130,8 +4131,8 @@ func (t *Topic) isDeleted() bool {
|
||||
// Get topic name suitable for the given client
|
||||
func (t *Topic) original(uid types.Uid) string {
|
||||
if t.cat == types.TopicCatP2P {
|
||||
if pud, ok := t.perUser[uid]; ok {
|
||||
return pud.topicName
|
||||
if _, ok := t.perUser[uid]; ok {
|
||||
return t.name
|
||||
}
|
||||
panic("Invalid P2P topic")
|
||||
}
|
||||
@@ -4350,7 +4351,6 @@ func genTopicName() string {
|
||||
}
|
||||
|
||||
// Convert expanded (routable) topic name into name suitable for sending to the user.
|
||||
// For example p2pAbCDef123 -> usrAbCDef
|
||||
func topicNameForUser(name string, uid types.Uid, isChan bool) string {
|
||||
switch topicCat(name) {
|
||||
case types.TopicCatMe:
|
||||
@@ -4358,8 +4358,7 @@ func topicNameForUser(name string, uid types.Uid, isChan bool) string {
|
||||
case types.TopicCatFnd:
|
||||
return "fnd"
|
||||
case types.TopicCatP2P:
|
||||
topic, _ := types.P2PNameForUser(uid, name)
|
||||
return topic
|
||||
return name
|
||||
case types.TopicCatGrp:
|
||||
if isChan {
|
||||
return types.GrpToChn(name)
|
||||
|
||||
Reference in New Issue
Block a user