Add QR code, Add MODT customisation

This commit is contained in:
2026-04-09 01:00:02 +02:00
parent e2f1bbcd64
commit 0ce248b2f9
8 changed files with 247 additions and 189 deletions

View File

@@ -3,6 +3,8 @@ package config
import "strconv"
const (
KeyModtext = "modt"
KeyUploadMaxFileSizeBytes = "upload.max_file_size_bytes"
KeyUploadMultiMaxFiles = "upload.multi.max_files"
KeyUploadMaxHours = "upload.max_hours"
@@ -18,6 +20,8 @@ const (
// Defaults (used when DB does not have an override)
const (
DefaultModt = "A_SERVICE_BY_BRAMMIE15"
DefaultUploadMaxFileSizeBytes int64 = 10 << 30 // 10 GiB (matches MaxMultipartMemory intent)
DefaultUploadMultiMaxFiles = 50
DefaultUploadMaxHours = 24 * 7 // 7 days
@@ -36,6 +40,8 @@ const (
// Code duplication be dammed
func DefaultKeyValues() map[string]string {
return map[string]string{
KeyModtext: DefaultModt,
KeyUploadMaxFileSizeBytes: strconv.FormatInt(DefaultUploadMaxFileSizeBytes, 10),
KeyUploadMultiMaxFiles: strconv.Itoa(DefaultUploadMultiMaxFiles),
KeyUploadMaxHours: strconv.Itoa(DefaultUploadMaxHours),

View File

@@ -12,6 +12,8 @@ type ConfigPageData struct {
Success bool
Error string
MODT string
UploadMaxFileSizeMB int64
UploadMultiMaxFiles int
UploadMaxHours int
@@ -33,6 +35,7 @@ func (h *Handler) ConfigPage(c *gin.Context) {
maxBytes := cfg.GetInt64Default(config.KeyUploadMaxFileSizeBytes, config.DefaultUploadMaxFileSizeBytes)
data := ConfigPageData{
Success: c.Query("saved") == "1",
MODT: cfg.GetStringDefault(config.KeyModtext, config.DefaultModt),
UploadMaxFileSizeMB: maxBytes / (1024 * 1024),
UploadMultiMaxFiles: cfg.GetIntDefault(config.KeyUploadMultiMaxFiles, config.DefaultUploadMultiMaxFiles),
UploadMaxHours: cfg.GetIntDefault(config.KeyUploadMaxHours, config.DefaultUploadMaxHours),
@@ -82,6 +85,12 @@ func (h *Handler) ConfigSave(c *gin.Context) {
return n, nil
}
newMODT, err := strconv.Unquote(`"` + c.PostForm("site_modt") + `"`)
if err != nil {
h.renderConfigError(c, "invalid modtext")
return
}
maxMB, err := parseInt64("upload_max_file_size_mb", 1, 1024*1024)
if err != nil {
h.renderConfigError(c, "invalid max file size")
@@ -142,6 +151,8 @@ func (h *Handler) ConfigSave(c *gin.Context) {
return
}
_ = cfg.SetString(config.KeyModtext, newMODT)
_ = cfg.SetString(config.KeyRateLimitLoginPerMinute, strconv.Itoa(loginPerMin))
_ = cfg.SetString(config.KeyRateLimitLoginBurst, strconv.Itoa(loginBurst))
_ = cfg.SetString(config.KeyRateLimitApiPerMinute, strconv.Itoa(apiPerMin))

View File

@@ -2,6 +2,7 @@ package web
import (
"ResendIt/internal/buildinfo"
"ResendIt/internal/config"
"ResendIt/internal/file"
"os"
"strconv"
@@ -33,6 +34,7 @@ func NewHandler(fileService *file.Service, cfg ConfigService) *Handler {
func (h *Handler) Index(c *gin.Context) {
c.HTML(200, "index.html", gin.H{
"title": "Home",
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
})
}
@@ -50,7 +52,9 @@ func (h *Handler) FileView(c *gin.Context) {
fileRecord, err := h.fileService.GetFileByViewID(id)
if err != nil {
c.HTML(404, "error.html", nil)
c.HTML(404, "error.html", gin.H{
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
})
return
}
@@ -58,6 +62,7 @@ func (h *Handler) FileView(c *gin.Context) {
deleteKey := fileRecord.DeletionID
c.HTML(200, "complete.html", gin.H{
"MODT": h.configService.GetStringDefault(config.KeyModtext, config.DefaultModt),
"Filename": fileRecord.Filename,
"DownloadID": downloadKey,
"DeleteID": deleteKey,