diff --git a/irc/channel.go b/irc/channel.go index b9af37fe..3b47b49d 100644 --- a/irc/channel.go +++ b/irc/channel.go @@ -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 { diff --git a/irc/handlers.go b/irc/handlers.go index d6deaa35..3daeb358 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -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 diff --git a/irc/modes/modes.go b/irc/modes/modes.go index 89216cf8..ae2d9224 100644 --- a/irc/modes/modes.go +++ b/irc/modes/modes.go @@ -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 {