Changeset 652 in code for trunk/user.go


Ignore:
Timestamp:
Oct 18, 2021, 5:15:15 PM (4 years ago)
Author:
contact
Message:

Add context args to Database interface

This is a mecanical change, which just lifts up the context.TODO()
calls from inside the DB implementations to the callers.

Future work involves properly wiring up the contexts when it makes
sense.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/user.go

    r644 r652  
    22
    33import (
     4        "context"
    45        "crypto/sha256"
    56        "encoding/binary"
     
    331332        }
    332333
    333         if err := net.user.srv.db.DeleteChannel(ch.ID); err != nil {
     334        if err := net.user.srv.db.DeleteChannel(context.TODO(), ch.ID); err != nil {
    334335                return err
    335336        }
     
    368369        })
    369370
    370         if err := net.user.srv.db.StoreClientDeliveryReceipts(net.ID, clientName, receipts); err != nil {
     371        if err := net.user.srv.db.StoreClientDeliveryReceipts(context.TODO(), net.ID, clientName, receipts); err != nil {
    371372                net.logger.Printf("failed to store delivery receipts for client %q: %v", clientName, err)
    372373        }
     
    488489        }()
    489490
    490         networks, err := u.srv.db.ListNetworks(u.ID)
     491        networks, err := u.srv.db.ListNetworks(context.TODO(), u.ID)
    491492        if err != nil {
    492493                u.logger.Printf("failed to list networks for user %q: %v", u.Username, err)
     
    496497        for _, record := range networks {
    497498                record := record
    498                 channels, err := u.srv.db.ListChannels(record.ID)
     499                channels, err := u.srv.db.ListChannels(context.TODO(), record.ID)
    499500                if err != nil {
    500501                        u.logger.Printf("failed to list channels for user %q, network %q: %v", u.Username, record.GetName(), err)
     
    506507
    507508                if u.hasPersistentMsgStore() {
    508                         receipts, err := u.srv.db.ListDeliveryReceipts(record.ID)
     509                        receipts, err := u.srv.db.ListDeliveryReceipts(context.TODO(), record.ID)
    509510                        if err != nil {
    510511                                u.logger.Printf("failed to load delivery receipts for user %q, network %q: %v", u.Username, network.GetName(), err)
     
    591592                        }
    592593                        uc.network.detach(c)
    593                         if err := uc.srv.db.StoreChannel(uc.network.ID, c); err != nil {
     594                        if err := uc.srv.db.StoreChannel(context.TODO(), uc.network.ID, c); err != nil {
    594595                                u.logger.Printf("failed to store updated detached channel %q: %v", c.Name, err)
    595596                        }
     
    780781
    781782        network := newNetwork(u, record, nil)
    782         err := u.srv.db.StoreNetwork(u.ID, &network.Network)
     783        err := u.srv.db.StoreNetwork(context.TODO(), u.ID, &network.Network)
    783784        if err != nil {
    784785                return nil, err
     
    822823        }
    823824
    824         if err := u.srv.db.StoreNetwork(u.ID, record); err != nil {
     825        if err := u.srv.db.StoreNetwork(context.TODO(), u.ID, record); err != nil {
    825826                return nil, err
    826827        }
     
    889890        }
    890891
    891         if err := u.srv.db.DeleteNetwork(network.ID); err != nil {
     892        if err := u.srv.db.DeleteNetwork(context.TODO(), network.ID); err != nil {
    892893                return err
    893894        }
     
    915916
    916917        realnameUpdated := u.Realname != record.Realname
    917         if err := u.srv.db.StoreUser(record); err != nil {
     918        if err := u.srv.db.StoreUser(context.TODO(), record); err != nil {
    918919                return fmt.Errorf("failed to update user %q: %v", u.Username, err)
    919920        }
Note: See TracChangeset for help on using the changeset viewer.