Changeset 409 in code for trunk/downstream.go
- Timestamp:
- Aug 20, 2020, 6:05:01 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/downstream.go
r406 r409 851 851 delete(net.offlineClients, dc.clientName) 852 852 } 853 854 // Fast-forward history to last message 855 for target, history := range net.history { 856 if ch, ok := net.channels[target]; ok && ch.Detached { 857 continue 858 } 859 860 lastID, err := lastMsgID(net, target, time.Now()) 861 if err != nil { 862 dc.logger.Printf("failed to get last message ID: %v", err) 863 continue 864 } 865 history.clients[dc.clientName] = lastID 866 } 853 867 }) 854 868 … … 857 871 858 872 func (dc *downstreamConn) sendNetworkHistory(net *network) { 859 if dc.caps["draft/chathistory"] {873 if dc.caps["draft/chathistory"] || dc.srv.LogPath == "" { 860 874 return 861 875 } … … 865 879 } 866 880 867 seq, ok := history.clients[dc.clientName]881 lastDelivered, ok := history.clients[dc.clientName] 868 882 if !ok { 869 883 continue 870 884 } 871 history.clients[dc.clientName] = history.ring.Cur() 872 873 consumer := history.ring.NewConsumer(seq) 885 886 limit := 4000 887 history, err := loadHistoryLatestID(dc.network, target, lastDelivered, limit) 888 if err != nil { 889 dc.logger.Printf("failed to send implicit history for %q: %v", target, err) 890 continue 891 } 874 892 875 893 batchRef := "history" … … 882 900 } 883 901 884 for { 885 msg := consumer.Consume() 886 if msg == nil { 887 break 888 } 889 902 for _, msg := range history { 890 903 // Don't replay all messages, because that would mess up client 891 904 // state. For instance we just sent the list of users, sending … … 901 914 902 915 if dc.caps["batch"] { 903 msg = msg.Copy()904 916 msg.Tags["batch"] = irc.TagValue(batchRef) 905 917 } 906 907 918 dc.SendMessage(dc.marshalMessage(msg, net)) 908 919 }
Note:
See TracChangeset
for help on using the changeset viewer.