示例#1
0
def push_customer_support_message(appid, appname, u, content, extra):
    receiver = u.uid
    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.ali_timestamp, u.jp_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        sound = 'default'
        alert = content
        badge = u.unread + 1
        content_available = 1
        IOSPush.push(appid, u.apns_device_token, alert, sound, badge,
                     content_available, extra)
        user.set_user_unread(rds, appid, receiver, u.unread + 1)
    elif u.ng_device_token and u.ng_timestamp == ts:
        android_push(appid, appname, u.ng_device_token, content, extra)
    elif u.xg_device_token and u.xg_timestamp == ts:
        xg_push(appid, appname, u.xg_device_token, content, extra)
    elif u.mi_device_token and u.mi_timestamp == ts:
        MiPush.push(appid, appname, u.mi_device_token, content)
    elif u.hw_device_token and u.hw_timestamp == ts:
        HuaWeiPush.push(appid, appname, u.hw_device_token, content)
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.ali_device_token and u.ali_timestamp == ts:
        AliPush.push(appid, appname, u.ali_device_token, content)
        #通过透传消息通知app有新消息到达
        content = json.dumps({"xiaowei": {"new": 1}})
        AliPush.push_message(appid, appname, u.ali_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, u.jp_device_token, content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#2
0
def push_message_u(appid, appname, u, content, extra, collapse_id=None):
    receiver = u.uid
    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.ali_timestamp, u.jp_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        sound = 'default'
        IOSPush.push(appid,
                     u.apns_device_token,
                     content,
                     sound=sound,
                     badge=u.unread + 1,
                     extra=extra,
                     collapse_id=collapse_id)
        user.set_user_unread(rds, appid, receiver, u.unread + 1)
    elif u.ng_device_token and u.ng_timestamp == ts:
        android_push(appid, appname, u.ng_device_token, content, extra)
    elif u.xg_device_token and u.xg_timestamp == ts:
        xg_push(appid, appname, u.xg_device_token, content, extra)
    elif u.mi_device_token and u.mi_timestamp == ts:
        MiPush.push(appid, appname, u.mi_device_token, content)
    elif u.hw_device_token and u.hw_timestamp == ts:
        HuaWeiPush.push(appid, appname, u.hw_device_token, content)
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.ali_device_token and u.ali_timestamp == ts:
        AliPush.push(appid, appname, u.ali_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, u.jp_device_token, content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#3
0
def handle_system_message(msg):
    obj = json.loads(msg)
    appid = obj["appid"]
    receiver = obj["receiver"]
    body = obj["content"]

    appname = config.APPNAME

    u = User.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    content = system_message_content(body)
    if not content:
        logging.info("can't push system message:%s", msg)
        return

    
    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, 
             u.mi_timestamp, u.hw_timestamp, u.gcm_timestamp, u.jp_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        sound = "apns.caf"
        IOSPush.push(appid, u.apns_device_token, content, u.unread, sound, {})
        User.set_user_unread(rds, appid, receiver, u.unread+1)
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, [u.jp_device_token], content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#4
0
def handle_system_message(msg):
    obj = json.loads(msg)
    appid = obj["appid"]
    receiver = obj["receiver"]
    body = obj["content"]

    appname = config.APPNAME

    u = User.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    content = system_message_content(body)
    if not content:
        logging.info("can't push system message:%s", msg)
        return

    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.jp_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        sound = "apns.caf"
        IOSPush.push(appid, u.apns_device_token, content, u.unread, sound, {})
        User.set_user_unread(rds, appid, receiver, u.unread + 1)
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, [u.jp_device_token], content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#5
0
def handle_voip_message(msg):
    obj = json.loads(msg)
    appid = obj["appid"]
    sender = obj["sender"]
    receiver = obj["receiver"]

    sender_name = User.get_user_name(rds, appid, sender)
    u = User.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, 
             u.mi_timestamp, u.hw_timestamp, u.gcm_timestamp, u.jp_timestamp)

    if sender_name:
        sender_name = sender_name.decode("utf8")
        content = "%s:%s"%(sender_name, u"请求与你通话")
    else:
        content = u"你的朋友请求与你通话"

    appname = config.APPNAME
    if u.apns_device_token and u.apns_timestamp == ts:
        sound = "apns.caf"
        badge = u.unread
        IOSPush.push(appid, u.apns_device_token, content, badge, sound, {})
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, [u.jp_device_token], content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#6
0
def handle_voip_message(msg):
    obj = json.loads(msg)
    appid = obj["appid"]
    sender = obj["sender"]
    receiver = obj["receiver"]

    sender_name = User.get_user_name(rds, appid, sender)
    u = User.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.jp_timestamp)

    if sender_name:
        sender_name = sender_name.decode("utf8")
        content = "%s:%s" % (sender_name, u"请求与你通话")
    else:
        content = u"你的朋友请求与你通话"

    appname = config.APPNAME
    if u.apns_device_token and u.apns_timestamp == ts:
        sound = "apns.caf"
        badge = u.unread
        IOSPush.push(appid, u.apns_device_token, content, badge, sound, {})
    elif u.gcm_device_token and u.gcm_timestamp == ts:
        GCMPush.push(appid, appname, u.gcm_device_token, content)
    elif u.jp_device_token and u.jp_timestamp == ts:
        JGPush.push(appid, appname, [u.jp_device_token], content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#7
0
def handle_system_message(msg):
    obj = json.loads(msg)
    appid = obj["appid"]
    receiver = obj["receiver"]

    appname = get_title(appid)
    try:
        content_obj = json.loads(obj.get('content'))
        voip_content = content_obj.get('voip_push')
        content = content_obj.get('push')
        if not voip_content and not content:
            return
        sound = content_obj.get('sound', 'default')
    except Exception as e:
        logging.info("exception:%s", e)
        return

    u = user.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.ali_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        if voip_content and u.pushkit_device_token:
            IOSPush.voip_push(appid, u.pushkit_device_token, voip_content)
        elif content:
            IOSPush.push(appid,
                         u.apns_device_token,
                         content,
                         sound=sound,
                         badge=u.unread + 1)
            user.set_user_unread(rds, appid, receiver, u.unread + 1)
        return

    if not content:
        return

    if u.mi_device_token and u.mi_timestamp == ts:
        MiPush.push_message(appid, u.mi_device_token, content)
    elif u.hw_device_token and u.hw_timestamp == ts:
        HuaWeiPush.push_message(appid, u.hw_device_token, content)
    else:
        logging.info("uid:%d has't device token", receiver)
示例#8
0
    u = user.get_user(rds, appid, receiver)
    if u is None:
        logging.info("uid:%d nonexist", receiver)
        return

    #找出最近绑定的token
    ts = max(u.apns_timestamp, u.xg_timestamp, u.ng_timestamp, u.mi_timestamp,
             u.hw_timestamp, u.gcm_timestamp, u.ali_timestamp)

    if u.apns_device_token and u.apns_timestamp == ts:
        if voip_content and u.pushkit_device_token:
            IOSPush.voip_push(appid, u.pushkit_device_token, voip_content)
        elif content:
            IOSPush.push(appid,
                         u.apns_device_token,
                         content,
                         sound=sound,
                         badge=u.unread + 1)
            user.set_user_unread(rds, appid, receiver, u.unread + 1)
        return

    if not content:
        return

    if u.mi_device_token and u.mi_timestamp == ts:
        MiPush.push_message(appid, u.mi_device_token, content)
    elif u.hw_device_token and u.hw_timestamp == ts:
        HuaWeiPush.push_message(appid, u.hw_device_token, content)
    elif u.ali_device_token and u.ali_timestamp == ts:
        AliPush.push_message(appid, appname, u.hw_device_token, content)
    else:
示例#9
0
def ios_push(appid, u, content):
    token = u.apns_device_token
    sound = "apns.caf"
    badge = 0

    IOSPush.push(appid, token, content, sound, badge)
示例#10
0
def ios_push(appid, token, content, badge, extra):
    sound = "default"
    alert = content
    IOSPush.push(appid, token, alert, sound, badge, extra)
示例#11
0
def ios_push(appid, token, content, badge, sound, extra):
    alert = content
    content_available = 0
    IOSPush.push(appid, token, alert, sound, badge, content_available, extra)
示例#12
0
def ios_push(appid, token, content, badge, extra):
    sound = "default"
    alert = content
    IOSPush.push(appid, token, alert, sound, badge, extra)
示例#13
0
def ios_push(appid, u, content):
    token = u.apns_device_token
    sound = "apns.caf"
    badge = 0

    IOSPush.push(appid, token, content, sound, badge)