Changeset 185 in code for trunk


Ignore:
Timestamp:
Mar 28, 2020, 4:36:09 PM (5 years ago)
Author:
contact
Message:

Use clientName to decide whether or not history should be sent

Closes: https://todo.sr.ht/~emersion/soju/31

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r184 r185  
    688688        }
    689689
    690         firstDownstream := len(dc.user.downstreamConns) == 0
     690        // Only send history if we're the first connected client with that name and
     691        // network
     692        sendHistory := true
     693        dc.user.forEachDownstream(func(conn *downstreamConn) {
     694                if dc.clientName == conn.clientName && dc.network == conn.network {
     695                        sendHistory = false
     696                }
     697        })
    691698
    692699        dc.SendMessage(&irc.Message{
     
    732739
    733740        dc.forEachNetwork(func(net *network) {
    734                 // TODO: need to take dc.network into account when deciding whether or
    735                 // not to load history
    736                 dc.runNetwork(net, firstDownstream)
     741                dc.runNetwork(net, sendHistory)
    737742        })
    738743
     
    749754        }
    750755
    751         historyName := dc.rawUsername
    752 
    753756        var seqPtr *uint64
    754757        if loadHistory {
    755758                net.lock.Lock()
    756                 seq, ok := net.history[historyName]
     759                seq, ok := net.history[dc.clientName]
    757760                net.lock.Unlock()
    758761                if ok {
     
    781784                }
    782785
     786                // TODO: close the consumer from the user goroutine, so we don't need
     787                // that net.history lock
    783788                seq := consumer.Close()
    784789
    785790                net.lock.Lock()
    786                 net.history[historyName] = seq
     791                net.history[dc.clientName] = seq
    787792                net.lock.Unlock()
    788793        }()
Note: See TracChangeset for help on using the changeset viewer.