Rename network.history to network.delivered
"History" is over-loaded with e.g. CHATHISTORY support.
This commit is contained in:
parent
c14118f7f9
commit
7e39f6d663
@ -325,12 +325,12 @@ func (dc *downstreamConn) ackMsgID(id string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
history, ok := network.history[entity]
|
delivered, ok := network.delivered[entity]
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
history.clients[dc.clientName] = id
|
delivered[dc.clientName] = id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dc *downstreamConn) sendPing(msgID string) {
|
func (dc *downstreamConn) sendPing(msgID string) {
|
||||||
@ -947,7 +947,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fast-forward history to last message
|
// Fast-forward history to last message
|
||||||
for target, history := range net.history {
|
for target, delivered := range net.delivered {
|
||||||
if ch, ok := net.channels[target]; ok && ch.Detached {
|
if ch, ok := net.channels[target]; ok && ch.Detached {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ func (dc *downstreamConn) welcome() error {
|
|||||||
dc.logger.Printf("failed to get last message ID: %v", err)
|
dc.logger.Printf("failed to get last message ID: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
history.clients[dc.clientName] = lastID
|
delivered[dc.clientName] = lastID
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -982,12 +982,12 @@ func (dc *downstreamConn) sendNetworkBacklog(net *network) {
|
|||||||
if dc.caps["draft/chathistory"] || dc.user.msgStore == nil {
|
if dc.caps["draft/chathistory"] || dc.user.msgStore == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for target, history := range net.history {
|
for target, delivered := range net.delivered {
|
||||||
if ch, ok := net.channels[target]; ok && ch.Detached {
|
if ch, ok := net.channels[target]; ok && ch.Detached {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
lastDelivered, ok := history.clients[dc.clientName]
|
lastDelivered, ok := delivered[dc.clientName]
|
||||||
if !ok {
|
if !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
12
upstream.go
12
upstream.go
@ -1678,7 +1678,7 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
|
|||||||
detached = ch.Detached
|
detached = ch.Detached
|
||||||
}
|
}
|
||||||
|
|
||||||
history, ok := uc.network.history[entity]
|
delivered, ok := uc.network.delivered[entity]
|
||||||
if !ok {
|
if !ok {
|
||||||
lastID, err := uc.user.msgStore.LastMsgID(uc.network, entity, time.Now())
|
lastID, err := uc.user.msgStore.LastMsgID(uc.network, entity, time.Now())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1686,20 +1686,18 @@ func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) (msgID string
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
history = &networkHistory{
|
delivered = make(map[string]string)
|
||||||
clients: make(map[string]string),
|
uc.network.delivered[entity] = delivered
|
||||||
}
|
|
||||||
uc.network.history[entity] = history
|
|
||||||
|
|
||||||
for clientName, _ := range uc.network.offlineClients {
|
for clientName, _ := range uc.network.offlineClients {
|
||||||
history.clients[clientName] = lastID
|
delivered[clientName] = lastID
|
||||||
}
|
}
|
||||||
|
|
||||||
if detached {
|
if detached {
|
||||||
// If the channel is detached, online clients act as offline
|
// If the channel is detached, online clients act as offline
|
||||||
// clients too
|
// clients too
|
||||||
uc.forEachDownstream(func(dc *downstreamConn) {
|
uc.forEachDownstream(func(dc *downstreamConn) {
|
||||||
history.clients[dc.clientName] = lastID
|
delivered[dc.clientName] = lastID
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
12
user.go
12
user.go
@ -55,10 +55,6 @@ type eventChannelDetach struct {
|
|||||||
|
|
||||||
type eventStop struct{}
|
type eventStop struct{}
|
||||||
|
|
||||||
type networkHistory struct {
|
|
||||||
clients map[string]string // indexed by client name
|
|
||||||
}
|
|
||||||
|
|
||||||
type network struct {
|
type network struct {
|
||||||
Network
|
Network
|
||||||
user *user
|
user *user
|
||||||
@ -66,8 +62,8 @@ type network struct {
|
|||||||
|
|
||||||
conn *upstreamConn
|
conn *upstreamConn
|
||||||
channels map[string]*Channel
|
channels map[string]*Channel
|
||||||
history map[string]*networkHistory // indexed by entity
|
delivered map[string]map[string]string // entity -> client name -> msg ID
|
||||||
offlineClients map[string]struct{} // indexed by client name
|
offlineClients map[string]struct{} // indexed by client name
|
||||||
lastError error
|
lastError error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +79,7 @@ func newNetwork(user *user, record *Network, channels []Channel) *network {
|
|||||||
user: user,
|
user: user,
|
||||||
stopped: make(chan struct{}),
|
stopped: make(chan struct{}),
|
||||||
channels: m,
|
channels: m,
|
||||||
history: make(map[string]*networkHistory),
|
delivered: make(map[string]map[string]string),
|
||||||
offlineClients: make(map[string]struct{}),
|
offlineClients: make(map[string]struct{}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -230,7 +226,7 @@ func (net *network) attach(ch *Channel) {
|
|||||||
forwardChannel(dc, uch)
|
forwardChannel(dc, uch)
|
||||||
}
|
}
|
||||||
|
|
||||||
if net.history[ch.Name] != nil {
|
if _, ok := net.delivered[ch.Name]; ok {
|
||||||
dc.sendNetworkBacklog(net)
|
dc.sendNetworkBacklog(net)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user