Browse Source

accounts: Support account-notify capability

tags/v0.2.0
Daniel Oaks 7 years ago
parent
commit
4fa094cea2
3 changed files with 16 additions and 4 deletions
  1. 1
    0
      CHANGELOG.md
  2. 13
    4
      irc/accounts.go
  3. 2
    0
      irc/capability.go

+ 1
- 0
CHANGELOG.md View File

@@ -12,6 +12,7 @@ Improved compatibility, more features, etc.
12 12
 ### Security
13 13
 
14 14
 ### Added
15
+* Support for IRCv3 capability [`account-notify`](http://ircv3.net/specs/extensions/account-notify-3.1.html)
15 16
 
16 17
 ### Changed
17 18
 * Casemapping changed from custom unicode mapping to preliminary [rfc7700](https://github.com/ircv3/ircv3-specifications/pull/272) mapping.

+ 13
- 4
irc/accounts.go View File

@@ -220,8 +220,7 @@ func authPlainHandler(server *Server, client *Client, mechanism string, value []
220 220
 		return false
221 221
 	}
222 222
 
223
-	client.Send(nil, server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, client.account.Name, fmt.Sprintf("You are now logged in as %s", client.account.Name))
224
-	client.Send(nil, server.name, RPL_SASLSUCCESS, client.nick, "SASL authentication successful")
223
+	client.successfulSaslAuth()
225 224
 	return false
226 225
 }
227 226
 
@@ -268,7 +267,17 @@ func authExternalHandler(server *Server, client *Client, mechanism string, value
268 267
 		return false
269 268
 	}
270 269
 
271
-	client.Send(nil, server.name, RPL_LOGGEDIN, client.nick, client.nickMaskString, client.account.Name, fmt.Sprintf("You are now logged in as %s", client.account.Name))
272
-	client.Send(nil, server.name, RPL_SASLSUCCESS, client.nick, "SASL authentication successful")
270
+	client.successfulSaslAuth()
273 271
 	return false
274 272
 }
273
+
274
+// successfulSaslAuth means that a SASL auth attempt completed successfully, and is used to dispatch messages.
275
+func (c *Client) successfulSaslAuth() {
276
+	c.Send(nil, c.server.name, RPL_LOGGEDIN, c.nick, c.nickMaskString, c.account.Name, fmt.Sprintf("You are now logged in as %s", c.account.Name))
277
+	c.Send(nil, c.server.name, RPL_SASLSUCCESS, c.nick, "SASL authentication successful")
278
+
279
+	// dispatch account-notify
280
+	for friend := range c.Friends(AccountNotify) {
281
+		friend.Send(nil, c.nickMaskString, "ACCOUNT", c.account.Name)
282
+	}
283
+}

+ 2
- 0
irc/capability.go View File

@@ -15,6 +15,7 @@ type Capability string
15 15
 
16 16
 const (
17 17
 	AccountTag      Capability = "account-tag"
18
+	AccountNotify   Capability = "account-notify"
18 19
 	AwayNotify      Capability = "away-notify"
19 20
 	ExtendedJoin    Capability = "extended-join"
20 21
 	MultiPrefix     Capability = "multi-prefix"
@@ -26,6 +27,7 @@ const (
26 27
 var (
27 28
 	SupportedCapabilities = CapabilitySet{
28 29
 		AccountTag:      true,
30
+		AccountNotify:   true,
29 31
 		AwayNotify:      true,
30 32
 		ExtendedJoin:    true,
31 33
 		MultiPrefix:     true,

Loading…
Cancel
Save