Changeset 421 in code for trunk/service.go


Ignore:
Timestamp:
Oct 24, 2020, 1:14:23 PM (5 years ago)
Author:
contact
Message:

Switch DB API to user IDs

This commit changes the Network schema to use user IDs instead of
usernames. While at it, a new UNIQUE(user, name) constraint ensures
there is no conflict with custom network names.

Closes: https://todo.sr.ht/~emersion/soju/86
References: https://todo.sr.ht/~emersion/soju/29

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/service.go

    r379 r421  
    549549        net.SASL.Mechanism = "EXTERNAL"
    550550
    551         if err := dc.srv.db.StoreNetwork(net.Username, &net.Network); err != nil {
     551        if err := dc.srv.db.StoreNetwork(dc.user.ID, &net.Network); err != nil {
    552552                return err
    553553        }
     
    594594        net.SASL.Mechanism = "PLAIN"
    595595
    596         if err := dc.srv.db.StoreNetwork(net.Username, &net.Network); err != nil {
     596        if err := dc.srv.db.StoreNetwork(dc.user.ID, &net.Network); err != nil {
    597597                return err
    598598        }
     
    618618        net.SASL.Mechanism = ""
    619619
    620         if err := dc.srv.db.StoreNetwork(dc.user.Username, &net.Network); err != nil {
     620        if err := dc.srv.db.StoreNetwork(dc.user.ID, &net.Network); err != nil {
    621621                return err
    622622        }
     
    690690        u.stop()
    691691
    692         if err := dc.srv.db.DeleteUser(username); err != nil {
     692        if err := dc.srv.db.DeleteUser(dc.user.ID); err != nil {
    693693                return fmt.Errorf("failed to delete user: %v", err)
    694694        }
Note: See TracChangeset for help on using the changeset viewer.