Changeset 284 in code for trunk/upstream.go


Ignore:
Timestamp:
May 1, 2020, 1:18:14 PM (5 years ago)
Author:
contact
Message:

Add support for detached channels

Channels can now be detached by leaving them with the reason "detach",
and re-attached by joining them again. Upon detaching the channel is
no longer forwarded to downstream connections. Upon re-attaching the
history buffer is sent.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/upstream.go

    r282 r284  
    14061406// appendHistory appends a message to the history. entity can be empty.
    14071407func (uc *upstreamConn) appendHistory(entity string, msg *irc.Message) {
     1408        detached := false
     1409        if ch, ok := uc.network.channels[entity]; ok {
     1410                detached = ch.Detached
     1411        }
     1412
    14081413        // If no client is offline, no need to append the message to the buffer
    1409         if len(uc.network.offlineClients) == 0 {
     1414        if len(uc.network.offlineClients) == 0 && !detached {
    14101415                return
    14111416        }
     
    14211426                for clientName, _ := range uc.network.offlineClients {
    14221427                        history.offlineClients[clientName] = 0
     1428                }
     1429
     1430                if detached {
     1431                        // If the channel is detached, online clients act as offline
     1432                        // clients too
     1433                        uc.forEachDownstream(func(dc *downstreamConn) {
     1434                                history.offlineClients[dc.clientName] = 0
     1435                        })
    14231436                }
    14241437        }
     
    14391452        uc.appendHistory(target, msg)
    14401453
     1454        // Don't forward messages if it's a detached channel
     1455        if ch, ok := uc.network.channels[target]; ok && ch.Detached {
     1456                return
     1457        }
     1458
    14411459        uc.forEachDownstream(func(dc *downstreamConn) {
    14421460                if dc != origin || dc.caps["echo-message"] {
Note: See TracChangeset for help on using the changeset viewer.