3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-22 10:42:52 +01:00

eliminate client.Realname() getter

This commit is contained in:
Shivaram Lingamneni 2019-05-22 16:10:56 -04:00
parent cf153c2b09
commit 1de166bccb
4 changed files with 14 additions and 18 deletions

View File

@ -668,10 +668,11 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
func (channel *Channel) playJoinForSession(session *Session) {
client := session.client
sessionRb := NewResponseBuffer(session)
details := client.Details()
if session.capabilities.Has(caps.ExtendedJoin) {
sessionRb.Add(nil, client.NickMaskString(), "JOIN", channel.Name(), client.AccountName(), client.Realname())
sessionRb.Add(nil, details.nickMask, "JOIN", channel.Name(), details.accountName, details.realname)
} else {
sessionRb.Add(nil, client.NickMaskString(), "JOIN", channel.Name())
sessionRb.Add(nil, details.nickMask, "JOIN", channel.Name())
}
channel.SendTopic(client, sessionRb, false)
channel.Names(client, sessionRb)
@ -738,7 +739,6 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
// send join for old clients
chname := channel.Name()
details := session.client.Details()
realName := session.client.Realname()
for _, member := range channel.Members() {
for _, session := range member.Sessions() {
if session.capabilities.Has(caps.Resume) {
@ -746,7 +746,7 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
}
if session.capabilities.Has(caps.ExtendedJoin) {
session.Send(nil, details.nickMask, "JOIN", chname, details.accountName, realName)
session.Send(nil, details.nickMask, "JOIN", chname, details.accountName, details.realname)
} else {
session.Send(nil, details.nickMask, "JOIN", chname)
}
@ -760,7 +760,7 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
rb := NewResponseBuffer(session)
// use blocking i/o to synchronize with the later history replay
if rb.session.capabilities.Has(caps.ExtendedJoin) {
rb.Add(nil, details.nickMask, "JOIN", channel.name, details.accountName, realName)
rb.Add(nil, details.nickMask, "JOIN", channel.name, details.accountName, details.realname)
} else {
rb.Add(nil, details.nickMask, "JOIN", channel.name)
}

View File

@ -187,12 +187,6 @@ func (client *Client) Hostname() string {
return client.hostname
}
func (client *Client) Realname() string {
client.stateMutex.RLock()
defer client.stateMutex.RUnlock()
return client.realname
}
func (client *Client) Away() (result bool) {
client.stateMutex.Lock()
result = client.away

View File

@ -2318,12 +2318,13 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
// send RENAME messages
clientPrefix := client.NickMaskString()
for _, mcl := range channel.Members() {
mDetails := mcl.Details()
for _, mSession := range mcl.Sessions() {
targetRb := rb
targetPrefix := clientPrefix
if mSession != rb.session {
targetRb = NewResponseBuffer(mSession)
targetPrefix = mcl.NickMaskString()
targetPrefix = mDetails.nickMask
}
if mSession.capabilities.Has(caps.Rename) {
if reason != "" {
@ -2338,7 +2339,7 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
targetRb.Add(nil, targetPrefix, "PART", oldName, fmt.Sprintf(mcl.t("Channel renamed")))
}
if mSession.capabilities.Has(caps.ExtendedJoin) {
targetRb.Add(nil, targetPrefix, "JOIN", newName, mcl.AccountName(), mcl.Realname())
targetRb.Add(nil, targetPrefix, "JOIN", newName, mDetails.accountName, mDetails.realname)
} else {
targetRb.Add(nil, targetPrefix, "JOIN", newName)
}

View File

@ -497,26 +497,27 @@ func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
// rplWhoReply returns the WHO reply between one user and another channel/user.
// <channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ]
// :<hopcount> <real name>
func (target *Client) rplWhoReply(channel *Channel, client *Client, rb *ResponseBuffer) {
func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer) {
channelName := "*"
flags := ""
if client.Away() {
if target.Away() {
flags = "G"
} else {
flags = "H"
}
if client.HasMode(modes.Operator) {
if target.HasMode(modes.Operator) {
flags += "*"
}
if channel != nil {
// TODO is this right?
flags += channel.ClientPrefixes(client, rb.session.capabilities.Has(caps.MultiPrefix))
flags += channel.ClientPrefixes(target, rb.session.capabilities.Has(caps.MultiPrefix))
channelName = channel.name
}
details := target.Details()
// hardcode a hopcount of 0 for now
rb.Add(nil, target.server.name, RPL_WHOREPLY, target.nick, channelName, client.Username(), client.Hostname(), client.server.name, client.Nick(), flags, "0 "+client.Realname())
rb.Add(nil, client.server.name, RPL_WHOREPLY, client.Nick(), channelName, details.username, details.hostname, client.server.name, details.nick, flags, "0 "+details.realname)
}
// rehash reloads the config and applies the changes from the config file.