dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit 51495d4187f24967b2367592366ca9dc86b791fe
parent 4102d7d4abb64435b0a315a830e327ce99c219f6
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Tue, 30 May 2023 03:46:55 -0700

toggle pow

Diffstat:
Acmd/dkf/migrations/133.sql | 4++++
Mpkg/actions/actions.go | 1+
Mpkg/database/tableSettings.go | 1+
Mpkg/web/handlers/admin.go | 3+++
Mpkg/web/handlers/data.go | 1+
Mpkg/web/public/views/pages/admin/settings.gohtml | 7+++++++
6 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/cmd/dkf/migrations/133.sql b/cmd/dkf/migrations/133.sql @@ -0,0 +1,4 @@ +-- +migrate Up +ALTER TABLE settings ADD COLUMN pow_enabled TINYINT(1) NOT NULL DEFAULT 0; + +-- +migrate Down diff --git a/pkg/actions/actions.go b/pkg/actions/actions.go @@ -72,6 +72,7 @@ func Start(c *cli.Context) error { config.ForumEnabled.Store(settings.ForumEnabled) config.SilentSelfKick.Store(settings.SilentSelfKick) config.MaybeAuthEnabled.Store(settings.MaybeAuthEnabled) + config.PowEnabled.Store(settings.PowEnabled) config.CaptchaDifficulty.Store(settings.CaptchaDifficulty) config.Xmr() diff --git a/pkg/database/tableSettings.go b/pkg/database/tableSettings.go @@ -15,6 +15,7 @@ type Settings struct { ForceLoginCaptcha bool // either or not people are forced to complete captcha at login DownloadsEnabled bool // either or not people can download files CaptchaDifficulty int64 // captcha difficulty + PowEnabled bool } // GetSettings get the saved settings from the DB diff --git a/pkg/web/handlers/admin.go b/pkg/web/handlers/admin.go @@ -219,6 +219,7 @@ func AdminSettingsHandler(c echo.Context) error { data.ForumEnabled = settings.ForumEnabled data.MaybeAuthEnabled = settings.MaybeAuthEnabled data.CaptchaDifficulty = settings.CaptchaDifficulty + data.PowEnabled = settings.PowEnabled if c.Request().Method == http.MethodPost { formName := c.Request().PostFormValue("formName") @@ -239,12 +240,14 @@ func AdminSettingsHandler(c echo.Context) error { settings.ForumEnabled = utils.DoParseBool(c.Request().PostFormValue("forumEnabled")) settings.MaybeAuthEnabled = utils.DoParseBool(c.Request().PostFormValue("maybeAuthEnabled")) settings.CaptchaDifficulty = utils.DoParseInt64(c.Request().PostFormValue("captchaDifficulty")) + settings.PowEnabled = utils.DoParseBool(c.Request().PostFormValue("powEnabled")) settings.DoSave(db) config.ProtectHome.Store(settings.ProtectHome) config.HomeUsersList.Store(settings.HomeUsersList) config.ForceLoginCaptcha.Store(settings.ForceLoginCaptcha) config.SignupEnabled.Store(settings.SignupEnabled) config.CaptchaDifficulty.Store(settings.CaptchaDifficulty) + config.PowEnabled.Store(settings.PowEnabled) config.SignupFakeEnabled.Store(settings.SignupFakeEnabled) config.DownloadsEnabled.Store(settings.DownloadsEnabled) config.ForumEnabled.Store(settings.ForumEnabled) diff --git a/pkg/web/handlers/data.go b/pkg/web/handlers/data.go @@ -547,6 +547,7 @@ type adminSettingsData struct { DownloadsEnabled bool ForumEnabled bool MaybeAuthEnabled bool + PowEnabled bool CaptchaDifficulty int64 } diff --git a/pkg/web/public/views/pages/admin/settings.gohtml b/pkg/web/public/views/pages/admin/settings.gohtml @@ -80,6 +80,13 @@ </div> <label class="form-check-label" for="maybeAuthEnabled">Maybe auth enabled</label> </div> + <div class="form-check form-check-1"> + <div class="checkbox-wrapper form-check-input"> + <input class="my-cbx" type="checkbox" name="powEnabled" id="powEnabled" value="1"{{ if .Data.PowEnabled }} checked{{ end }} /> + <label for="powEnabled" class="toggle"><span></span></label> + </div> + <label class="form-check-label" for="powEnabled">Proof of work enabled</label> + </div> <div> <label class="form-check-label" for="captchaDifficulty">Captcha difficulty</label> <select name="captchaDifficulty" id="captchaDifficulty">