Example #1
0
                             inbound=(len(argv) > 1 and argv[1] == 'incoming'),
                             type="text")

for a in range(int(form.getfirst('NumMedia') or 0)):
    content_type = form.getfirst('MediaContentType%d' % a)
    content_url = form.getfirst('MediaUrl%d' % a)
    if content_url:
        media = Attachment.create(sid='%s-%d' % (event.sid, a),
                                  url=content_url,
                                  mime_type=content_type,
                                  event=event)

if event.conversation.peer.blocked:
    # TODO: make this do something useful
    event.status = 'rejected'
    event.save()
    sys.exit()

if argv[1] == 'incoming':
    for n in user.notifications.where(Notification.notify_sms == True):
        try:
            # TODO notify at the conversation level, so multiple messages don't send multiple emails
            control.notify(event, n)
        except:
            logger.exception("Got error trying to notify on SMS")

print """Content-type: text/xml;charset=utf-8

<Response></Response>
"""
Example #2
0
            config.configuration["root-url"],
            transcribeTag,
        )

if not responseBody and state == "post-vm":
    notifyQuery = user.notifications.where(Notification.notify_voicemail == True)
    # give the transcription service a chance to transcribe before notifying
    if event.inbox.transcribe_voicemail and form.getfirst("RecordingDuration"):
        notifyDelay = 60 + int(form.getfirst("RecordingDuration"))
    responseBody = "<Say>Your voicemail has been recorded. Thank you.</Say>"

if not responseBody:
    responseBody = "<Say>An unknown error occurred. Please try again later. (state=%s)</Say>" % state

logger.info("notifyDelay=%d", notifyDelay or 0)
for n in notifyQuery:
    try:
        control.notify(event, n, notifyDelay)
    except:
        logger.exception("Got error trying to notify on call")


print """\
Content-type: text/xml;charset=utf-8

"""

print "<Response>"
print responseBody
print "</Response>"
Example #3
0
            transcribeTag = ' transcribe="true" transcribeCallback="transcribed"'
        responseBody += '<Record action="%s/voice.py/post-vm" maxLength="240"%s />' % (
            config.configuration['root-url'], transcribeTag)

if not responseBody and state == 'post-vm':
    notifyQuery = user.notifications.where(
        Notification.notify_voicemail == True)
    # give the transcription service a chance to transcribe before notifying
    if event.inbox.transcribe_voicemail and form.getfirst('RecordingDuration'):
        notifyDelay = 60 + int(form.getfirst('RecordingDuration'))
    responseBody = '<Say>Your voicemail has been recorded. Thank you.</Say>'

if not responseBody:
    responseBody = '<Say>An unknown error occurred. Please try again later. (state=%s)</Say>' % state

logger.info("notifyDelay=%d", notifyDelay or 0)
for n in notifyQuery:
    try:
        control.notify(event, n, notifyDelay)
    except:
        logger.exception("Got error trying to notify on call")

print """\
Content-type: text/xml;charset=utf-8

"""

print '<Response>'
print responseBody
print '</Response>'
Example #4
0
                             inbound=(len(argv) > 1 and argv[1] == 'incoming'),
                             type="text")

for a in range(int(form.getfirst('NumMedia') or 0)):
    content_type = form.getfirst('MediaContentType%d' % a)
    content_url = form.getfirst('MediaUrl%d' % a)
    if content_url:
        media = Attachment.create(sid='%s-%d' % (event.sid, a),
                                  url=content_url,
                                  mime_type=content_type,
                                  event=event)

if event.conversation.peer.blocked:
    # TODO: make this do something useful
    event.status = 'rejected'
    event.save()
    sys.exit()

if argv[1] == 'incoming':
    for n in user.notifications.where(Notification.notify_sms == True):
        try:
            # TODO notify at the conversation level, so multiple messages don't send multiple emails
            control.notify(event, n)
        except:
            logger.exception("Got error trying to notify on SMS")

print """Content-type: text/xml;charset=utf-8

<Response></Response>
"""