Skip to content

Commit

Permalink
Rename VapidConfig to VAPIDConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
cotrone committed Nov 8, 2023
1 parent 5e2712a commit 2af7383
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Web/WebPush.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Web.WebPush (
, sendPushNotifications
-- * Types
, Subscription(..)
, VapidConfig(..)
, VAPIDConfig(..)
, PushNotification(..)
, PushNotificationCreated(..)
, PushNotificationError(..)
Expand Down Expand Up @@ -57,7 +57,7 @@ import Network.URI
import System.Random (randomRIO)

-- | Configuration for VAPID server identification
data VapidConfig = VapidConfig {
data VAPIDConfig = VAPIDConfig {
vapidConfigContact :: T.Text -- ^ Contact information for the application server, either a `mailto:` URI or an HTTPS URL
, vapidConfigKeys :: VAPIDKeys -- ^ Keypair used to sign the VAPID identification
}
Expand All @@ -71,7 +71,7 @@ data PushNotificationCreated = PushNotificationCreated {
-- similar to `sendPushNotification` but shares VAPID keys across multiple requests
sendPushNotifications :: (MonadIO m, A.ToJSON msg, MonadRandom m)
=> Manager
-> VapidConfig
-> VAPIDConfig
-> PushNotification msg
-> [Subscription]
-> m [(Subscription, Either PushNotificationError PushNotificationCreated)]
Expand Down Expand Up @@ -99,7 +99,7 @@ sendPushNotifications httpManager vapidConfig pushNotification subscriptions = d
-- > self.addEventListener('push', function(event){ console.log(event.data.json()); });
sendPushNotification :: (MonadIO m, A.ToJSON msg, MonadRandom m)
=> Manager
-> VapidConfig
-> VAPIDConfig
-> PushNotification msg
-> Subscription
-> m (Either PushNotificationError PushNotificationCreated)
Expand Down
2 changes: 1 addition & 1 deletion test/WebPushMock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ testSendMessage =
]
encodedMessage = TE.decodeUtf8 $ BSL.toStrict $ encode message
endpointManager <- HTTP.newManager HTTP.defaultManagerSettings
either (assertFailure . show) (const (pure ())) =<< sendPushNotification endpointManager (VapidConfig "mailto:test@example.com" keys) notification (subscriptionResult subscription)
either (assertFailure . show) (const (pure ())) =<< sendPushNotification endpointManager (VAPIDConfig "mailto:test@example.com" keys) notification (subscriptionResult subscription)

step "Getting notifications"
notificationsResponse <- webPushGetNotificationsFor (clientHash subscription)
Expand Down
4 changes: 2 additions & 2 deletions web-push-example/src/WebPushExample.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ appSendPushNotification cfg text = do
liftIO $ putStrLn $ "Sending notification to " <> show (Prelude.length subscribtions) <> " subscribers containing message: " <> show text

-- Send all notifications
let vapidConfig = WP.VapidConfig "mailto:test@example.com" keys
let vapidConfig = WP.VAPIDConfig "mailto:test@example.com" keys
liftIO $ putStrLn "Sending batch notifications "
results <- WP.sendPushNotifications manager vapidConfig pushDetails $ catMaybes (toWebPushSubscription <$> Set.toList subscribtions)
forM_ results $ \res -> do
Expand Down Expand Up @@ -189,7 +189,7 @@ initPersistentConfig = do
initPersistentKeys = do
privExists <- doesFileExist privKeyFp
pubExists <- doesFileExist pubKeyFp
if privExists || pubExists
if privExists && pubExists
then (either (fail . ("Unable to read keys: " <>) . show) pure) =<< WP.readVapidKeys pubKeyFp privKeyFp
else do
putStrLn "Generating keys"
Expand Down

0 comments on commit 2af7383

Please sign in to comment.