Skip to content

Commit 62065c4

Browse files
committed
can decode google play referrer
1 parent 4a49410 commit 62065c4

File tree

4 files changed

+30
-7
lines changed

4 files changed

+30
-7
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: delivery-calculator
3-
version: 0.1.0.18
3+
version: 0.1.0.20
44
synopsis: Delivery Calculator
55
category: Web
66
build-type: Simple

ghcjs/delivery-calculator/src/App/Types.hs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module App.Types
2525
cny,
2626
rub,
2727
mkGooglePlayLink,
28+
unGooglePlayLink,
2829
testGroupLink,
2930
functoraLink,
3031
sourceLink,
@@ -529,6 +530,9 @@ mkGooglePlayLink st =
529530
k <- URI.mkQueryKey "referrer"
530531
v <-
531532
URI.mkQueryValue
533+
. decodeUtf8
534+
. B64URL.encodeUnpadded
535+
. encodeUtf8
532536
$ URI.render
533537
ref
534538
{ URI.uriQuery =
@@ -544,6 +548,13 @@ mkGooglePlayLink st =
544548
{ URI.uriQuery = [URI.QueryParam k v]
545549
}
546550

551+
unGooglePlayLink :: (MonadIO m, MonadThrow m) => Unicode -> m (St Unique)
552+
unGooglePlayLink raw = do
553+
bs <- either throwString pure . B64URL.decodeUnpadded $ encodeUtf8 raw
554+
txt <- either throw pure $ decodeUtf8Strict bs
555+
uri <- URI.mkURI txt
556+
either throw identityToUnique . fromQuery $ URI.uriQuery uri
557+
547558
testGroupLink :: URI
548559
testGroupLink =
549560
either impureThrow id

ghcjs/delivery-calculator/src/Main.hs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,26 @@ updateModel (InitUpdate mShortSt) prevSt = do
141141
.~ False
142142
opfsSync sink nextSt
143143
Just ref -> do
144-
alert ref
144+
longSt <- unGooglePlayLink ref
145+
let mLongSt = Just longSt
146+
let st =
147+
( mShortSt <|> mLongSt
148+
)
149+
& _Just
150+
. #stAssets
151+
.~ ( fromMaybe mempty $ mLongSt ^? _Just . #stAssets
152+
)
153+
finSt <- newModel (nextSt ^. #modelWebOpts) mvSink (Just nextSt) st
145154
liftIO
146155
. sink
147156
. PushUpdate
148157
. PureUpdate
149-
$ #modelLoading
150-
.~ False
151-
opfsSync sink nextSt
158+
$ ( const
159+
$ finSt
160+
& #modelLoading
161+
.~ False
162+
)
163+
opfsSync sink finSt
152164
Just uri -> do
153165
mLongSt <- unLongUri uri
154166
let st =

ghcjs/delivery-calculator/trapeze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
platforms:
22
android:
33
appName: Delivery Calculator
4-
versionCode: 18
5-
versionName: 0.1.0.18
4+
versionCode: 20
5+
versionName: 0.1.0.20
66
packageName: com.functora.delivery_calculator
77
manifest:
88
- file: AndroidManifest.xml

0 commit comments

Comments
 (0)