示例#1
0
    def post(self):
        self._require_login()
        self._require_registration()

        # Check to make sure that they aren't trying to edit another user
        current_user_account_id = self.user_bundle.account.key.id()
        target_account_id = self.request.get('account_id')
        if target_account_id == current_user_account_id:
            client_id = self.request.get('client_id')
            client = MobileClient.get_by_id(int(client_id),
                                            parent=ndb.Key(
                                                Account,
                                                current_user_account_id))
            if client is not None:
                # This makes sure that the client actually exists and that this user owns it
                if client.client_type == ClientType.WEBHOOK:
                    keys = {
                        client.client_type:
                        [(client.messaging_id, client.secret)]
                    }
                else:
                    keys = {client.client_type: [client.messaging_id]}
                notification = PingNotification()
                notification.send(keys)
            self.redirect('/account')
        else:
            self.redirect('/')
 def send_ping(cls, client):
     if client.client_type == ClientType.OS_ANDROID:
         notification = PingNotification()
         notification.send({client.client_type: [client.messaging_id]})
     else:
         # Send iOS/web/webhooks ping via TBANS
         return TBANSHelper.ping(client)
    def send_ping(cls, client):
        if client.client_type == ClientType.WEBHOOK:
            keys = {client.client_type: [(client.messaging_id, client.secret)]}
        else:
            keys = {client.client_type: [client.messaging_id]}

        notification = PingNotification()
        notification.send(keys)
示例#4
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        self.testbed.init_taskqueue_stub(root_path=".")

        self.notification = PingNotification()
示例#5
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        # User a Ping notification to test the render and send classes
        # It's as simple as it gets
        self.notification = PingNotification()
        self.keys = {ClientType.OS_ANDROID: ["abc123"], ClientType.WEBHOOK: ["123abc"]}
        self.notification.keys = self.keys
示例#6
0
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()
        self.testbed.init_datastore_v3_stub()
        self.testbed.init_memcache_stub()
        ndb.get_context().clear_cache()  # Prevent data from leaking between tests

        self.testbed.init_taskqueue_stub(root_path=".")

        self.notification = PingNotification()
示例#7
0
    def get(self):
        webhooks = MobileClient.query(MobileClient.client_type == ClientType.WEBHOOK).fetch()
        failures = []

        notification = PingNotification()._render_webhook()

        for key in webhooks:
            if not NotificationSender.send_webhook(notification, [(key.messaging_id, key.secret)]):
                failures.append(key.key)

        count = len(failures)
        if failures:
            ndb.delete_multi(failures)
        logging.info("Deleted {} broken webhooks".format(count))

        template_values = {'count': count}
        path = os.path.join(os.path.dirname(__file__), '../../templates/admin/webhooks_clear_do.html')
        self.response.out.write(template.render(path, template_values))
    def setUp(self):
        self.testbed = testbed.Testbed()
        self.testbed.activate()

        self.notification = PingNotification()