summaryrefslogtreecommitdiff
path: root/fig-web/src/Fig/Web/Module
diff options
context:
space:
mode:
authorLLLL Colonq <llll@colonq>2026-02-20 18:41:01 -0500
committerLLLL Colonq <llll@colonq>2026-02-20 18:41:01 -0500
commitb837bfb0f878a84d429a2b4f39bce33fc58274ba (patch)
tree5f91c0be78d509a083b979d30aa1008f7600c0ae /fig-web/src/Fig/Web/Module
parentfb284963700ddf126fa4a1113158c28e0aa60733 (diff)
web: user-id endpoint
Diffstat (limited to 'fig-web/src/Fig/Web/Module')
-rw-r--r--fig-web/src/Fig/Web/Module/User.hs14
1 files changed, 13 insertions, 1 deletions
diff --git a/fig-web/src/Fig/Web/Module/User.hs b/fig-web/src/Fig/Web/Module/User.hs
index 90daa6f..e21afcf 100644
--- a/fig-web/src/Fig/Web/Module/User.hs
+++ b/fig-web/src/Fig/Web/Module/User.hs
@@ -67,9 +67,21 @@ public a = do
status status404
respondText "user not found"
Just val -> respondText $ decodeUtf8 val
+ onGet "/api/user-id/:name" do
+ name <- pathParam "name"
+ getText a.db ("user-id:" <> encodeUtf8 (Text.toLower name)) >>= \case
+ Nothing -> do
+ status status404
+ respondText "username not found"
+ Just val -> respondText val
onGet "/api/user/info/:uid" do -- get everything bundled together
uid <- pathParam "uid"
- respondJSON =<< getUserInfo a.db uid
+ info <- getUserInfo a.db uid
+ case Map.lookup "name" info.properties of
+ Just _ -> respondJSON info
+ Nothing -> do
+ status status404
+ respondText "no such user"
onGet "/api/user/stats/:uid" do
uid <- pathParam "uid"
respondJSON =<< getIntegerValuedMap a.db ("user:stats:" <> uid)