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,9 +42,12 @@ func RemoveCard(w http.ResponseWriter, r *http.Request) {
// save and update contact revision
err = store.DB.Transaction(func(tx *gorm.DB) error {
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
}
if res := tx.Model(&channel.ChannelSlot).Update("revision", account.ChannelRevision+1).Error; res != nil {
return res
}