Created
April 30, 2021 21:55
-
-
Save andrewvmail/d442b7239611a55afd60f4e71166ab2f to your computer and use it in GitHub Desktop.
sparrow.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/sparrow/apns.ex b/lib/sparrow/apns.ex | |
index ae60b02..83b4233 100644 | |
--- a/lib/sparrow/apns.ex | |
+++ b/lib/sparrow/apns.ex | |
@@ -141,6 +141,17 @@ defmodule Sparrow.APNS do | |
"action=handle_push_response, result=fail, reason=#{inspect(reason)}" | |
end) | |
+ if reason === :TooManyProviderTokenUpdates do | |
+ _ = | |
+ Logger.info("TooManyProviderTokenUpdates Restart the process", | |
+ what: :apns_push_response, | |
+ result: :error, | |
+ reason: inspect(reason) | |
+ ) | |
+ Application.stop(:sparrow) | |
+ Application.start(:sparrow) | |
+ end | |
+ | |
{:error, reason} | |
end | |
end | |
diff --git a/lib/sparrow/apns/token_bearer.ex b/lib/sparrow/apns/token_bearer.ex | |
index cfb431c..b7d3d37 100644 | |
--- a/lib/sparrow/apns/token_bearer.ex | |
+++ b/lib/sparrow/apns/token_bearer.ex | |
@@ -13,6 +13,7 @@ defmodule Sparrow.APNS.TokenBearer do | |
@apns_jwt_alg "ES256" | |
@refresh_token_time :timer.minutes(50) | |
+ | |
@doc """ | |
Returns APNS token for token based authentication. | |
""" | |
@@ -28,6 +29,10 @@ defmodule Sparrow.APNS.TokenBearer do | |
| {%{required(atom) => Sparrow.APNS.Token.t()}, pos_integer} | |
) :: GenServer.on_start() | |
def start_link(tokens) do | |
+ _ = | |
+ Logger.info(fn -> | |
+ "start link" | |
+ end) | |
GenServer.start_link(__MODULE__, tokens, name: __MODULE__) | |
end | |
@@ -40,12 +45,10 @@ defmodule Sparrow.APNS.TokenBearer do | |
state = Sparrow.APNS.TokenBearer.State.new(tokens, refresh_token_time) | |
@tab_name = :ets.new(@tab_name, [:set, :protected, :named_table]) | |
update_tokens(state) | |
- | |
_ = | |
Logger.info(fn -> | |
- "worker=apns_tokens_bearer, action=init, result=success" | |
+ "worker=apns_tokens_bearer, action=init, result=success (patched)" | |
end) | |
- | |
{:ok, state} | |
end | |
@@ -53,12 +56,10 @@ defmodule Sparrow.APNS.TokenBearer do | |
state = Sparrow.APNS.TokenBearer.State.new(tokens, @refresh_token_time) | |
@tab_name = :ets.new(@tab_name, [:set, :protected, :named_table]) | |
update_tokens(state) | |
- | |
_ = | |
Logger.info(fn -> | |
- "worker=apns_tokens_bearer, action=init, result=success" | |
+ "worker=apns_tokens_bearer, action=init, result=success (patched)" | |
end) | |
- | |
{:ok, state} | |
end | |
@@ -78,7 +79,7 @@ defmodule Sparrow.APNS.TokenBearer do | |
{:noreply, Sparrow.APNS.TokenBearer.State.t()} | |
def handle_info(:update_tokens, state) do | |
update_tokens(state) | |
- _ = Logger.debug(fn -> "worker=apns_tokens_bearer, action=token_update" end) | |
+ _ = Logger.info(fn -> "worker=apns_tokens_bearer, action=token_update" end) | |
{:noreply, state} | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment