Skip to content

Commit

Permalink
fix: ster get-meta-info (#3436)
Browse files Browse the repository at this point in the history
  • Loading branch information
battermann authored Jul 15, 2023
1 parent d7502ba commit 0020ed6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions changelog.d/3-bug-fixes/pr-3436
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`/i/user/meta-info` endpoint in backoffice/stern fixed
8 changes: 4 additions & 4 deletions tools/stern/src/Stern/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tools/stern/src/Stern/API/Routes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0020ed6

Please sign in to comment.