Make DB.DeleteChannel take the channel ID

... to allow the caller to correctly do any necessary casemapping.
This commit is contained in:
Hubert Hirtz 2020-09-06 17:00:42 +02:00 committed by Simon Ser
parent 42828d68e9
commit 7310f67fc7
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 7 additions and 3 deletions

4
db.go
View File

@ -461,10 +461,10 @@ func (db *DB) StoreChannel(networkID int64, ch *Channel) error {
return err
}
func (db *DB) DeleteChannel(networkID int64, name string) error {
func (db *DB) DeleteChannel(id int64) error {
db.lock.Lock()
defer db.lock.Unlock()
_, err := db.db.Exec("DELETE FROM Channel WHERE network = ? AND name = ?", networkID, name)
_, err := db.db.Exec("DELETE FROM Channel WHERE id = ?", id)
return err
}

View File

@ -229,7 +229,11 @@ func (net *network) createUpdateChannel(ch *Channel) error {
}
func (net *network) deleteChannel(name string) error {
if err := net.user.srv.db.DeleteChannel(net.ID, name); err != nil {
ch, ok := net.channels[name]
if !ok {
return fmt.Errorf("unknown channel %q", name)
}
if err := net.user.srv.db.DeleteChannel(ch.ID); err != nil {
return err
}
delete(net.channels, name)