def post(self): """Notify subscribers that a service changed status.""" address = self.request.get('address') service = Service.get(self.request.get('service')) oldstatus = Status.get(self.request.get('oldstatus')) number = self.request.get('number') logging.info("Service: %s" % service) logging.info("Service name: %s" % service.name) msg = "%s changed state from %s to %s (%s)" % ( service.name, oldstatus.name, service.current_event().status.name, service.current_event().message) user = Subscription.get_by_email(address) if user.status == "available" or not number: status_code = xmpp.send_message(address, msg) chat_message_sent = (status_code == xmpp.NO_ERROR) logging.info("Notified: %s\nmessage: %s code: %d" % (address, msg, status_code)) elif user.status == "unavailable" and number: sms = smsgw(to = number, msg = msg) sms.send() logging.info("Offline SMS: %s\nmessage: %s" % (number, msg))
def get(self): sms = smsgw(to = "+61431461200", msg = "AppEngine Test") sms.send()