diff --git a/changelog.d/3-bug-fixes/aws-sns-without-CustomUserData b/changelog.d/3-bug-fixes/aws-sns-without-CustomUserData deleted file mode 100644 index a6dd4abd4f5..00000000000 --- a/changelog.d/3-bug-fixes/aws-sns-without-CustomUserData +++ /dev/null @@ -1 +0,0 @@ -Previously, AWS/SNS endpoint creation included `CustomUserData` which was the `UserId`. This doesn't make sense anymore; given that a user may be attached with the same device (Android or iOS) and several accounts (several `UserId`s!) to the same backend. So, `CustomUserData` isn't added to the request, anymore. diff --git a/services/gundeck/src/Gundeck/Aws.hs b/services/gundeck/src/Gundeck/Aws.hs index d0c955a5636..09984bb4a0b 100644 --- a/services/gundeck/src/Gundeck/Aws.hs +++ b/services/gundeck/src/Gundeck/Aws.hs @@ -283,18 +283,17 @@ lookupEndpoint arn = do pure (SNSEndpoint (Push.Token t) (fromMaybe False e) d) mkUsers = Set.fromList . mapMaybe (hush . fromText) . Text.split (== ':') -createEndpoint :: Push.Transport -> ArnEnv -> AppName -> Push.Token -> Amazon (Either CreateEndpointError EndpointArn) -createEndpoint tr arnEnv app token = do +createEndpoint :: UserId -> Push.Transport -> ArnEnv -> AppName -> Push.Token -> Amazon (Either CreateEndpointError EndpointArn) +createEndpoint u tr arnEnv app token = do env <- ask let top = mkAppTopic arnEnv tr app let arn = mkSnsArn (env ^. region) (env ^. account) top let tkn = Push.tokenText token let req = SNS.newCreatePlatformEndpoint (toText arn) tkn + & set SNS.createPlatformEndpoint_customUserData (Just (toText u)) & set SNS.createPlatformEndpoint_attributes (Just $ Map.insert "Enabled" "true" Map.empty) - logRequest req tkn arn res <- retrying (limitRetries 2) (const isTimeout) (const (sendCatch (env ^. awsEnv) req)) - logResponse res tkn arn case res of Right r -> case view SNS.createPlatformEndpointResponse_endpointArn r of @@ -314,7 +313,6 @@ createEndpoint tr arnEnv app token = do debug $ msg @Text "InvalidParameter: InvalidToken" . field "response" (show x) - . logFields tkn arn pure (Left (InvalidToken token)) | is "SNS" 404 x -> pure (Left (AppNotFound app)) @@ -345,22 +343,6 @@ createEndpoint tr arnEnv app token = do string "must be at most 8192 bytes long in UTF-8 encoding" <|> string "iOS device tokens must be no more than 400 hexadecimal characters" pure () - logRequest req tkn arn = - trace $ - msg @Text "AWS/SNS endpoint creation request" - . field "request" (show req) - . logFields tkn arn - logResponse res tkn arn = - trace $ - msg @Text "AWS/SNS endpoint creation response" - . field "response" (show res) - . logFields tkn arn - logFields tkn arn = - field "transport" (show tr) - . field "appName" (show app) - . field "arnEnv" (show arnEnv) - . field "token" tkn - . field "arn" (toText arn) -------------------------------------------------------------------------------- -- Publish diff --git a/services/gundeck/src/Gundeck/Push.hs b/services/gundeck/src/Gundeck/Push.hs index 935a6bd33bc..f863ff57a03 100644 --- a/services/gundeck/src/Gundeck/Push.hs +++ b/services/gundeck/src/Gundeck/Push.hs @@ -450,7 +450,7 @@ addToken uid cid newtok = mpaRunWithBudget 1 (Left Public.AddTokenErrorNoBudget) let tok = t ^. token env <- view (options . optAws . awsArnEnv) aws <- view awsEnv - ept <- Aws.execute aws (Aws.createEndpoint trp env app tok) + ept <- Aws.execute aws (Aws.createEndpoint uid trp env app tok) case ept of Left (Aws.EndpointInUse arn) -> do Log.info $ "arn" .= toText arn ~~ msg (val "ARN in use")