From 62f0726dea6ad3e1c61758f48dcc3a4706d821bc Mon Sep 17 00:00:00 2001 From: Ryan Barrett Date: Wed, 28 Oct 2015 17:59:34 -0700 Subject: [PATCH] retry: redirect back to page user came from to preserve query params. for #524 --- app.py | 3 ++- templates/social_user.html | 1 + test/test_app.py | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 01ac7347..de379f5c 100644 --- a/app.py +++ b/app.py @@ -525,7 +525,8 @@ def post(self): self.abort(400, 'Unexpected key kind %s', entity.key.kind()) self.messages.add('Retrying. Refresh in a minute to see the results!') - self.redirect(entity.source.get().bridgy_url(self)) + self.redirect(self.request.get('redirect_to').encode('utf-8') or + entity.source.get().bridgy_url(self)) class RedirectToFrontPageHandler(util.Handler): diff --git a/templates/social_user.html b/templates/social_user.html index f4fbfe29..64745f04 100644 --- a/templates/social_user.html +++ b/templates/social_user.html @@ -204,6 +204,7 @@
+
diff --git a/test/test_app.py b/test/test_app.py index 373b89e7..bc2fd3f1 100644 --- a/test/test_app.py +++ b/test/test_app.py @@ -84,6 +84,14 @@ def test_retry(self): # webmention endpoints for URL domains should be refreshed self.assertIsNone(memcache.get('W https skipped')) + def test_retry_redirect_to(self): + key = self.responses[0].put() + response = app.application.get_response( + '/retry', method='POST', body='key=%s&redirect_to=/foo/bar' % key.urlsafe()) + self.assertEquals(302, response.status_int) + self.assertEquals('http://localhost/foo/bar', + response.headers['Location'].split('#')[0]) + def test_poll_now_and_retry_response_missing_key(self): for endpoint in '/poll-now', '/retry': for body in '', 'key=' + self.responses[0].key.urlsafe(): # hasn't been stored