Skip to content

Commit

Permalink
Update aioapns dependency to one that supports python 3.10+
Browse files Browse the repository at this point in the history
  • Loading branch information
bradtgmurray committed Sep 5, 2023
1 parent db821f3 commit d33c452
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ authors = [
{name = "Matrix.org Team and contributors", email = "[email protected]"}
]
dependencies = [
"aioapns>=1.10,<2.1",
"aioapns>=3.0",
"attrs>=19.2.0",
"cryptography>=2.6.1",
"idna>=2.8",
Expand Down
51 changes: 27 additions & 24 deletions sygnal/apnspushkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,31 +172,34 @@ def __init__(self, name: str, sygnal: "Sygnal", config: Dict[str, Any]) -> None:
# this overrides the create_connection method to use a HTTP proxy
loop = ProxyingEventLoopWrapper(loop, proxy_url_str) # type: ignore

if certfile is not None:
# max_connection_attempts is actually the maximum number of
# additional connection attempts, so =0 means try once only
# (we will retry at a higher level so not worth doing more here)
self.apns_client = APNs(
client_cert=certfile,
use_sandbox=self.use_sandbox,
max_connection_attempts=0,
loop=loop,
)
async def make_apns() -> aioapns.APNs:
if certfile is not None:
# max_connection_attempts is actually the maximum number of
# additional connection attempts, so =0 means try once only
# (we will retry at a higher level so not worth doing more here)
apns_client = APNs(
client_cert=certfile,
use_sandbox=self.use_sandbox,
max_connection_attempts=0,
)

self._report_certificate_expiration(certfile)
else:
# max_connection_attempts is actually the maximum number of
# additional connection attempts, so =0 means try once only
# (we will retry at a higher level so not worth doing more here)
self.apns_client = APNs(
key=self.get_config("keyfile", str),
key_id=self.get_config("key_id", str),
team_id=self.get_config("team_id", str),
topic=self.get_config("topic", str),
use_sandbox=self.use_sandbox,
max_connection_attempts=0,
loop=loop,
)
self._report_certificate_expiration(certfile)

return apns_client
else:
# max_connection_attempts is actually the maximum number of
# additional connection attempts, so =0 means try once only
# (we will retry at a higher level so not worth doing more here)
return APNs(
key=self.get_config("keyfile", str),
key_id=self.get_config("key_id", str),
team_id=self.get_config("team_id", str),
topic=self.get_config("topic", str),
use_sandbox=self.use_sandbox,
max_connection_attempts=0,
)

self.apns_client = loop.run_until_complete(make_apns())

push_type = self.get_config("push_type", str)
if not push_type:
Expand Down

0 comments on commit d33c452

Please sign in to comment.