mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 14:09:52 +01:00
Clear appointments on anime delete
This commit is contained in:
15
nuss.go
15
nuss.go
@@ -257,6 +257,21 @@ func DeleteUserFromAppointment(username string, animeId int64, meeting time.Time
|
||||
}
|
||||
|
||||
func DeleteAnime(tx *nutsdb.Tx, keyBytes []byte) error {
|
||||
// clear appointments
|
||||
appoints, err := tx.GetAll(bucketAppoint)
|
||||
if err == nil {
|
||||
animeId, err := BytesToInt64(keyBytes)
|
||||
if err == nil {
|
||||
for _, e := range appoints {
|
||||
// decode appointment list
|
||||
dbAnimeId, _, err := BytesToInt64AndDate(e.Key)
|
||||
if err == nil && dbAnimeId == animeId {
|
||||
tx.Delete(bucketAppoint, e.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tx.Delete(bucketChat, keyBytes)
|
||||
return tx.Delete(bucketAnime, keyBytes)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user