예제 #1
0
    def testMappingQueries(self):
        import emission.core.wrapper.user as ecwu

        self.test_email_1 = "test_push_1"
        self.test_email_2 = "test_push_2"
        try:
            user_1 = ecwu.User.register(self.test_email_1)
            user_2 = ecwu.User.register(self.test_email_2)
            user_1.update({
                "curr_platform": "ios",
                "curr_sync_interval": 3600,
                "device_token": "ios_device_token"
            })
            user_2.update({
                "curr_platform": "android",
                "curr_sync_interval": 3600,
                "device_token": "android_device_token"
            })

            uuid_token_list = pnq.get_matching_tokens(
                pnq.get_user_query([user_1.uuid, user_2.uuid]))
            self.assertEqual(uuid_token_list,
                             ["ios_device_token", "android_device_token"])

            platform_token_list = pnq.get_matching_tokens(
                pnq.get_platform_query("ios"))
            self.assertEqual(platform_token_list, ["ios_device_token"])
        finally:
            ecwu.User.unregister(self.test_email_1)
            ecwu.User.unregister(self.test_email_2)
예제 #2
0
def send_silent_notification_to_ios_with_interval(interval, dev=False):
    query = pnq.combine_queries(
        [pnq.get_platform_query("ios"),
         pnq.get_sync_interval_query(interval)])
    token_map = pnq.get_matching_tokens(query)
    logging.debug("found %d tokens for ios with interval %d" %
                  (len(token_map), interval))
    return __get_default_interface__().send_silent_notification(
        token_map, {}, dev)
예제 #3
0
    def testMappingQueries(self):
        import emission.core.wrapper.user as ecwu

        self.test_email_1 = "test_push_1"
        self.test_email_2 = "test_push_2"
        try:
            user_1 = ecwu.User.register(self.test_email_1)
            user_2 = ecwu.User.register(self.test_email_2)
            user_1.update({"curr_platform": "ios", "curr_sync_interval": 3600,
                "device_token": "ios_device_token"})
            user_2.update({"curr_platform": "android", "curr_sync_interval": 3600,
                "device_token": "android_device_token"})

            uuid_token_list = pnq.get_matching_tokens(pnq.get_user_query([user_1.uuid, user_2.uuid]))
            self.assertEqual(uuid_token_list, ["ios_device_token", "android_device_token"])
            
            platform_token_list = pnq.get_matching_tokens(pnq.get_platform_query("ios"))
            self.assertEqual(platform_token_list, ["ios_device_token"])
        finally:
            ecwu.User.unregister(self.test_email_1)
            ecwu.User.unregister(self.test_email_2)
예제 #4
0
def query(spec):
    platform = spec['platform']
    userid_list = pnq.get_matching_user_ids(pnq.get_platform_query(platform))
    return userid_list
예제 #5
0
def send_silent_notification_to_ios_with_interval(interval, dev=False):
    query = pnq.combine_queries([pnq.get_platform_query("ios"),
                                 pnq.get_sync_interval_query(interval)])
    token_map = pnq.get_matching_tokens(query)
    logging.debug("found %d tokens for ios with interval %d" % (len(token_map), interval))
    return __get_default_interface__().send_silent_notification(token_map, {}, dev)
예제 #6
0
        action="store_true",
        help="send a silent push notification. title and message are ignored")
    group = parser.add_mutually_exclusive_group(required=True)
    group.add_argument("-e", "--user_email", nargs="+")
    group.add_argument("-u", "--user_uuid", nargs="+")
    group.add_argument("-p", "--platform")
    group.add_argument("-a", "--all", action="store_true")
    parser.add_argument("-d", "--dev", action="store_true", default=False)

    args = parser.parse_args()

    if args.user_uuid:
        uuid_list = [uuid.UUID(uuid_str) for uuid_str in args.user_uuid]
    elif args.platform:
        uuid_list = pnq.get_matching_user_ids(
            pnq.get_platform_query(args.platform))
    elif args.all:
        uuid_list = esdu.get_all_uuids()
    else:
        uuid_list = [
            ecwu.User.fromEmail(uuid_str).uuid for uuid_str in args.user_email
        ]
    logging.info("After parsing, uuid list = %s" % uuid_list)

    if (args.silent):
        response = pnu.send_silent_notification_to_users(uuid_list, {},
                                                         dev=args.dev)
    else:
        json_data = {
            "title": args.title_message[0],
            "message": args.title_message[1]
예제 #7
0
def query(spec):
  platform = spec['platform']
  userid_list = pnq.get_matching_user_ids(pnq.get_platform_query(platform))
  return userid_list