Skip to content

Commit 2813e70

Browse files
author
Micah Denbraver
committed
remove undocumented 'creds' parameter
1 parent 0f79181 commit 2813e70

File tree

2 files changed

+22
-23
lines changed

2 files changed

+22
-23
lines changed

push_notifications/apns.py

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,18 @@
1616
from .exceptions import APNSError, APNSUnsupportedPriority, APNSServerError
1717

1818

19-
def _apns_create_socket(creds=None, application_id=None):
20-
if creds is None:
21-
if not get_manager().has_auth_token_creds(application_id):
22-
cert = get_manager().get_apns_certificate(application_id)
23-
creds = apns2_credentials.CertificateCredentials(cert)
24-
else:
25-
keyPath, keyId, teamId = get_manager().get_apns_auth_creds(application_id)
26-
# No use getting a lifetime because this credential is
27-
# ephemeral, but if you're looking at this to see how to
28-
# create a credential, you could also pass the lifetime and
29-
# algorithm. Neither of those settings are exposed in the
30-
# settings API at the moment.
31-
creds = creds or apns2_credentials.TokenCredentials(keyPath, keyId, teamId)
19+
def _apns_create_socket(application_id=None):
20+
if not get_manager().has_auth_token_creds(application_id):
21+
cert = get_manager().get_apns_certificate(application_id)
22+
creds = apns2_credentials.CertificateCredentials(cert)
23+
else:
24+
keyPath, keyId, teamId = get_manager().get_apns_auth_creds(application_id)
25+
# No use getting a lifetime because this credential is
26+
# ephemeral, but if you're looking at this to see how to
27+
# create a credential, you could also pass the lifetime and
28+
# algorithm. Neither of those settings are exposed in the
29+
# settings API at the moment.
30+
creds = apns2_credentials.TokenCredentials(keyPath, keyId, teamId)
3231
client = apns2_client.APNsClient(
3332
creds,
3433
use_sandbox=get_manager().get_apns_use_sandbox(application_id),
@@ -59,9 +58,9 @@ def _apns_prepare(
5958

6059

6160
def _apns_send(
62-
registration_id, alert, batch=False, application_id=None, creds=None, **kwargs
61+
registration_id, alert, batch=False, application_id=None, **kwargs
6362
):
64-
client = _apns_create_socket(creds=creds, application_id=application_id)
63+
client = _apns_create_socket(application_id=application_id)
6564

6665
notification_kwargs = {}
6766

@@ -97,7 +96,7 @@ def _apns_send(
9796
)
9897

9998

100-
def apns_send_message(registration_id, alert, application_id=None, creds=None, **kwargs):
99+
def apns_send_message(registration_id, alert, application_id=None, **kwargs):
101100
"""
102101
Sends an APNS notification to a single registration_id.
103102
This will send the notification as form data.
@@ -112,7 +111,7 @@ def apns_send_message(registration_id, alert, application_id=None, creds=None, *
112111
try:
113112
_apns_send(
114113
registration_id, alert, application_id=application_id,
115-
creds=creds, **kwargs
114+
**kwargs
116115
)
117116
except apns2_errors.APNsException as apns2_exception:
118117
if isinstance(apns2_exception, apns2_errors.Unregistered):
@@ -124,7 +123,7 @@ def apns_send_message(registration_id, alert, application_id=None, creds=None, *
124123

125124

126125
def apns_send_bulk_message(
127-
registration_ids, alert, application_id=None, creds=None, **kwargs
126+
registration_ids, alert, application_id=None, **kwargs
128127
):
129128
"""
130129
Sends an APNS notification to one or more registration_ids.
@@ -137,7 +136,7 @@ def apns_send_bulk_message(
137136

138137
results = _apns_send(
139138
registration_ids, alert, batch=True, application_id=application_id,
140-
creds=creds, **kwargs
139+
**kwargs
141140
)
142141
inactive_tokens = [token for token, result in results.items() if result == "Unregistered"]
143142
models.APNSDevice.objects.filter(registration_id__in=inactive_tokens).update(active=False)

push_notifications/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_queryset(self):
133133

134134

135135
class APNSDeviceQuerySet(models.query.QuerySet):
136-
def send_message(self, message, creds=None, **kwargs):
136+
def send_message(self, message, **kwargs):
137137
if self.exists():
138138
from .apns import apns_send_bulk_message
139139

@@ -146,7 +146,7 @@ def send_message(self, message, creds=None, **kwargs):
146146
)
147147
r = apns_send_bulk_message(
148148
registration_ids=reg_ids, alert=message, application_id=app_id,
149-
creds=creds, **kwargs
149+
**kwargs
150150
)
151151
if hasattr(r, "keys"):
152152
res += [r]
@@ -169,13 +169,13 @@ class APNSDevice(Device):
169169
class Meta:
170170
verbose_name = _("APNS device")
171171

172-
def send_message(self, message, creds=None, **kwargs):
172+
def send_message(self, message, **kwargs):
173173
from .apns import apns_send_message
174174

175175
return apns_send_message(
176176
registration_id=self.registration_id,
177177
alert=message,
178-
application_id=self.application_id, creds=creds,
178+
application_id=self.application_id,
179179
**kwargs
180180
)
181181

0 commit comments

Comments
 (0)