mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 08:56:10 +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 zephyr_backend(request, request.user)
|
||||
|
||||
huddle_dedup = {}
|
||||
|
||||
@login_required
|
||||
@require_post
|
||||
def forge_zephyr(request):
|
||||
@@ -192,15 +190,12 @@ def forge_zephyr(request):
|
||||
|
||||
if (request.POST['type'] == 'personal' and ',' in request.POST['recipient']):
|
||||
# Huddle message, need to make sure we're not syncing it twice!
|
||||
huddle_val = hashlib.md5(request.POST['sender'] + "|" +
|
||||
request.POST['new_zephyr'] + "|" +
|
||||
request.POST['time']).hexdigest()
|
||||
if huddle_val in huddle_dedup:
|
||||
if Zephyr.objects.filter(sender=request.POST['sender'],
|
||||
content=request.POST['new_zephyr'],
|
||||
time=request.POST['time']):
|
||||
# This is a duplicate huddle message, deduplicate!
|
||||
return json_success()
|
||||
|
||||
huddle_dedup[huddle_val] = True
|
||||
|
||||
# Now confirm all the other recipients exist in our system
|
||||
for user_email in request.POST["recipient"].split(","):
|
||||
try:
|
||||
|
||||
@@ -192,7 +192,7 @@ def zephyr_to_humbug(options):
|
||||
def get_zephyrs(last_received):
|
||||
browser.addheaders.append(('X-CSRFToken', csrf_token))
|
||||
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()])
|
||||
res = browser.open("https://app.humbughq.com/get_updates_longpoll", submit_data)
|
||||
return simplejson.loads(res.read())['zephyrs']
|
||||
|
||||
Reference in New Issue
Block a user