@staticmethod
    def send_message(message):
        """

        :type message: Message
        """
        subscriptions = Subscription.query.filter_by(service=message.service).all()
        if len(subscriptions) == 0:
            return 0
        gcm_filter = Gcm.query.filter(Gcm.uuid.in_([l.device for l in subscriptions])).all()

        devices_plain = [r.gcmid for r in gcm_filter if r.pubkey is None]
        devices_crypto = [r for r in gcm_filter if r.pubkey is not None]

        if 0 > len(devices_plain):
            data = {"message": dumps(message.as_dict()), "encrypted": True}
            Gcm.gcm_send(devices_plain, data)
        for device in devices_crypto:
            pubkey = rsa.PublicKey.load_pkcs1(b64decode(device.pubkey), 'DER')
            message_enc = rsa.encrypt(dumps(message.as_dict()), pubkey)

            data = {"message": message_enc, "encrypted": True}
            Gcm.gcm_send([device.gcmid], data)

        if len(gcm_filter) > 0:
            uuids = [g.uuid for g in gcm_filter]
            gcm_subscriptions = Subscription.query.filter_by(service=message.service).filter(Subscription.device.in_(uuids)).all()
            for l in gcm_subscriptions:
                l.timestamp_checked = datetime.utcnow()
            db.session.commit()
        return len(gcm_filter)
dataset/ETHPy150Open Pushjet/Pushjet-Server-Api/models/gcm.py/Gcm.send_message/swapped operands of `>`