diff --git a/calendar/util.go b/calendar/util.go index e853866..11f7a78 100644 --- a/calendar/util.go +++ b/calendar/util.go @@ -35,17 +35,15 @@ func HasEventAccess(c *gin.Context, e *Event, cid string) error { return nil } -func ChangeCalGroup(cal_id, to string) error { - return db.Transaction(func(tx *gorm.DB) error { - affected := tx.Exec(`update calendars set group_id = ( - select id from groups where name = ? - ) where id = ?`, to, cal_id).RowsAffected - if affected == 0 { - return errors.ErrorNotFound - } - tx.Exec(`update events set group_id = ( - select id from groups where name = ? - ) where calendar_id = ?`, to, cal_id) - return nil - }) +func ChangeCalGroup(tx *gorm.DB, cal_id, to string) error { + affected := tx.Exec(`update calendars set group_id = ( + select id from groups where name = ? + ) where id = ?`, to, cal_id).RowsAffected + if affected == 0 { + return errors.ErrorNotFound + } + tx.Exec(`update events set group_id = ( + select id from groups where name = ? + ) where calendar_id = ?`, to, cal_id) + return nil }