3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 20:09:41 +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) { func (channel *Channel) playJoinForSession(session *Session) {
client := session.client client := session.client
sessionRb := NewResponseBuffer(session) sessionRb := NewResponseBuffer(session)
details := client.Details()
if session.capabilities.Has(caps.ExtendedJoin) { 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 { } else {
sessionRb.Add(nil, client.NickMaskString(), "JOIN", channel.Name()) sessionRb.Add(nil, details.nickMask, "JOIN", channel.Name())
} }
channel.SendTopic(client, sessionRb, false) channel.SendTopic(client, sessionRb, false)
channel.Names(client, sessionRb) channel.Names(client, sessionRb)
@ -738,7 +739,6 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
// send join for old clients // send join for old clients
chname := channel.Name() chname := channel.Name()
details := session.client.Details() details := session.client.Details()
realName := session.client.Realname()
for _, member := range channel.Members() { for _, member := range channel.Members() {
for _, session := range member.Sessions() { for _, session := range member.Sessions() {
if session.capabilities.Has(caps.Resume) { if session.capabilities.Has(caps.Resume) {
@ -746,7 +746,7 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
} }
if session.capabilities.Has(caps.ExtendedJoin) { 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 { } else {
session.Send(nil, details.nickMask, "JOIN", chname) session.Send(nil, details.nickMask, "JOIN", chname)
} }
@ -760,7 +760,7 @@ func (channel *Channel) resumeAndAnnounce(session *Session) {
rb := NewResponseBuffer(session) rb := NewResponseBuffer(session)
// use blocking i/o to synchronize with the later history replay // use blocking i/o to synchronize with the later history replay
if rb.session.capabilities.Has(caps.ExtendedJoin) { 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 { } else {
rb.Add(nil, details.nickMask, "JOIN", channel.name) rb.Add(nil, details.nickMask, "JOIN", channel.name)
} }

View File

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

View File

@ -2318,12 +2318,13 @@ func renameHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
// send RENAME messages // send RENAME messages
clientPrefix := client.NickMaskString() clientPrefix := client.NickMaskString()
for _, mcl := range channel.Members() { for _, mcl := range channel.Members() {
mDetails := mcl.Details()
for _, mSession := range mcl.Sessions() { for _, mSession := range mcl.Sessions() {
targetRb := rb targetRb := rb
targetPrefix := clientPrefix targetPrefix := clientPrefix
if mSession != rb.session { if mSession != rb.session {
targetRb = NewResponseBuffer(mSession) targetRb = NewResponseBuffer(mSession)
targetPrefix = mcl.NickMaskString() targetPrefix = mDetails.nickMask
} }
if mSession.capabilities.Has(caps.Rename) { if mSession.capabilities.Has(caps.Rename) {
if reason != "" { 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"))) targetRb.Add(nil, targetPrefix, "PART", oldName, fmt.Sprintf(mcl.t("Channel renamed")))
} }
if mSession.capabilities.Has(caps.ExtendedJoin) { 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 { } else {
targetRb.Add(nil, targetPrefix, "JOIN", newName) 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. // rplWhoReply returns the WHO reply between one user and another channel/user.
// <channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ] // <channel> <user> <host> <server> <nick> ( "H" / "G" ) ["*"] [ ( "@" / "+" ) ]
// :<hopcount> <real name> // :<hopcount> <real name>
func (target *Client) rplWhoReply(channel *Channel, client *Client, rb *ResponseBuffer) { func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer) {
channelName := "*" channelName := "*"
flags := "" flags := ""
if client.Away() { if target.Away() {
flags = "G" flags = "G"
} else { } else {
flags = "H" flags = "H"
} }
if client.HasMode(modes.Operator) { if target.HasMode(modes.Operator) {
flags += "*" flags += "*"
} }
if channel != nil { if channel != nil {
// TODO is this right? // 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 channelName = channel.name
} }
details := target.Details()
// hardcode a hopcount of 0 for now // 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. // rehash reloads the config and applies the changes from the config file.