mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-08 17:07:36 +01:00
add METADATA response when MONITOR triggered
This commit is contained in:
parent
0119bbc36f
commit
f91d1d94f6
@ -1398,7 +1398,7 @@ func (client *Client) destroy(session *Session) {
|
|||||||
|
|
||||||
// alert monitors
|
// alert monitors
|
||||||
if registered {
|
if registered {
|
||||||
client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false)
|
client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false, nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// clean up channels
|
// clean up channels
|
||||||
|
|||||||
@ -38,7 +38,7 @@ func (manager *MonitorManager) AddMonitors(users utils.HashSet[*Session], cfnick
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AlertAbout alerts everyone monitoring `client`'s nick that `client` is now {on,off}line.
|
// AlertAbout alerts everyone monitoring `client`'s nick that `client` is now {on,off}line.
|
||||||
func (manager *MonitorManager) AlertAbout(nick, cfnick string, online bool) {
|
func (manager *MonitorManager) AlertAbout(nick, cfnick string, online bool, client *Client) {
|
||||||
var watchers []*Session
|
var watchers []*Session
|
||||||
// safely copy the list of clients watching our nick
|
// safely copy the list of clients watching our nick
|
||||||
manager.RLock()
|
manager.RLock()
|
||||||
@ -52,8 +52,21 @@ func (manager *MonitorManager) AlertAbout(nick, cfnick string, online bool) {
|
|||||||
command = RPL_MONONLINE
|
command = RPL_MONONLINE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var metadata map[string]string
|
||||||
|
if online && client != nil {
|
||||||
|
metadata = client.ListMetadata()
|
||||||
|
}
|
||||||
|
|
||||||
for _, session := range watchers {
|
for _, session := range watchers {
|
||||||
session.Send(nil, session.client.server.name, command, session.client.Nick(), nick)
|
session.Send(nil, session.client.server.name, command, session.client.Nick(), nick)
|
||||||
|
|
||||||
|
if metadata != nil && session.capabilities.Has(caps.Metadata) {
|
||||||
|
for key := range session.MetadataSubscriptions() {
|
||||||
|
if val, ok := metadata[key]; ok {
|
||||||
|
session.Send(nil, client.server.name, "METADATA", nick, key, "*", val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -128,9 +128,11 @@ func performNickChange(server *Server, client *Client, target *Client, session *
|
|||||||
}
|
}
|
||||||
|
|
||||||
newCfnick := target.NickCasefolded()
|
newCfnick := target.NickCasefolded()
|
||||||
if newCfnick != details.nickCasefolded {
|
// send MONITOR updates only for nick changes, not for new connection registration;
|
||||||
client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false)
|
// defer MONITOR for new connection registration until pre-registration metadata is applied
|
||||||
client.server.monitorManager.AlertAbout(assignedNickname, newCfnick, true)
|
if hadNick && newCfnick != details.nickCasefolded {
|
||||||
|
client.server.monitorManager.AlertAbout(details.nick, details.nickCasefolded, false, nil)
|
||||||
|
client.server.monitorManager.AlertAbout(assignedNickname, newCfnick, true, target)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@ -430,6 +430,8 @@ func (server *Server) tryRegister(c *Client, session *Session) (exiting bool) {
|
|||||||
|
|
||||||
c.applyPreregMetadata(session)
|
c.applyPreregMetadata(session)
|
||||||
|
|
||||||
|
c.server.monitorManager.AlertAbout(c.Nick(), c.NickCasefolded(), true, c)
|
||||||
|
|
||||||
// this is not a reattach, so if the client is always-on, this is the first time
|
// this is not a reattach, so if the client is always-on, this is the first time
|
||||||
// the Client object was created during the current server uptime. mark dirty in
|
// the Client object was created during the current server uptime. mark dirty in
|
||||||
// order to persist the realname and the user modes:
|
// order to persist the realname and the user modes:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user