@@ -93,7 +93,7 @@ homePage mayEvent = do
9393 LogOut -> Map. singleton " event" " log-out"
9494
9595-- E.g. https://share.unison-lang.org/@unison/base/code/@ceedubs/each-first/latest
96- projectBranchBrowseLink :: ProjectBranchShortHand -> AppM reqCtx URI
96+ projectBranchBrowseLink :: ( MonadReader ( Env. Env ctx ) m ) => ProjectBranchShortHand -> m URI
9797projectBranchBrowseLink (ProjectBranchShortHand {userHandle, projectSlug, contributorHandle, branchName}) = do
9898 let branchPath = case contributorHandle of
9999 Just contributor -> [IDs. toText contributor, IDs. toText branchName]
@@ -102,13 +102,13 @@ projectBranchBrowseLink (ProjectBranchShortHand {userHandle, projectSlug, contri
102102 shareUIPath path
103103
104104-- E.g. https://share.unison-lang.org/@unison/base/contributions/100
105- contributionLink :: ProjectShortHand -> ContributionNumber -> AppM reqCtx URI
105+ contributionLink :: ( MonadReader ( Env. Env ctx ) m ) => ProjectShortHand -> ContributionNumber -> m URI
106106contributionLink (ProjectShortHand {userHandle, projectSlug}) contributionNumber = do
107107 let path = [IDs. toText (PrefixedID @ " @" userHandle), IDs. toText projectSlug, " contributions" , IDs. toText contributionNumber]
108108 shareUIPath path
109109
110110-- | Where the user should go when clicking on a notification
111- notificationLink :: HydratedEventPayload -> AppM reqCtx URI
111+ notificationLink :: ( MonadReader ( Env. Env ctx ) m ) => HydratedEventPayload -> m URI
112112notificationLink = \ case
113113 HydratedProjectBranchUpdatedPayload payload ->
114114 projectBranchBrowseLink payload. branchInfo. projectBranchShortHand
@@ -123,19 +123,19 @@ unisonLogoImage =
123123----------- Utilities -----------
124124
125125-- | Construct a full URI to a path within share, with provided query params.
126- sharePathQ :: [Text ] -> Map Text Text -> AppM reqCtx URI
126+ sharePathQ :: ( MonadReader ( Env. Env ctx ) m ) => [Text ] -> Map Text Text -> m URI
127127sharePathQ pathSegments queryParams = do
128128 uri <- asks Env. apiOrigin
129129 pure . setPathAndQueryParams pathSegments queryParams $ uri
130130
131131-- | Construct a full URI to a path within share.
132- sharePath :: [Text ] -> AppM reqCtx URI
132+ sharePath :: ( MonadReader ( Env. Env ctx ) m ) => [Text ] -> m URI
133133sharePath path = sharePathQ path mempty
134134
135135-- | Check if a URI is a the Share UI, the Cloud UI, the main website, or the
136136-- Cloud website. This is useful for preventing attackers from generating
137137-- arbitrary redirections in things like login redirects.
138- isTrustedURI :: URI -> AppM reqCtx Bool
138+ isTrustedURI :: ( MonadReader ( Env. Env ctx ) m ) => URI -> m Bool
139139isTrustedURI uri = do
140140 shareUiURI <- asks Env. shareUiOrigin
141141 websiteURI <- asks Env. websiteOrigin
@@ -146,12 +146,12 @@ isTrustedURI uri = do
146146 pure $ any (\ uri -> uriAuthority uri == requestedAuthority) trustedURIs
147147
148148-- | Construct a full URI to a path within the share UI, with the provided query params.
149- shareUIPathQ :: [Text ] -> Map Text Text -> AppM reqCtx URI
149+ shareUIPathQ :: ( MonadReader ( Env. Env ctx ) m ) => [Text ] -> Map Text Text -> m URI
150150shareUIPathQ pathSegments queryParams = do
151151 shareUiURI <- asks Env. shareUiOrigin
152152 pure . setPathAndQueryParams pathSegments queryParams $ shareUiURI
153153
154- shareUIPath :: [Text ] -> AppM reqCtx URI
154+ shareUIPath :: ( MonadReader ( Env. Env ctx ) m ) => [Text ] -> m URI
155155shareUIPath pathSegments = shareUIPathQ pathSegments mempty
156156
157157-- | Various Error types that the Share UI knows how to interpret
@@ -172,7 +172,7 @@ shareUIErrorToUIText e =
172172 AccountCreationInvalidHandle {} ->
173173 " AccountCreationInvalidHandle"
174174
175- errorRedirectLink :: ShareUIError -> AppM reqCtx URI
175+ errorRedirectLink :: ( MonadReader ( Env. Env ctx ) m ) => ShareUIError -> m URI
176176errorRedirectLink shareUIError = shareUIPathQ [" error" ] (Map. fromList [(" appError" , shareUIErrorToUIText shareUIError)])
177177
178178-- | Redirect the user to the Share UI and show an error message.
0 commit comments