func peerFrom(entry data.RosterEntry, c *config.Account) *roster.Peer { belongsTo := c.ID() var nickname string p, ok := c.GetPeer(entry.Jid) if ok { nickname = p.Nickname } return roster.PeerFrom(entry, belongsTo, nickname) }
func peerFrom(entry data.RosterEntry, c *config.Account) *roster.Peer { belongsTo := c.ID() var nickname string var groups []string if p, ok := c.GetPeer(entry.Jid); ok { nickname = p.Nickname groups = p.Groups } return roster.PeerFrom(entry, belongsTo, nickname, groups) }
// PeerFrom returns a new Peer that contains the same information as the RosterEntry given func PeerFrom(e xmpp.RosterEntry, conf *config.Account) *Peer { belongsTo := conf.ID() var nickname string p, ok := conf.GetPeer(e.Jid) if ok { nickname = p.Nickname } return &Peer{ Jid: xmpp.RemoveResourceFromJid(e.Jid), Subscription: e.Subscription, Name: e.Name, Nickname: nickname, Groups: toSet(e.Group...), BelongsTo: belongsTo, } }
func (m *accountManager) removeAccount(conf *config.Account, k func()) { toRemove, exists := m.getAccountByID(conf.ID()) if !exists { return } m.Lock() defer m.Unlock() accs := make([]*account, 0, len(m.accounts)-1) for _, acc := range m.accounts { if acc == toRemove { delete(m.contacts, acc) continue } accs = append(accs, acc) } m.accounts = accs k() }