Example #1
0
    def dispatch_request(self):

        message = json.loads(request.args['message'])

        if message:
            smska = PhoneSMS(phone=message["from"], message=message["msg"])

            sms_data = parse_sms(message["msg"])

            smska.smstype = "recv"
            smska.state = "recv"

            waiting_ticket = self.get_waiting_ticket(sms_data)

            if waiting_ticket:
                waiting_ticket.valid_until = sms_data["valid_until"]
                waiting_ticket.valid_from = sms_data["valid_from"]
                waiting_ticket.price = sms_data["price"]
                waiting_ticket.code = sms_data["code"]

                ss = SmsSender()
                smsid = ss.sendSms(waiting_ticket.phone,
                                   get_prepared_sms_for_ticket(waiting_ticket))
                waiting_ticket.sms_sender_id = smsid

            db_session.add(smska)
            db_session.commit()

        # print(message)

        return "inbox_view"
Example #2
0
def getSmsStatus():
    smsId = request.args.get('smsid')
    if smsId:
        ss = SmsSender()
        resp = ss.getSmsStatus(smsId)
        return jsonify({'status': resp['status']})
    else:
        return 'no smsid'
Example #3
0
def lastSentSms():
    ss = SmsSender()
    lastsmses = ss.getLastSsmses()
    return render_template('lastsentsms.html', lastsmses=lastsmses)
Example #4
0
def bbSmsDelivery():
    ss = SmsSender()
    ss.saveDeliveryStatus(request.args)
    return 'ok'
Example #5
0
def bbSendSms():
    ss = SmsSender()
    if request.args.get('n'):
        ss.sendSms(request.args.get('n'), request.args.get('m', 'nic'))
    return 'ok'