Browse Source

Review fixes

tags/v2.2.0-rc1
Daniel Oaks 4 years ago
parent
commit
6bee1f6d6a
3 changed files with 11 additions and 25 deletions
  1. 10
    12
      irc/channel.go
  2. 1
    1
      irc/handlers.go
  3. 0
    12
      irc/modes/modes.go

+ 10
- 12
irc/channel.go View File

@@ -541,25 +541,23 @@ func (channel *Channel) ClientPrefixes(client *Client, isMultiPrefix bool) strin
541 541
 	}
542 542
 }
543 543
 
544
-func (channel *Channel) ClientModeStrings(client *Client) []string {
544
+func (channel *Channel) ClientModeStrings(client *Client) (result []string) {
545 545
 	channel.stateMutex.RLock()
546 546
 	defer channel.stateMutex.RUnlock()
547 547
 	modes, present := channel.members[client]
548
-	if !present {
549
-		return []string{}
550
-	} else {
551
-		return modes.Strings()
548
+	if present {
549
+		for _, mode := range modes.AllModes() {
550
+			result = append(result, mode.String())
551
+		}
552 552
 	}
553
+	return
553 554
 }
554 555
 
555
-func (channel *Channel) ClientJoinTime(client *Client) *time.Time {
556
+func (channel *Channel) ClientJoinTime(client *Client) time.Time {
556 557
 	channel.stateMutex.RLock()
557 558
 	defer channel.stateMutex.RUnlock()
558
-	time, present := channel.memberJoinTimes[client]
559
-	if present {
560
-		return &time
561
-	}
562
-	return nil
559
+	time := channel.memberJoinTimes[client]
560
+	return time
563 561
 }
564 562
 
565 563
 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
738 736
 			defer channel.stateMutex.Unlock()
739 737
 
740 738
 			channel.members.Add(client)
741
-			channel.memberJoinTimes[client] = time.Now()
739
+			channel.memberJoinTimes[client] = time.Now().UTC()
742 740
 			firstJoin := len(channel.members) == 1
743 741
 			newChannel := firstJoin && channel.registeredFounder == ""
744 742
 			if newChannel {

+ 1
- 1
irc/handlers.go View File

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

+ 0
- 12
irc/modes/modes.go View File

@@ -388,18 +388,6 @@ func (set *ModeSet) String() (result string) {
388 388
 	return buf.String()
389 389
 }
390 390
 
391
-// Strings returns the modes in this set.
392
-func (set *ModeSet) Strings() (result []string) {
393
-	if set == nil {
394
-		return
395
-	}
396
-
397
-	for _, mode := range set.AllModes() {
398
-		result = append(result, mode.String())
399
-	}
400
-	return
401
-}
402
-
403 391
 // Prefixes returns a list of prefixes for the given set of channel modes.
404 392
 func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
405 393
 	if set == nil {

Loading…
Cancel
Save