clearing channel association when deleting contact

This commit is contained in:
Roland Osborne 2022-10-11 13:56:27 -07:00
parent 18716162cc
commit 1b5af314a1

View File

@ -42,7 +42,10 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) {
// save and update contact revision // save and update contact revision
err = store.DB.Transaction(func(tx *gorm.DB) error { err = store.DB.Transaction(func(tx *gorm.DB) error {
for _, channel := range slot.Card.Channels { for _, channel := range slot.Card.Channels {
if res := tx.Model(&channel).Association("Cards").Delete(&slot.Card); res != nil { if res := tx.Model(&channel).Association("Cards").Delete(slot.Card); res != nil {
return res
}
if res := tx.Model(&channel).Update("detail_revision", account.ChannelRevision+1).Error; res != nil {
return res return res
} }
if res := tx.Model(&channel.ChannelSlot).Update("revision", account.ChannelRevision+1).Error; res != nil { if res := tx.Model(&channel.ChannelSlot).Update("revision", account.ChannelRevision+1).Error; res != nil {