Changeset 568 in code for trunk/downstream.go


Ignore:
Timestamp:
Jun 25, 2021, 6:33:13 PM (4 years ago)
Author:
contact
Message:

Add per-user realname setting

This allows users to set a default realname used if the per-network
realname isn't set.

A new "user update" command is introduced and can be extended to edit
other user properties and other users in the future.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/downstream.go

    r565 r568  
    8484                attrs["username"] = irc.TagValue(network.Username)
    8585        }
    86         if network.Realname != "" {
    87                 attrs["realname"] = irc.TagValue(network.Realname)
     86        if realname := GetRealname(&network.user.User, &network.Network); realname != "" {
     87                attrs["realname"] = irc.TagValue(realname)
    8888        }
    8989
     
    13881388                }
    13891389
     1390                // If the client just resets to the default, just wipe the per-network
     1391                // preference
     1392                storeRealname := realname
     1393                if realname == dc.user.Realname {
     1394                        storeRealname = ""
     1395                }
     1396
    13901397                var storeErr error
    13911398                var needUpdate []Network
     
    13991406                                })
    14001407
    1401                                 n.Realname = realname
     1408                                n.Realname = storeRealname
    14021409                                if err := dc.srv.db.StoreNetwork(dc.user.ID, &n.Network); err != nil {
    14031410                                        dc.logger.Printf("failed to store network realname: %v", err)
     
    14081415
    14091416                        record := n.Network // copy network record because we'll mutate it
    1410                         record.Realname = realname
     1417                        record.Realname = storeRealname
    14111418                        needUpdate = append(needUpdate, record)
    14121419                })
     
    22242231                        pass, _ := attrs.GetTag("pass")
    22252232
     2233                        if realname == dc.user.Realname {
     2234                                realname = ""
     2235                        }
     2236
    22262237                        // TODO: reject unknown attributes
    22272238
Note: See TracChangeset for help on using the changeset viewer.