Пример #1
0
    def notify_to_parents(self, alias, location, mobile, region_id=None):
        """Push information to clinet through push.

        PUSH 1.0
        """
        flag = self.check_timestamp(int(location['timestamp']))
        if not flag: 
            return

        category = location.category
        dev_id = location.dev_id

        if not location['pbat']:
            terminal = QueryHelper.get_terminal_info(dev_id, self.db, self.redis) 
            location['pbat'] = terminal['pbat'] if terminal['pbat'] is not None else 0 

        if mobile:
            # 1: push to android
            android_push_list_key = get_android_push_list_key(mobile) 
            android_push_list = self.redis.getvalue(android_push_list_key) 
            if android_push_list: 
                for push_id in android_push_list: 
                    push_key = NotifyHelper.get_push_key(push_id, self.redis) 
                    NotifyHelper.push_to_android(category, dev_id, alias, location, push_id, push_key, region_id)
            # 2: push  to ios 
            ios_push_list_key = get_ios_push_list_key(mobile) 
            ios_push_list = self.redis.getvalue(ios_push_list_key) 
            if ios_push_list: 
                for ios_id in ios_push_list: 
                    ios_badge = NotifyHelper.get_iosbadge(ios_id, self.redis) 
                    NotifyHelper.push_to_ios(category, dev_id, alias, location, ios_id, ios_badge, region_id)