mirror of https://github.com/zulip/zulip.git
Avoid excessive feedback ticket headers.
(imported from commit 84eb0945e23f670f4d343672dc5589a1867926d6)
This commit is contained in:
parent
73a05d52f5
commit
4477ee4bba
|
@ -15,9 +15,11 @@ from zilencer.forms import EnterpriseToSForm
|
||||||
from error_notify import notify_server_error, notify_browser_error
|
from error_notify import notify_server_error, notify_browser_error
|
||||||
from django.core.mail import send_mail
|
from django.core.mail import send_mail
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
import time
|
||||||
|
|
||||||
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
|
rest_dispatch = csrf_exempt((lambda request, *args, **kwargs: _rest_dispatch(request, globals(), *args, **kwargs)))
|
||||||
|
|
||||||
|
FEEDBACK_USER_TIMES = {}
|
||||||
|
|
||||||
def get_ticket_number():
|
def get_ticket_number():
|
||||||
fn = '/var/tmp/.feedback-bot-ticket-number'
|
fn = '/var/tmp/.feedback-bot-ticket-number'
|
||||||
|
@ -38,18 +40,26 @@ def submit_feedback(request, deployment, message=REQ(converter=json_to_dict)):
|
||||||
if len(subject) > 60:
|
if len(subject) > 60:
|
||||||
subject = subject[:57].rstrip() + "..."
|
subject = subject[:57].rstrip() + "..."
|
||||||
|
|
||||||
|
content = ''
|
||||||
|
sender_email = message['sender_email']
|
||||||
|
t = time.time()
|
||||||
|
|
||||||
ticket_number = get_ticket_number()
|
# We generate ticket numbers if it's been more than a few minutes
|
||||||
content = '\n~~~'
|
# since their last message. This avoids some noise when people use
|
||||||
content += '\nticket Z%03d (@support please ack)' % (ticket_number,)
|
# enter-send.
|
||||||
content += '\nsender: %s' % (message['sender_full_name'],)
|
if t - FEEDBACK_USER_TIMES.get(sender_email, 0) > 180:
|
||||||
content += '\nemail: %s' % (message['sender_email'],)
|
ticket_number = get_ticket_number()
|
||||||
if 'sender_domain' in message:
|
content += '\n~~~'
|
||||||
content += '\nrealm: %s' % (message['sender_domain'],)
|
content += '\nticket Z%03d (@support please ack)' % (ticket_number,)
|
||||||
content += '\n~~~'
|
content += '\nsender: %s' % (message['sender_full_name'],)
|
||||||
|
content += '\nemail: %s' % (sender_email,)
|
||||||
|
if 'sender_domain' in message:
|
||||||
|
content += '\nrealm: %s' % (message['sender_domain'],)
|
||||||
|
content += '\n~~~'
|
||||||
|
content += '\n\n'
|
||||||
|
|
||||||
content += '\n\n'
|
|
||||||
content += message['content']
|
content += message['content']
|
||||||
|
FEEDBACK_USER_TIMES[sender_email] = t
|
||||||
|
|
||||||
internal_send_message("feedback@zulip.com", "stream", "support", subject, content)
|
internal_send_message("feedback@zulip.com", "stream", "support", subject, content)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue