aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-10-15 16:24:21 +0200
committermetamuffin <metamuffin@disroot.org>2023-10-15 16:24:21 +0200
commit95149c9f252b4ee678b4d7b766c9c4830b548d07 (patch)
tree1802f90e946cec9d67b99ebba9eb0b419249b95f
parentc2f56de490704e3fd6e5d2633e03dab20cce33ff (diff)
downloadfastbangs-95149c9f252b4ee678b4d7b766c9c4830b548d07.tar
fastbangs-95149c9f252b4ee678b4d7b766c9c4830b548d07.tar.bz2
fastbangs-95149c9f252b4ee678b4d7b766c9c4830b548d07.tar.zst
apply some linter suggestions
-rw-r--r--src/Auth.hs2
-rw-r--r--src/BangState.hs4
-rw-r--r--src/Config.hs16
-rw-r--r--src/Data/Bang.hs2
4 files changed, 12 insertions, 12 deletions
diff --git a/src/Auth.hs b/src/Auth.hs
index 98b4932..b29b163 100644
--- a/src/Auth.hs
+++ b/src/Auth.hs
@@ -16,4 +16,4 @@ ensureAuth :: MonadHandler m => Config -> m ()
ensureAuth cfg = lookupBasicAuth >>= \case
Nothing -> notAuthenticated
Just (user, pw) -> unless (hashSha512 pw == encodeUtf8 (confPwHash cfg) && user == confUser cfg) $ permissionDenied "Wrong username/password"
- where hashSha512 pw = convertToBase Base64 $ (hash $ encodeUtf8 pw :: Digest SHA512)
+ where hashSha512 pw = convertToBase Base64 (hash $ encodeUtf8 pw :: Digest SHA512)
diff --git a/src/BangState.hs b/src/BangState.hs
index 1b76649..b728789 100644
--- a/src/BangState.hs
+++ b/src/BangState.hs
@@ -41,11 +41,11 @@ reserialize s = do
ddg <- readTVar $ ddgBangs s
let jsonBs = encode $ own <> ddg -- left biased union
- writeTVar (serializedBangs s) $ toStrict $ jsonBs
+ writeTVar (serializedBangs s) $ toStrict jsonBs
writeTVar (brotliBangs s) $ toStrict $ compress jsonBs
-- hash: for now, base64 of the first 120 bits of the SHA512 of the bangs
writeTVar (serializedHash s) $ decodeASCII $ Data.ByteString.take 20
- $ convertToBase Base64 $ (hashlazy jsonBs :: Digest SHA512)
+ $ convertToBase Base64 (hashlazy jsonBs :: Digest SHA512)
writeTQueue (syncFileNotifications s) ()
-- spawns a thread for syncing the current state to disk. do *NOT* use forkIO on this
diff --git a/src/Config.hs b/src/Config.hs
index 12fc09d..137d42d 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -43,14 +43,14 @@ getConfig = do
Config
<$> (read <$> resolveVal (lookup "port" confFile) "PORT" "20546")
- <*> resolveVal (lookup "bind-addr" confFile) "BIND_ADDR" "*6"
- <*> resolveVal (lookup "base-url" confFile) "BASE_URL" "http://localhost:20546"
- <*> resolveVal (lookup "favicon-url" confFile) "FAVICON_URL" ""
- <*> resolveVal (lookup "db-path" confFile) "DB_PATH" "banger.db"
- <*> resolveVal (lookup "admin-user" confFile) "ADMIN_USER" "bleb"
- <*> resolveVal (lookup "admin-pw-hash" confFile) "ADMIN_PW_HASH" "" -- prevent login without manual pw
- <*> fmap (<|> lookup "email-command" confFile) (lookupEnv "EMAIL_CMD")
- <*> resolveVal (lookup "admin-email" confFile) "ADMIN_EMAIL" ""
+ <*> resolveVal (lookup "bind-addr" confFile) "BIND_ADDR" "*6"
+ <*> resolveVal (lookup "base-url" confFile) "BASE_URL" "http://localhost:20546"
+ <*> resolveVal (lookup "favicon-url" confFile) "FAVICON_URL" ""
+ <*> resolveVal (lookup "db-path" confFile) "DB_PATH" "banger.db"
+ <*> resolveVal (lookup "admin-user" confFile) "ADMIN_USER" "bleb"
+ <*> resolveVal (lookup "admin-pw-hash" confFile) "ADMIN_PW_HASH" "" -- prevent login without manual pw
+ <*> fmap (<|> lookup "email-command" confFile) (lookupEnv "EMAIL_CMD")
+ <*> resolveVal (lookup "admin-email" confFile) "ADMIN_EMAIL" ""
where resolveVal :: IsString s => Maybe String -> String -> String -> IO s
resolveVal mayConf q def = do
diff --git a/src/Data/Bang.hs b/src/Data/Bang.hs
index 42a5d06..5788bbe 100644
--- a/src/Data/Bang.hs
+++ b/src/Data/Bang.hs
@@ -22,7 +22,7 @@ singletonBangs :: Text -> Text -> Text -> Bangs
singletonBangs bn bu bdp = Bangs $ M.singleton bn (bu, bdp)
instance FromJSON Bangs where
- parseJSON b = parseJSON b >>= fmap Bangs . sequence . fmap getInfo
+ parseJSON b = parseJSON b >>= fmap Bangs . mapM getInfo
where getInfo v = (,) <$> v .: "url" <*> v .: "name"
instance ToJSON Bangs where