mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
already_sent_mirrored_message: Clean up query
No need for an 'if' if we're just returning a boolean. And using QuerySet.exists() should be a little more efficient. (imported from commit 69ec3cc9f2fe904ec40ea3b8a8687a06cd03f3f3)
This commit is contained in:
@@ -497,12 +497,11 @@ def already_sent_mirrored_message(request):
|
||||
utc_from_ts = datetime.datetime.utcfromtimestamp
|
||||
req_time = float(request.POST['time'])
|
||||
email = request.POST['sender'].lower()
|
||||
if Message.objects.filter(sender__user__email=email,
|
||||
return Message.objects.filter(
|
||||
sender__user__email=email,
|
||||
content=request.POST['content'],
|
||||
pub_date__gt=utc_from_ts(req_time - 10).replace(tzinfo=utc),
|
||||
pub_date__lt=utc_from_ts(req_time + 10).replace(tzinfo=utc)):
|
||||
return True
|
||||
return False
|
||||
pub_date__lt=utc_from_ts(req_time + 10).replace(tzinfo=utc)).exists()
|
||||
|
||||
# Validte that the passed in object is an email address from the user's realm
|
||||
# TODO: Check that it's a real email address here.
|
||||
|
||||
Reference in New Issue
Block a user