diff --git a/autopush/tests/test_webpush_server.py b/autopush/tests/test_webpush_server.py index 8790d557..e1f93d20 100644 --- a/autopush/tests/test_webpush_server.py +++ b/autopush/tests/test_webpush_server.py @@ -26,7 +26,6 @@ from autopush.webpush_server import ( CheckStorage, DeleteMessage, - DropUser, MigrateUser, StoreMessages, Unregister, @@ -231,31 +230,6 @@ def test_delete_message(self): assert len(results.messages) == 5 -class TestDropUserProcessor(BaseSetup): - def _makeFUT(self): - from autopush.webpush_server import DropUserCommand - return DropUserCommand(self.conf, self.db) - - def test_drop_user(self): - drop_command = self._makeFUT() - - # Create a user - user = UserItemFactory() - uaid = user["uaid"] - self.db.router.register_user(user) - - # Check that its there - item = self.db.router.get_uaid(uaid) - assert item is not None - - # Drop it - drop_command.process(DropUser(uaid=uaid)) - - # Verify its gone - with pytest.raises(ItemNotFound): - self.db.router.get_uaid(uaid) - - class TestMigrateUserProcessor(BaseSetup): def _makeFUT(self): from autopush.webpush_server import MigrateUserCommand diff --git a/autopush/webpush_server.py b/autopush/webpush_server.py index 533db3f5..1a95566b 100644 --- a/autopush/webpush_server.py +++ b/autopush/webpush_server.py @@ -139,11 +139,6 @@ class DeleteMessage(InputCommand): message = attrib(convert=dict_to_webpush_message) # type: WebPushMessage -@attrs(slots=True) -class DropUser(InputCommand): - uaid = attrib(convert=uaid_from_str) # type: UUID - - @attrs(slots=True) class MigrateUser(InputCommand): uaid = attrib(convert=uaid_from_str) # type: UUID @@ -180,11 +175,6 @@ class DeleteMessageResponse(OutputCommand): success = attrib(default=True) # type: bool -@attrs(slots=True) -class DropUserResponse(OutputCommand): - success = attrib(default=True) # type: bool - - @attrs(slots=True) class MigrateUserResponse(OutputCommand): message_month = attrib() # type: str @@ -264,20 +254,17 @@ def __init__(self, conf, db): self.db = db self.check_storage_processor = CheckStorageCommand(conf, db) self.delete_message_processor = DeleteMessageCommand(conf, db) - self.drop_user_processor = DropUserCommand(conf, db) self.migrate_user_proocessor = MigrateUserCommand(conf, db) self.unregister_process = UnregisterCommand(conf, db) self.store_messages_process = StoreMessagesUserCommand(conf, db) self.deserialize = dict( delete_message=DeleteMessage, - drop_user=DropUser, migrate_user=MigrateUser, unregister=Unregister, store_messages=StoreMessages, ) self.command_dict = dict( delete_message=self.delete_message_processor, - drop_user=self.drop_user_processor, migrate_user=self.migrate_user_proocessor, unregister=self.unregister_process, store_messages=self.store_messages_process, @@ -376,13 +363,6 @@ def process(self, command): return DeleteMessageResponse() -class DropUserCommand(ProcessorCommand): - def process(self, command): - # type: (DropUser) -> DropUserResponse - self.db.router.drop_user(command.uaid.hex) - return DropUserResponse() - - class MigrateUserCommand(ProcessorCommand): def process(self, command): # type: (MigrateUser) -> MigrateUserResponse diff --git a/autopush_rs/src/call.rs b/autopush_rs/src/call.rs index 4300b44a..088b82db 100644 --- a/autopush_rs/src/call.rs +++ b/autopush_rs/src/call.rs @@ -128,10 +128,6 @@ enum Call { message_month: String, }, - DropUser { - uaid: String, - }, - MigrateUser { uaid: String, message_month: String, @@ -168,11 +164,6 @@ pub struct DeleteMessageResponse { pub success: bool, } -#[derive(Deserialize)] -pub struct DropUserResponse { - pub success: bool, -} - #[derive(Deserialize)] pub struct MigrateUserResponse { pub message_month: String, @@ -214,12 +205,6 @@ impl Server { return fut; } - pub fn drop_user(&self, uaid: String) -> MyFuture { - let (call, fut) = PythonCall::new(&Call::DropUser { uaid }); - self.send_to_python(call); - return fut; - } - pub fn migrate_user( &self, uaid: String, diff --git a/autopush_rs/src/client.rs b/autopush_rs/src/client.rs index 3ddb9ee5..a223839e 100644 --- a/autopush_rs/src/client.rs +++ b/autopush_rs/src/client.rs @@ -592,7 +592,7 @@ where #[state_machine_future(transitions(AuthDone))] AwaitDropUser { - response: MyFuture, + response: MyFuture<()>, data: AuthClientData, }, @@ -696,7 +696,8 @@ where ); transition!(AwaitMigrateUser { response, data }); } else if all_acked && webpush.flags.reset_uaid { - let response = data.srv.drop_user(webpush.uaid.simple().to_string()); + + let response = data.srv.ddb.drop_uaid(&data.srv.opts.router_table_name, &webpush.uaid); transition!(AwaitDropUser { response, data }); } transition!(AwaitInput { data }) diff --git a/autopush_rs/src/util/ddb_helpers.rs b/autopush_rs/src/util/ddb_helpers.rs index be26abb6..ac4f1d14 100644 --- a/autopush_rs/src/util/ddb_helpers.rs +++ b/autopush_rs/src/util/ddb_helpers.rs @@ -855,6 +855,20 @@ impl DynamoStorage { Box::new(response) } + pub fn drop_uaid( + &self, + table_name: &str, + uaid: &Uuid, + ) -> MyFuture<()> { + let ddb = self.ddb.clone(); + let response = DynamoStorage::drop_user(ddb, uaid, table_name) + .and_then(move |_| -> MyFuture<_> { + Box::new(future::ok(())) + }) + .chain_err(|| "Unable to drop user record"); + Box::new(response) + } + pub fn check_storage( &self, table_name: &str,