From 1d832ee1bc83df1f51593ae72123096046627cf1 Mon Sep 17 00:00:00 2001 From: Alex Jaspersen Date: Fri, 4 Jun 2021 16:44:00 -0700 Subject: [PATCH] Show email in NS INFO when user has permission. Users logged into an account can see their own email. Opers with the accreg capability can see all users. --- irc/accounts.go | 4 ++++ irc/nickserv.go | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/irc/accounts.go b/irc/accounts.go index 99e4aeb4..473b21fa 100644 --- a/irc/accounts.go +++ b/irc/accounts.go @@ -1259,6 +1259,9 @@ func (am *AccountManager) deserializeRawAccount(raw rawClientAccount, cfName str return } result.AdditionalNicks = unmarshalReservedNicks(raw.AdditionalNicks) + if strings.HasPrefix(raw.Callback, "mailto:") { + result.Email = strings.TrimPrefix(raw.Callback, "mailto:") + } result.Verified = raw.Verified if raw.VHost != "" { e := json.Unmarshal([]byte(raw.VHost), &result.VHost) @@ -2032,6 +2035,7 @@ type ClientAccount struct { Name string NameCasefolded string RegisteredAt time.Time + Email string Credentials AccountCredentials Verified bool Suspended *AccountSuspension diff --git a/irc/nickserv.go b/irc/nickserv.go index 1c1b606a..0b7f9424 100644 --- a/irc/nickserv.go +++ b/irc/nickserv.go @@ -813,6 +813,13 @@ func nsInfoHandler(service *ircService, server *Server, client *Client, command service.Notice(rb, fmt.Sprintf(client.t("Account: %s"), account.Name)) registeredAt := account.RegisteredAt.Format(time.RFC1123) service.Notice(rb, fmt.Sprintf(client.t("Registered at: %s"), registeredAt)) + + if account.Name == client.AccountName() || client.HasRoleCapabs("accreg") { + if account.Email != "" { + service.Notice(rb, fmt.Sprintf(client.t("Email address: %s"), account.Email)) + } + } + // TODO nicer formatting for this for _, nick := range account.AdditionalNicks { service.Notice(rb, fmt.Sprintf(client.t("Additional grouped nick: %s"), nick))