Return the error if return_messages_immediately returns an error response

We previously started long-polling.

(imported from commit 5860e484c63088ed34226f39f5aeb74e3ed43f91)
This commit is contained in:
Zev Benjamin 2012-11-01 15:53:40 -04:00
parent 08b76126b4
commit 6178cd830a
1 changed files with 4 additions and 2 deletions

View File

@ -432,7 +432,7 @@ def send_with_safety_check(response, handler, apply_markdown=True, **kwargs):
# c.f. ticket #64 # c.f. ticket #64
# #
# apply_markdown=True is the fail-safe default. # apply_markdown=True is the fail-safe default.
if apply_markdown: if response['result'] == 'success' and apply_markdown:
for msg in response['messages']: for msg in response['messages']:
if msg['content_type'] != 'text/html': if msg['content_type'] != 'text/html':
handler.set_status(500) handler.set_status(500)
@ -443,10 +443,12 @@ def send_with_safety_check(response, handler, apply_markdown=True, **kwargs):
def get_updates_backend(request, user_profile, handler, client_id, **kwargs): def get_updates_backend(request, user_profile, handler, client_id, **kwargs):
resp = return_messages_immediately(request, user_profile, resp = return_messages_immediately(request, user_profile,
client_id, **kwargs) client_id, **kwargs)
if resp is not None and resp['result'] == 'success': if resp is not None:
send_with_safety_check(resp, handler, **kwargs) send_with_safety_check(resp, handler, **kwargs)
return return
# Now we're in long-polling mode
def cb(**cb_kwargs): def cb(**cb_kwargs):
if handler.request.connection.stream.closed(): if handler.request.connection.stream.closed():
return return