Add gitea spam user cleaning script

This commit is contained in:
2025-01-24 22:38:58 +01:00
parent c8b05eedfc
commit 3c430bca64
7 changed files with 274 additions and 1 deletions

View File

@ -0,0 +1,24 @@
module TeaCleaner.Options
( jsonOptions
) where
import qualified Data.Aeson.TH as Aeson
import Prelude hiding (id)
import Data.Char
applyFirst :: (Char -> Char) -> String -> String
applyFirst _ [] = []
applyFirst f [x] = [f x]
applyFirst f (x:xs) = f x: xs
-- | Generic casing for symbol separated names
symbCase :: String -> String
symbCase = u . applyFirst toLower
where u [] = []
u (x:xs) | isUpper x = '_' : toLower x : u xs
| otherwise = x : u xs
jsonOptions :: Aeson.Options
jsonOptions = Aeson.defaultOptions
{ Aeson.fieldLabelModifier = symbCase
}