Changeset 409 in code for trunk/upstream.go
- Timestamp:
- Aug 20, 2020, 6:05:01 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/upstream.go
r407 r409 709 709 ch.Members[newNick] = memberships 710 710 uc.appendLog(ch.Name, msg) 711 uc.appendHistory(ch.Name, msg)712 711 } 713 712 } … … 819 818 820 819 uc.appendLog(ch.Name, msg) 821 uc.appendHistory(ch.Name, msg)822 820 } 823 821 } … … 1612 1610 } 1613 1611 1614 // TODO: handle moving logs when a network name changes, when support for this is added1615 1612 func (uc *upstreamConn) appendLog(entity string, msg *irc.Message) { 1616 1613 if uc.srv.LogPath == "" { … … 1624 1621 } 1625 1622 1626 if _, err := ml.Append(msg); err != nil {1627 uc.logger.Printf("failed to log message: %v", err)1628 }1629 }1630 1631 // appendHistory appends a message to the history. entity can be empty.1632 func (uc *upstreamConn) appendHistory(entity string, msg *irc.Message) {1633 1623 detached := false 1634 1624 if ch, ok := uc.network.channels[entity]; ok { … … 1638 1628 history, ok := uc.network.history[entity] 1639 1629 if !ok { 1630 lastID, err := lastMsgID(uc.network, entity, time.Now()) 1631 if err != nil { 1632 uc.logger.Printf("failed to log message: failed to get last message ID: %v", err) 1633 return 1634 } 1635 1640 1636 history = &networkHistory{ 1641 clients: make(map[string]uint64), 1642 ring: NewRing(uc.srv.RingCap), 1637 clients: make(map[string]string), 1643 1638 } 1644 1639 uc.network.history[entity] = history 1645 1640 1646 1641 for clientName, _ := range uc.network.offlineClients { 1647 history.clients[clientName] = 01642 history.clients[clientName] = lastID 1648 1643 } 1649 1644 … … 1652 1647 // clients too 1653 1648 uc.forEachDownstream(func(dc *downstreamConn) { 1654 history.clients[dc.clientName] = 0 1655 }) 1656 } 1657 } 1658 1659 history.ring.Produce(msg) 1649 history.clients[dc.clientName] = lastID 1650 }) 1651 } 1652 } 1653 1654 msgID, err := ml.Append(msg) 1655 if err != nil { 1656 uc.logger.Printf("failed to log message: %v", err) 1657 return 1658 } 1660 1659 1661 1660 if !detached { 1662 1661 uc.forEachDownstream(func(dc *downstreamConn) { 1663 history.clients[dc.clientName] = history.ring.Cur()1664 }) 1665 } 1666 } 1667 1668 // produce appends a message to the logs , adds it to the history and forwards1669 // it to connected downstreamconnections.1662 history.clients[dc.clientName] = msgID 1663 }) 1664 } 1665 } 1666 1667 // produce appends a message to the logs and forwards it to connected downstream 1668 // connections. 1670 1669 // 1671 1670 // If origin is not nil and origin doesn't support echo-message, the message is … … 1675 1674 uc.appendLog(target, msg) 1676 1675 } 1677 1678 uc.appendHistory(target, msg)1679 1676 1680 1677 // Don't forward messages if it's a detached channel
Note:
See TracChangeset
for help on using the changeset viewer.