Provide more info in support requests.

Have the Feedback Bot provide the sender's full name.
Put the email in the message to help searching.
Generate a ticket number to make it easier to refer to the message from
elsewhere.

(imported from commit 4d789135a0097bade50b4d980f49ca596d85b73b)
This commit is contained in:
Steve Howell 2013-10-06 13:27:15 -04:00
parent a283cae098
commit 989ea5ffbc

View file

@ -45,20 +45,44 @@ staging_client = zulip.Client(
verbose=True, verbose=True,
site="https://staging.zulip.com/api") site="https://staging.zulip.com/api")
def get_ticket_number():
fn = '/var/tmp/.feedback-bot-ticket-number'
try:
ticket_number = int(open(fn).read()) + 1
except:
ticket_number = 1
open(fn, 'w').write('%d' % ticket_number)
return ticket_number
def forward_message(message): def forward_message(message):
if message["type"] != "private" or len(message["display_recipient"]) != 2: if message["type"] != "private" or len(message["display_recipient"]) != 2:
return return
if "sender_domain" in message: if "sender_domain" in message:
subject = "feedback: %s (%s)" % (message["sender_email"], message["sender_domain"]) subject = "feedback: %s (%s)" % (message["sender_email"], message["sender_domain"])
else: else:
subject = "feedback from %s" % message["sender_email"], subject = "feedback from %s" % message["sender_email"],
if len(subject) > 60: if len(subject) > 60:
subject = subject[:57].rstrip() + "..." subject = subject[:57].rstrip() + "..."
ticket_number = get_ticket_number()
content = '@support, Please ack this new request.'
content += '\n~~~'
content += '\nticket Z%03d' % (ticket_number,)
content += '\nsender: %s' % (message['sender_full_name'],)
content += '\nemail: %s' % (message['sender_email'],)
if 'sender_domain' in message:
content += '\nrealm: %s' % (message['sender_domain'],)
content += '\n~~~'
content += '\n\n'
content += message['content']
forwarded_message = { forwarded_message = {
"type": "stream", "type": "stream",
"to": "support", "to": "support",
"subject": subject, "subject": subject,
"content": message["content"], "content": content,
} }
staging_client.send_message(forwarded_message) staging_client.send_message(forwarded_message)
logging.info("Forwarded feedback from %s" % (message["sender_email"],)) logging.info("Forwarded feedback from %s" % (message["sender_email"],))