Pārlūkot izejas kodu

Review fixes

tags/v2.2.0-rc1
Daniel Oaks 4 gadus atpakaļ
vecāks
revīzija
6bee1f6d6a
3 mainītis faili ar 11 papildinājumiem un 25 dzēšanām
  1. 10
    12
      irc/channel.go
  2. 1
    1
      irc/handlers.go
  3. 0
    12
      irc/modes/modes.go

+ 10
- 12
irc/channel.go Parādīt failu

541
 	}
541
 	}
542
 }
542
 }
543
 
543
 
544
-func (channel *Channel) ClientModeStrings(client *Client) []string {
544
+func (channel *Channel) ClientModeStrings(client *Client) (result []string) {
545
 	channel.stateMutex.RLock()
545
 	channel.stateMutex.RLock()
546
 	defer channel.stateMutex.RUnlock()
546
 	defer channel.stateMutex.RUnlock()
547
 	modes, present := channel.members[client]
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
 	channel.stateMutex.RLock()
557
 	channel.stateMutex.RLock()
557
 	defer channel.stateMutex.RUnlock()
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
 func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
563
 func (channel *Channel) ClientHasPrivsOver(client *Client, target *Client) bool {
738
 			defer channel.stateMutex.Unlock()
736
 			defer channel.stateMutex.Unlock()
739
 
737
 
740
 			channel.members.Add(client)
738
 			channel.members.Add(client)
741
-			channel.memberJoinTimes[client] = time.Now()
739
+			channel.memberJoinTimes[client] = time.Now().UTC()
742
 			firstJoin := len(channel.members) == 1
740
 			firstJoin := len(channel.members) == 1
743
 			newChannel := firstJoin && channel.registeredFounder == ""
741
 			newChannel := firstJoin && channel.registeredFounder == ""
744
 			if newChannel {
742
 			if newChannel {

+ 1
- 1
irc/handlers.go Parādīt failu

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

+ 0
- 12
irc/modes/modes.go Parādīt failu

388
 	return buf.String()
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
 // Prefixes returns a list of prefixes for the given set of channel modes.
391
 // Prefixes returns a list of prefixes for the given set of channel modes.
404
 func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
392
 func (set *ModeSet) Prefixes(isMultiPrefix bool) (prefixes string) {
405
 	if set == nil {
393
 	if set == nil {

Notiek ielāde…
Atcelt
Saglabāt