Added anime list deletion
This commit is contained in:
36
pages/animelist/delete.go
Normal file
36
pages/animelist/delete.go
Normal file
@ -0,0 +1,36 @@
|
||||
package animelist
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// DeleteConfirmation shows the confirmation page before deleting an anime list.
|
||||
func DeleteConfirmation(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.DeleteAnimeList(user))
|
||||
}
|
||||
|
||||
// Delete deletes your entire anime list.
|
||||
func Delete(ctx aero.Context) error {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in")
|
||||
}
|
||||
|
||||
animeList := user.AnimeList()
|
||||
animeList.Lock()
|
||||
animeList.Items = nil
|
||||
animeList.Unlock()
|
||||
|
||||
return ctx.String("ok")
|
||||
}
|
Reference in New Issue
Block a user