From 0020ed60690705dfd97e5d34984d08223d1afb26 Mon Sep 17 00:00:00 2001 From: Leif Battermann Date: Sat, 15 Jul 2023 16:31:43 +0200 Subject: [PATCH] fix: ster get-meta-info (#3436) --- changelog.d/3-bug-fixes/pr-3436 | 1 + tools/stern/src/Stern/API.hs | 8 ++++---- tools/stern/src/Stern/API/Routes.hs | 2 ++ 3 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 changelog.d/3-bug-fixes/pr-3436 diff --git a/changelog.d/3-bug-fixes/pr-3436 b/changelog.d/3-bug-fixes/pr-3436 new file mode 100644 index 00000000000..229545d92ef --- /dev/null +++ b/changelog.d/3-bug-fixes/pr-3436 @@ -0,0 +1 @@ +`/i/user/meta-info` endpoint in backoffice/stern fixed diff --git a/tools/stern/src/Stern/API.hs b/tools/stern/src/Stern/API.hs index 3a3e30205f3..66d29acf611 100644 --- a/tools/stern/src/Stern/API.hs +++ b/tools/stern/src/Stern/API.hs @@ -395,13 +395,13 @@ getConsentLog e = do <$> Intra.getEmailConsentLog e <*> Intra.getMarketoResult e -getUserData :: UserId -> Handler UserMetaInfo -getUserData uid = do +getUserData :: UserId -> Maybe Int -> Maybe Int -> Handler UserMetaInfo +getUserData uid mMaxConvs mMaxNotifs = do account <- Intra.getUserProfiles (Left [uid]) >>= noSuchUser . listToMaybe conns <- Intra.getUserConnections uid - convs <- Intra.getUserConversations uid + convs <- Intra.getUserConversations uid <&> take (fromMaybe 1 mMaxConvs) clts <- Intra.getUserClients uid - notfs <- (Intra.getUserNotifications uid <&> toJSON @[QueuedNotification]) `catchE` (pure . String . cs . show) + notfs <- (Intra.getUserNotifications uid <&> take (fromMaybe 10 mMaxNotifs) <&> toJSON @[QueuedNotification]) `catchE` (pure . String . cs . show) consent <- (Intra.getUserConsentValue uid <&> toJSON @ConsentValue) `catchE` (pure . String . cs . show) consentLog <- (Intra.getUserConsentLog uid <&> toJSON @ConsentLog) `catchE` (pure . String . cs . show) cookies <- Intra.getUserCookies uid diff --git a/tools/stern/src/Stern/API/Routes.hs b/tools/stern/src/Stern/API/Routes.hs index af94471b030..58f241352eb 100644 --- a/tools/stern/src/Stern/API/Routes.hs +++ b/tools/stern/src/Stern/API/Routes.hs @@ -379,6 +379,8 @@ type SternAPI = :> "user" :> "meta-info" :> QueryParam' [Required, Strict, Description "A valid UserId"] "id" UserId + :> QueryParam' [Optional, Strict, Description "Max number of conversation (default 1)"] "max_conversations" Int + :> QueryParam' [Optional, Strict, Description "Max number of notifications (default 10)"] "max_notifications" Int :> Post '[JSON] UserMetaInfo ) :<|> Named