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

Commit

Permalink
fix: don't check storage for new uaid's
Browse files Browse the repository at this point in the history
Closes #1017
  • Loading branch information
bbangert committed Sep 13, 2017
1 parent 4d5a44f commit 922e342
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 81 deletions.
2 changes: 2 additions & 0 deletions autopush/tests/test_webpush_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ def test_nonexisting_uaid(self):
result = p.process(hello) # type: HelloResponse
ok_(isinstance(result, HelloResponse))
ok_(hello.uaid != result.uaid)
eq_(result.check_storage, False)

def test_existing_uaid(self):
p = self._makeFUT()
Expand All @@ -244,6 +245,7 @@ def test_existing_uaid(self):
result = p.process(hello) # type: HelloResponse
ok_(isinstance(result, HelloResponse))
eq_(hello.uaid.hex, result.uaid)
eq_(result.check_storage, True)

def test_existing_newer_uaid(self):
p = self._makeFUT()
Expand Down
8 changes: 7 additions & 1 deletion autopush/webpush_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class OutputCommand(object):
class HelloResponse(OutputCommand):
uaid = attrib() # type: Optional[str]
message_month = attrib() # type: str
check_storage = attrib() # type: bool
reset_uaid = attrib() # type: bool
rotate_message_table = attrib(default=False) # type: bool

Expand Down Expand Up @@ -337,6 +338,7 @@ def process(self, hello):
# type: (Hello) -> HelloResponse
user_item = None
flags = dict(
check_storage=False,
message_month=self.db.current_msg_month,
reset_uaid=False
)
Expand All @@ -359,8 +361,9 @@ def lookup_user(self, hello):
# type: (Hello) -> (Optional[JSONDict], JSONDict)
flags = dict(
message_month=None,
rotate_message_table=False,
check_storage=False,
reset_uaid=False,
rotate_message_table=False,
)
uaid = hello.uaid.hex
try:
Expand All @@ -380,6 +383,9 @@ def lookup_user(self, hello):
self.db.router.drop_user(uaid)
return None, flags

# If we got here, its a valid user that needs storage checked
flags["check_storage"] = True

# Determine if message table rotation is needed
flags["message_month"] = record["current_month"]
if record["current_month"] != self.db.current_msg_month:
Expand Down
1 change: 1 addition & 0 deletions autopush_rs/src/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ struct PythonError {
pub struct HelloResponse {
pub uaid: Option<Uuid>,
pub message_month: String,
pub check_storage: bool,
pub reset_uaid: bool,
pub rotate_message_table: bool,
}
Expand Down
Loading

0 comments on commit 922e342

Please sign in to comment.