Changeset 292 in code for trunk/downstream.go


Ignore:
Timestamp:
May 11, 2020, 10:25:49 AM (5 years ago)
Author:
delthas
Message:

Add support for multiple user channel memberships

User channel memberships are actually a set of memberships, not a single
value. This introduces memberships, a type representing a set of
memberships, stored as an array of memberships ordered by descending
rank.

This also adds multi-prefix to the permanent downstream and upstream
capabilities, so that we try to get all possible channel memberships.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r291 r292  
    6060        "sasl":         "PLAIN",
    6161        "server-time":  "",
     62}
     63
     64// needAllDownstreamCaps is the list of downstream capabilities that
     65// require support from all upstreams to be enabled
     66var needAllDownstreamCaps = map[string]string{
     67        "away-notify":  "",
     68        "multi-prefix": "",
    6269}
    6370
     
    597604
    598605func (dc *downstreamConn) updateSupportedCaps() {
    599         awayNotifySupported := true
     606        supportedCaps := make(map[string]bool)
     607        for cap := range needAllDownstreamCaps {
     608                supportedCaps[cap] = true
     609        }
    600610        dc.forEachUpstream(func(uc *upstreamConn) {
    601                 awayNotifySupported = awayNotifySupported && uc.caps["away-notify"]
     611                for cap, supported := range supportedCaps {
     612                        supportedCaps[cap] = supported && uc.caps[cap]
     613                }
    602614        })
    603615
    604         if awayNotifySupported {
    605                 dc.setSupportedCap("away-notify", "")
    606         } else {
    607                 dc.unsetSupportedCap("away-notify")
     616        for cap, supported := range supportedCaps {
     617                if supported {
     618                        dc.setSupportedCap(cap, needAllDownstreamCaps[cap])
     619                } else {
     620                        dc.unsetSupportedCap(cap)
     621                }
    608622        }
    609623}
Note: See TracChangeset for help on using the changeset viewer.