2019-08-29 05:08:32 +00:00
|
|
|
package animelist
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/aerogo/aero"
|
2019-11-17 07:59:34 +00:00
|
|
|
"github.com/animenotifier/notify.moe/arn"
|
2019-08-29 05:08:32 +00:00
|
|
|
"github.com/animenotifier/notify.moe/components"
|
|
|
|
)
|
|
|
|
|
|
|
|
// DeleteConfirmation shows the confirmation page before deleting an anime list.
|
|
|
|
func DeleteConfirmation(ctx aero.Context) error {
|
2019-11-17 07:59:34 +00:00
|
|
|
user := arn.GetUserFromContext(ctx)
|
2019-08-29 05:08:32 +00:00
|
|
|
|
|
|
|
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 {
|
2019-11-17 07:59:34 +00:00
|
|
|
user := arn.GetUserFromContext(ctx)
|
2019-08-29 05:08:32 +00:00
|
|
|
|
|
|
|
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")
|
|
|
|
}
|