aboutsummaryrefslogtreecommitdiff
path: root/service
diff options
context:
space:
mode:
authorr <r@freesoftwareextremist.com>2021-04-03 09:22:43 +0000
committerr <r@freesoftwareextremist.com>2021-04-03 09:24:39 +0000
commit76c5baef6ae8f5520ab40fef48532b6b5759384f (patch)
tree4826c83217ab73d7f7b9964190553027a2ed994a /service
parenta82745175e6e4cbd87c884a7ec7d0408e9a4f3d5 (diff)
downloadbloat-76c5baef6ae8f5520ab40fef48532b6b5759384f.tar.gz
bloat-76c5baef6ae8f5520ab40fef48532b6b5759384f.zip
Add option for user CSS
Diffstat (limited to 'service')
-rw-r--r--service/service.go4
-rw-r--r--service/transport.go2
2 files changed, 6 insertions, 0 deletions
diff --git a/service/service.go b/service/service.go
index a29345e..5d80c28 100644
--- a/service/service.go
+++ b/service/service.go
@@ -64,6 +64,7 @@ func (s *service) authenticate(c *client, sid string, csrf string, ref string, t
CSRFToken: c.s.CSRFToken,
UserID: c.s.UserID,
AntiDopamineMode: sett.AntiDopamineMode,
+ UserCSS: sett.CSS,
Referrer: ref,
}
}()
@@ -888,6 +889,9 @@ func (s *service) SaveSettings(c *client, settings *model.Settings) (err error)
default:
return errInvalidArgument
}
+ if len(settings.CSS) > 1<<20 {
+ return errInvalidArgument
+ }
sess, err := s.sessionRepo.Get(c.s.ID)
if err != nil {
return
diff --git a/service/transport.go b/service/transport.go
index 50bf9be..f448cc3 100644
--- a/service/transport.go
+++ b/service/transport.go
@@ -463,6 +463,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
fluorideMode := c.r.FormValue("fluoride_mode") == "true"
darkMode := c.r.FormValue("dark_mode") == "true"
antiDopamineMode := c.r.FormValue("anti_dopamine_mode") == "true"
+ css := c.r.FormValue("css")
settings := &model.Settings{
DefaultVisibility: visibility,
@@ -475,6 +476,7 @@ func NewHandler(s *service, logger *log.Logger, staticDir string) http.Handler {
FluorideMode: fluorideMode,
DarkMode: darkMode,
AntiDopamineMode: antiDopamineMode,
+ CSS: css,
}
err := s.SaveSettings(c, settings)