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 58b5085
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 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
12 changes: 0 additions & 12 deletions autopush/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,18 +524,6 @@ def raise_error(*args, **kwargs):
router_type="webpush"))
assert res == (False, {})

def test_register_user_expired(self):
from time import time

router = Router(self.table_conf, SinkMetrics(), resource=self.resource)
expired = self._create_minimal_record()
uaid = expired["uaid"]
expired["expiry"] = int(time()) - 100
self.router.register_user(expired)
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 58b5085

Please sign in to comment.