mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 18:52:41 +01:00
Review fixes
This commit is contained in:
parent
4164c643e6
commit
6bee1f6d6a
@ -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()
|
channel.stateMutex.RLock()
|
||||||
defer channel.stateMutex.RUnlock()
|
defer channel.stateMutex.RUnlock()
|
||||||
modes, present := channel.members[client]
|
modes, present := channel.members[client]
|
||||||
if !present {
|
if present {
|
||||||
return []string{}
|
for _, mode := range modes.AllModes() {
|
||||||
} else {
|
result = append(result, mode.String())
|
||||||
return modes.Strings()
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) ClientJoinTime(client *Client) *time.Time {
|
func (channel *Channel) ClientJoinTime(client *Client) time.Time {
|
||||||
channel.stateMutex.RLock()
|
channel.stateMutex.RLock()
|
||||||
defer channel.stateMutex.RUnlock()
|
defer channel.stateMutex.RUnlock()
|
||||||
time, present := channel.memberJoinTimes[client]
|
time := channel.memberJoinTimes[client]
|
||||||
if present {
|
return time
|
||||||
return &time
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
|
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()
|
defer channel.stateMutex.Unlock()
|
||||||
|
|
||||||
channel.members.Add(client)
|
channel.members.Add(client)
|
||||||
channel.memberJoinTimes[client] = time.Now()
|
channel.memberJoinTimes[client] = time.Now().UTC()
|
||||||
firstJoin := len(channel.members) == 1
|
firstJoin := len(channel.members) == 1
|
||||||
newChannel := firstJoin && channel.registeredFounder == ""
|
newChannel := firstJoin && channel.registeredFounder == ""
|
||||||
if newChannel {
|
if newChannel {
|
||||||
|
@ -940,7 +940,7 @@ func extjwtHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Re
|
|||||||
claims["cmodes"] = []string{}
|
claims["cmodes"] = []string{}
|
||||||
if channel.hasClient(client) {
|
if channel.hasClient(client) {
|
||||||
joinTime := channel.ClientJoinTime(client)
|
joinTime := channel.ClientJoinTime(client)
|
||||||
if joinTime == nil {
|
if joinTime.IsZero() {
|
||||||
// shouldn't happen, only in races
|
// 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"))
|
rb.Add(nil, server.name, "FAIL", "EXTJWT", "UNKNOWN_ERROR", client.t("Channel join time is inconsistent, JWT not generated"))
|
||||||
return false
|
return false
|
||||||
|
@ -388,18 +388,6 @@ func (set *ModeSet) String() (result string) {
|
|||||||
return buf.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.
|
// Prefixes returns a list of prefixes for the given set of channel modes.
|
||||||
func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
|
func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
|
||||||
if set == nil {
|
if set == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user