diff --git a/internal/db/dbrepo/actionrepo/actions.go b/internal/db/dbrepo/actionrepo/actions.go index 28a24cde79c7f4ba7f9e392e2bd60817f37b5bf1..27ac51f4943a923a80c0eb7d99f079ba869cfcd5 100644 --- a/internal/db/dbrepo/actionrepo/actions.go +++ b/internal/db/dbrepo/actionrepo/actions.go @@ -86,3 +86,14 @@ func AddRemoveFromCalendarCode( ) return } + +// UseRemoveCalendarCode uses a calendar remove ActionCode to remove a token from a calendar and then deletes the +// code from the database +func UseRemoveCalendarCode(rlog log.Ext1FieldLogger, tx *sqlx.Tx, code string) error { + return db.RunWithinTransaction( + rlog, tx, func(tx *sqlx.Tx) error { + _, err := tx.Exec(`CALL ActionCodes_UseRemoveFromCalendar(?)`, code) + return errors.WithStack(err) + }, + ) +} diff --git a/internal/endpoints/actions/actions.go b/internal/endpoints/actions/actions.go index b9663d61721cf37914e92466db6ade2a53dfed1a..d91025b16f023295ad0959abbe6d7b3679e36480 100644 --- a/internal/endpoints/actions/actions.go +++ b/internal/endpoints/actions/actions.go @@ -23,8 +23,6 @@ func HandleActions(ctx *fiber.Ctx) error { switch actionInfo.Action { case pkg.ActionRecreate: return handleRecreate(ctx, actionInfo.Code) - case pkg.ActionManageNotification: - return handleManageNotification(ctx, actionInfo.Code) case pkg.ActionVerifyEmail: return handleVerifyEmail(ctx, actionInfo.Code) case pkg.ActionRemoveFromCalendar: @@ -53,11 +51,15 @@ func handleVerifyEmail(ctx *fiber.Ctx, code string) error { ) } -func handleManageNotification(ctx *fiber.Ctx, code string) error { - return ctxutils.RenderErrorPage(ctx, fiber.StatusNotImplemented, api.ErrorNYI.CombinedMessage()) -} func handleRemoveFromCalendar(ctx *fiber.Ctx, code string) error { - return ctxutils.RenderErrorPage(ctx, fiber.StatusNotImplemented, api.ErrorNYI.CombinedMessage()) + rlog := logger.GetRequestLogger(ctx) + err := actionrepo.UseRemoveCalendarCode(rlog, nil, code) + if err != nil { + return ctxutils.RenderInternalServerErrorPage(ctx, err) + } + return ctxutils.RenderErrorPage( + ctx, http.StatusOK, "The token was successfully removed from the calendar.", "Token Removed from Calendar", + ) } // CreateVerifyEmail creates an action url for verifying a mail address diff --git a/internal/endpoints/actions/pkg/actions.go b/internal/endpoints/actions/pkg/actions.go index a135a4856c5e1bd28a0c3092269d3b8b7dcd8bc6..3af2487742b097bd7af6decbbccc6cbe356bdc45 100644 --- a/internal/endpoints/actions/pkg/actions.go +++ b/internal/endpoints/actions/pkg/actions.go @@ -9,13 +9,11 @@ import ( const ( ActionRecreate = "recreate_token" ActionVerifyEmail = "verify_email" - ActionManageNotification = "manage_notification" ActionRemoveFromCalendar = "remove_from_calendar" ) // CodeLifetimes holds the default lifetime of the different action codes var CodeLifetimes = map[string]int{ - ActionManageNotification: 0, ActionVerifyEmail: 3600, ActionRecreate: 0, ActionRemoveFromCalendar: 0, diff --git a/internal/server/web/partials/scripts.mustache b/internal/server/web/partials/scripts.mustache index d56122b457c8be6e87a96eec34902c2986d295e0..8b5757f9612b1f4269ce8707e2254656d96707a0 100644 --- a/internal/server/web/partials/scripts.mustache +++ b/internal/server/web/partials/scripts.mustache @@ -34,7 +34,7 @@ <script src="{{instance-url}}/static/js/create-mt.js"></script> <script src="{{instance-url}}/static/js/capabilities.js"></script> <script src="{{instance-url}}/static/js/notifications.js"></script> - <!-- <script src="{{instance-url}}/static/js/settings-notifications.js"></script>--> + <script src="{{instance-url}}/static/js/settings-notifications.js"></script> {{/home}} {{#settings}} <script src="{{instance-url}}/static/js/tokeninfo.js"></script>