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

Review fixes

This commit is contained in:
Daniel Oaks 2020-04-17 16:23:18 +10:00 committed by Shivaram Lingamneni
parent 4164c643e6
commit 6bee1f6d6a
3 changed files with 11 additions and 25 deletions

View File

@ -541,25 +541,23 @@ func (channel *Channel) ClientPrefixes(client *Client, isMultiPrefix bool) strin
}
}
func (channel *Channel) ClientModeStrings(client *Client) []string {
func (channel *Channel) ClientModeStrings(client *Client) (result []string) {
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()
modes, present := channel.members[client]
if !present {
return []string{}
} else {
return modes.Strings()
if present {
for _, mode := range modes.AllModes() {
result = append(result, mode.String())
}
}
return
}
func (channel *Channel) ClientJoinTime(client *Client) *time.Time {
func (channel *Channel) ClientJoinTime(client *Client) time.Time {
channel.stateMutex.RLock()
defer channel.stateMutex.RUnlock()
time, present := channel.memberJoinTimes[client]
if present {
return &time
}
return nil
time := channel.memberJoinTimes[client]
return time
}
func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
@ -738,7 +736,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
defer channel.stateMutex.Unlock()
channel.members.Add(client)
channel.memberJoinTimes[client] = time.Now()
channel.memberJoinTimes[client] = time.Now().UTC()
firstJoin := len(channel.members) == 1
newChannel := firstJoin && channel.registeredFounder == ""
if newChannel {

View File

@ -940,7 +940,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
claims["cmodes"] = []string{}
if channel.hasClient(client) {
joinTime := channel.ClientJoinTime(client)
if joinTime == nil {
if joinTime.IsZero() {
// shouldn't happen, only in races
rb.Add(nil, server.name, "FAIL", "EXTJWT", "UNKNOWN_ERROR", client.t("Channel join time is inconsistent, JWT not generated"))
return false

View File

@ -388,18 +388,6 @@ func (set *ModeSet) String() (result string) {
return buf.String()
}
// Strings returns the modes in this set.
func (set *ModeSet) Strings() (result []string) {
if set == nil {
return
}
for _, mode := range set.AllModes() {
result = append(result, mode.String())
}
return
}
// Prefixes returns a list of prefixes for the given set of channel modes.
func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
if set == nil {