Changeset 722 in code for trunk


Ignore:
Timestamp:
Nov 19, 2021, 6:21:48 PM (4 years ago)
Author:
contact
Message:

Use RPL_LOGGEDIN/OUT to mirror upstream status

This will allow clients to properly show/hide UI to login and
register.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r721 r722  
    259259        realname        string
    260260        hostname        string
     261        account         string   // RPL_LOGGEDIN/OUT state
    261262        password        string   // empty after authentication
    262263        network         *network // can be nil
     
    760761                } else if done {
    761762                        dc.saslServer = nil
    762                         dc.SendMessage(&irc.Message{
    763                                 Prefix:  dc.srv.prefix(),
    764                                 Command: irc.RPL_LOGGEDIN,
    765                                 Params:  []string{dc.nick, dc.prefix().String(), dc.user.Username, "You are now logged in"},
    766                         })
     763                        // Technically we should send RPL_LOGGEDIN here. However we use
     764                        // RPL_LOGGEDIN to mirror the upstream connection status. Let's see
     765                        // how many clients that breaks. See:
     766                        // https://github.com/ircv3/ircv3-specifications/pull/476
    767767                        dc.SendMessage(&irc.Message{
    768768                                Prefix:  dc.srv.prefix(),
     
    10361036                dc.realname = uc.realname
    10371037        }
     1038}
     1039
     1040func (dc *downstreamConn) updateAccount() {
     1041        uc := dc.upstream()
     1042        if uc == nil || uc.account == dc.account || !dc.caps["sasl"] {
     1043                return
     1044        }
     1045
     1046        if uc.account != "" {
     1047                dc.SendMessage(&irc.Message{
     1048                        Prefix:  dc.srv.prefix(),
     1049                        Command: irc.RPL_LOGGEDIN,
     1050                        Params:  []string{dc.nick, dc.prefix().String(), uc.account, "You are logged in as " + uc.account},
     1051                })
     1052        } else {
     1053                dc.SendMessage(&irc.Message{
     1054                        Prefix:  dc.srv.prefix(),
     1055                        Command: irc.RPL_LOGGEDOUT,
     1056                        Params:  []string{dc.nick, dc.prefix().String(), "You are logged out"},
     1057                })
     1058        }
     1059
     1060        dc.account = uc.account
    10381061}
    10391062
     
    12611284        dc.updateNick()
    12621285        dc.updateRealname()
     1286        dc.updateAccount()
    12631287
    12641288        if motd := dc.user.srv.Config().MOTD; motd != "" && dc.network == nil {
  • trunk/upstream.go

    r720 r722  
    587587                }
    588588                uc.logger.Printf("logged in with account %q", uc.account)
     589                uc.forEachDownstream(func(dc *downstreamConn) {
     590                        dc.updateAccount()
     591                })
    589592        case irc.RPL_LOGGEDOUT:
    590593                uc.account = ""
    591594                uc.logger.Printf("logged out")
     595                uc.forEachDownstream(func(dc *downstreamConn) {
     596                        dc.updateAccount()
     597                })
    592598        case irc.ERR_NICKLOCKED, irc.RPL_SASLSUCCESS, irc.ERR_SASLFAIL, irc.ERR_SASLTOOLONG, irc.ERR_SASLABORTED:
    593599                var info string
  • trunk/user.go

    r710 r722  
    542542                                dc.updateNick()
    543543                                dc.updateRealname()
     544                                dc.updateAccount()
    544545                        })
    545546                        u.forEachDownstream(func(dc *downstreamConn) {
Note: See TracChangeset for help on using the changeset viewer.