mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
Hopefully fix huddle message deduplication with MIT sync.
(imported from commit bccaa67d02e72b1c444d39b019d5bd87800b1441)
This commit is contained in:
@@ -170,8 +170,6 @@ def zephyr(request):
|
|||||||
return json_error("Invalid field 'time'")
|
return json_error("Invalid field 'time'")
|
||||||
return zephyr_backend(request, request.user)
|
return zephyr_backend(request, request.user)
|
||||||
|
|
||||||
huddle_dedup = {}
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
@require_post
|
@require_post
|
||||||
def forge_zephyr(request):
|
def forge_zephyr(request):
|
||||||
@@ -192,15 +190,12 @@ def forge_zephyr(request):
|
|||||||
|
|
||||||
if (request.POST['type'] == 'personal' and ',' in request.POST['recipient']):
|
if (request.POST['type'] == 'personal' and ',' in request.POST['recipient']):
|
||||||
# Huddle message, need to make sure we're not syncing it twice!
|
# Huddle message, need to make sure we're not syncing it twice!
|
||||||
huddle_val = hashlib.md5(request.POST['sender'] + "|" +
|
if Zephyr.objects.filter(sender=request.POST['sender'],
|
||||||
request.POST['new_zephyr'] + "|" +
|
content=request.POST['new_zephyr'],
|
||||||
request.POST['time']).hexdigest()
|
time=request.POST['time']):
|
||||||
if huddle_val in huddle_dedup:
|
|
||||||
# This is a duplicate huddle message, deduplicate!
|
# This is a duplicate huddle message, deduplicate!
|
||||||
return json_success()
|
return json_success()
|
||||||
|
|
||||||
huddle_dedup[huddle_val] = True
|
|
||||||
|
|
||||||
# Now confirm all the other recipients exist in our system
|
# Now confirm all the other recipients exist in our system
|
||||||
for user_email in request.POST["recipient"].split(","):
|
for user_email in request.POST["recipient"].split(","):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ def zephyr_to_humbug(options):
|
|||||||
def get_zephyrs(last_received):
|
def get_zephyrs(last_received):
|
||||||
browser.addheaders.append(('X-CSRFToken', csrf_token))
|
browser.addheaders.append(('X-CSRFToken', csrf_token))
|
||||||
submit_hash = {'last_received': last_received,
|
submit_hash = {'last_received': last_received,
|
||||||
"mit_sync_bot": True}
|
"mit_sync_bot": 'yes'}
|
||||||
submit_data = urllib.urlencode([(k, v.encode('utf-8')) for k,v in submit_hash.items()])
|
submit_data = urllib.urlencode([(k, v.encode('utf-8')) for k,v in submit_hash.items()])
|
||||||
res = browser.open("https://app.humbughq.com/get_updates_longpoll", submit_data)
|
res = browser.open("https://app.humbughq.com/get_updates_longpoll", submit_data)
|
||||||
return simplejson.loads(res.read())['zephyrs']
|
return simplejson.loads(res.read())['zephyrs']
|
||||||
|
|||||||
Reference in New Issue
Block a user