Browse Source

fix #1198

tags/v2.2.0-rc1
Shivaram Lingamneni 3 years ago
parent
commit
93530ae397
5 changed files with 18 additions and 12 deletions
  1. 6
    2
      irc/channel.go
  2. 2
    2
      irc/getters.go
  3. 6
    4
      irc/handlers.go
  4. 2
    2
      irc/roleplay.go
  5. 2
    2
      irc/server.go

+ 6
- 2
irc/channel.go View File

@@ -767,6 +767,7 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
767 767
 		modestr = fmt.Sprintf("+%v", givenMode)
768 768
 	}
769 769
 
770
+	isAway, awayMessage := client.Away()
770 771
 	for _, member := range channel.Members() {
771 772
 		for _, session := range member.Sessions() {
772 773
 			if session == rb.session {
@@ -783,6 +784,9 @@ func (channel *Channel) Join(client *Client, key string, isSajoin bool, rb *Resp
783 784
 			if givenMode != 0 {
784 785
 				session.Send(nil, client.server.name, "MODE", chname, modestr, details.nick)
785 786
 			}
787
+			if isAway && session.capabilities.Has(caps.AwayNotify) {
788
+				session.sendFromClientInternal(false, time.Time{}, "", details.nickMask, details.account, nil, "AWAY", awayMessage)
789
+			}
786 790
 		}
787 791
 	}
788 792
 
@@ -1458,8 +1462,8 @@ func (channel *Channel) Invite(invitee *Client, inviter *Client, rb *ResponseBuf
1458 1462
 	tnick := invitee.Nick()
1459 1463
 	rb.Add(nil, inviter.server.name, RPL_INVITING, cnick, tnick, chname)
1460 1464
 	invitee.Send(nil, inviter.NickMaskString(), "INVITE", tnick, chname)
1461
-	if invitee.Away() {
1462
-		rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, invitee.AwayMessage())
1465
+	if away, awayMessage := invitee.Away(); away {
1466
+		rb.Add(nil, inviter.server.name, RPL_AWAY, cnick, tnick, awayMessage)
1463 1467
 	}
1464 1468
 }
1465 1469
 

+ 2
- 2
irc/getters.go View File

@@ -185,9 +185,9 @@ func (client *Client) Hostname() string {
185 185
 	return client.hostname
186 186
 }
187 187
 
188
-func (client *Client) Away() (result bool) {
188
+func (client *Client) Away() (result bool, message string) {
189 189
 	client.stateMutex.Lock()
190
-	result = client.away
190
+	result, message = client.away, client.awayMessage
191 191
 	client.stateMutex.Unlock()
192 192
 	return
193 193
 }

+ 6
- 4
irc/handlers.go View File

@@ -2122,9 +2122,11 @@ func dispatchMessageToTarget(client *Client, tags map[string]string, histType hi
2122 2122
 				rb.AddSplitMessageFromClient(nickMaskString, accountName, tagsToSend, command, tnick, message)
2123 2123
 			}
2124 2124
 		}
2125
-		if histType != history.Notice && user.Away() {
2125
+		if histType != history.Notice {
2126 2126
 			//TODO(dan): possibly implement cooldown of away notifications to users
2127
-			rb.Add(nil, server.name, RPL_AWAY, client.Nick(), tnick, user.AwayMessage())
2127
+			if away, awayMessage := user.Away(); away {
2128
+				rb.Add(nil, server.name, RPL_AWAY, client.Nick(), tnick, awayMessage)
2129
+			}
2128 2130
 		}
2129 2131
 
2130 2132
 		config := server.Config()
@@ -2742,7 +2744,7 @@ func userhostHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *
2742 2744
 		if target.HasMode(modes.Operator) {
2743 2745
 			isOper = "*"
2744 2746
 		}
2745
-		if target.Away() {
2747
+		if away, _ := target.Away(); away {
2746 2748
 			isAway = "-"
2747 2749
 		} else {
2748 2750
 			isAway = "+"
@@ -2893,7 +2895,7 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response
2893 2895
 	}
2894 2896
 	if fields.Has('f') { // "flags" (away + oper state + channel status prefix + bot)
2895 2897
 		var flags strings.Builder
2896
-		if target.Away() {
2898
+		if away, _ := target.Away(); away {
2897 2899
 			flags.WriteRune('G') // Gone
2898 2900
 		} else {
2899 2901
 			flags.WriteRune('H') // Here

+ 2
- 2
irc/roleplay.go View File

@@ -110,9 +110,9 @@ func sendRoleplayMessage(server *Server, client *Client, source string, targetSt
110 110
 		for _, session := range user.Sessions() {
111 111
 			session.sendSplitMsgFromClientInternal(false, source, "", nil, "PRIVMSG", tnick, splitMessage)
112 112
 		}
113
-		if user.Away() {
113
+		if away, awayMessage := user.Away(); away {
114 114
 			//TODO(dan): possibly implement cooldown of away notifications to users
115
-			rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, user.AwayMessage())
115
+			rb.Add(nil, server.name, RPL_AWAY, cnick, tnick, awayMessage)
116 116
 		}
117 117
 	}
118 118
 }

+ 2
- 2
irc/server.go View File

@@ -436,8 +436,8 @@ func (client *Client) getWhoisOf(target *Client, rb *ResponseBuffer) {
436 436
 		}
437 437
 	}
438 438
 	rb.Add(nil, client.server.name, RPL_WHOISIDLE, cnick, tnick, strconv.FormatUint(target.IdleSeconds(), 10), strconv.FormatInt(target.SignonTime(), 10), client.t("seconds idle, signon time"))
439
-	if target.Away() {
440
-		rb.Add(nil, client.server.name, RPL_AWAY, cnick, tnick, target.AwayMessage())
439
+	if away, awayMessage := target.Away(); away {
440
+		rb.Add(nil, client.server.name, RPL_AWAY, cnick, tnick, awayMessage)
441 441
 	}
442 442
 }
443 443
 

Loading…
Cancel
Save