Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Commit

Permalink
bug: Remove expiry checks for routing to prevent dropped mobile UAID
Browse files Browse the repository at this point in the history
Closes #1161
  • Loading branch information
jrconlin committed Mar 20, 2018
1 parent e723de3 commit 027c7f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 5 additions & 14 deletions autopush/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,9 @@ def create_router_table(tablename="router", read_throughput=5,
)
table.meta.client.get_waiter('table_exists').wait(
TableName=tablename)
try:
table.meta.client.update_time_to_live(
TableName=tablename,
TimeToLiveSpecification={
'Enabled': True,
'AttributeName': 'expiry'
}
)
except ClientError as ex: # pragma nocover
if ex.response["Error"]["Code"] != "UnknownOperationException":
raise
# Mobile devices (particularly older ones) do not have expiry and
# do not check in regularly. We don't know when they expire other than
# the bridge server failing the UID from their side.
return table


Expand Down Expand Up @@ -776,9 +768,8 @@ def get_uaid(self, uaid):
# Incomplete record, drop it.
self.drop_user(uaid)
raise ItemNotFound("uaid not found")
if item.get("expiry") < _expiry(0):
self.drop_user(uaid)
raise ItemNotFound("uaid expired")
# Mobile users do not check in after initial registration.
# DO NOT EXPIRE THEM.
return item
except Boto3Error: # pragma: nocover
# We trap JSONResponseError because Moto returns text instead of
Expand Down
4 changes: 3 additions & 1 deletion autopush/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ def raise_error(*args, **kwargs):
router_type="webpush"))
assert res == (False, {})

"""
def test_register_user_expired(self):
from time import time
Expand All @@ -535,7 +536,8 @@ def test_register_user_expired(self):
with pytest.raises(ItemNotFound) as ex:
router.get_uaid(uaid)
assert ex.value.message == "uaid expired"

"""

def test_clear_node_provision_failed(self):
router = Router(self.table_conf, SinkMetrics(),
resource=self.resource)
Expand Down

0 comments on commit 027c7f2

Please sign in to comment.