Skip to content

Commit

Permalink
chore: run mix format on our changes (#4)
Browse files Browse the repository at this point in the history
* fix: allow httpoison 2.0 (codedge-llc#236)

* fix: allow httpoison 2.0

* ci: fix workflows

* ci: revert to ubuntu-latest

* ci: use setup-beam@v1

* chore: update CHANGELOG

* docs: update README links

* fix: move token generation into Pigeon.APNS.Token (codedge-llc#227)

This means the token is only generated once and used across all workers

* chore: update CHANGELOG

---------

Co-authored-by: Henry Popp <[email protected]>
Co-authored-by: Henry Popp <[email protected]>
Co-authored-by: Andrew Timberlake <[email protected]>
  • Loading branch information
4 people authored Mar 17, 2023
1 parent 4f7a5a9 commit 81a4cce
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pigeon/apns/token.ex
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ defmodule Pigeon.APNS.Token do

@spec get(JWTConfig.t()) :: t
def get(%JWTConfig{} = config) do
token_storage_key = config.key_identifier <> ":" <> config.team_id <> ":" <> config.uri
token_storage_key =
config.key_identifier <> ":" <> config.team_id <> ":" <> config.uri

Agent.get_and_update(__MODULE__, fn map ->
{timestamp, saved_token} = Map.get(map, token_storage_key, {0, nil})
now = :os.system_time(:seconds)

age = now - timestamp

if age < @token_max_age do
{saved_token, map}
else
Expand Down

0 comments on commit 81a4cce

Please sign in to comment.