mirror of https://github.com/zulip/zulip.git
get_updates: Replace the "mirror" argument with checking "client".
(imported from commit bd84c2c7a456de8ea7ec35eaf76b5bf8647ca61a)
This commit is contained in:
parent
a6841c7f12
commit
a1d8e9d30f
|
@ -540,8 +540,7 @@ def humbug_to_zephyr(options):
|
||||||
logger.info("Starting syncing messages.")
|
logger.info("Starting syncing messages.")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
humbug_client.call_on_each_message(maybe_forward_to_zephyr,
|
humbug_client.call_on_each_message(maybe_forward_to_zephyr)
|
||||||
options={"mirror": 'zephyr_mirror'})
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Error syncing messages:")
|
logger.exception("Error syncing messages:")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
|
@ -294,7 +294,7 @@ def get_old_messages_backend(request, anchor = POST(converter=to_non_negative_in
|
||||||
def json_get_updates(request, user_profile, handler):
|
def json_get_updates(request, user_profile, handler):
|
||||||
client_id = request.session.session_key
|
client_id = request.session.session_key
|
||||||
return get_updates_backend(request, user_profile, handler, client_id,
|
return get_updates_backend(request, user_profile, handler, client_id,
|
||||||
apply_markdown=True)
|
client=request._client, apply_markdown=True)
|
||||||
|
|
||||||
@asynchronous
|
@asynchronous
|
||||||
@authenticated_api_view
|
@authenticated_api_view
|
||||||
|
@ -303,13 +303,13 @@ def api_get_messages(request, user_profile, handler, client_id=POST(default=None
|
||||||
apply_markdown=POST(default=False, converter=simplejson.loads)):
|
apply_markdown=POST(default=False, converter=simplejson.loads)):
|
||||||
return get_updates_backend(request, user_profile, handler, client_id,
|
return get_updates_backend(request, user_profile, handler, client_id,
|
||||||
apply_markdown=apply_markdown,
|
apply_markdown=apply_markdown,
|
||||||
mirror=request.POST.get("mirror"))
|
client=request._client)
|
||||||
|
|
||||||
def format_updates_response(messages=[], apply_markdown=True,
|
def format_updates_response(messages=[], apply_markdown=True,
|
||||||
user_profile=None, new_pointer=None,
|
user_profile=None, new_pointer=None,
|
||||||
mirror=None, update_types=[]):
|
client=None, update_types=[]):
|
||||||
if mirror is not None:
|
if client is not None and client.name.endswith("_mirror"):
|
||||||
messages = [m for m in messages if m.sending_client.name != mirror]
|
messages = [m for m in messages if m.sending_client.name != client.name]
|
||||||
ret = {'messages': [message.to_dict(apply_markdown) for message in messages],
|
ret = {'messages': [message.to_dict(apply_markdown) for message in messages],
|
||||||
"result": "success",
|
"result": "success",
|
||||||
"msg": "",
|
"msg": "",
|
||||||
|
@ -357,9 +357,9 @@ def return_messages_immediately(user_profile, client_id, last,
|
||||||
# to forward is one that was sent via the mirroring, the API
|
# to forward is one that was sent via the mirroring, the API
|
||||||
# client will end up in an endless loop requesting more data from
|
# client will end up in an endless loop requesting more data from
|
||||||
# us.
|
# us.
|
||||||
if "mirror" in kwargs:
|
if "client" in kwargs and kwargs["client"].name.endswith("_mirror"):
|
||||||
messages = [m for m in messages if
|
messages = [m for m in messages if
|
||||||
m.sending_client.name != kwargs["mirror"]]
|
m.sending_client.name != kwargs["client"].name]
|
||||||
|
|
||||||
update_types = []
|
update_types = []
|
||||||
if messages:
|
if messages:
|
||||||
|
|
Loading…
Reference in New Issue