def confirm_friend(): userid = request.form.get('id') user = User.query.filter_by(id=userid).first() if user is not None: # if not in the friendlist if g.current_user.add_friend(user): result = client.message_system_publish( from_user_id=g.current_user.id, to_user_id=userid, object_name='RC:ContactNtf', content=json.dumps({"message": u"已成功添加为好友", "sourceUserId":g.current_user.id,"targetUserId":userid}), push_content='confirm', push_data='confirm' ) return jsonify({ 'status':result[u'code'] }) else: return jsonify({ 'status':408, }) else: return jsonify({ 'status':404 })
def send_request_to_peer(id_from, id_to, pushcontent): return client.message_system_publish( from_user_id=id_from, to_user_id=id_to, object_name='RC:ContactNtf', content=json.dumps({"message": u"好友请求:" + pushcontent, "sourceUserId":id_from,"targetUserId":id_to}), push_content='send add friend request', push_data='send add friend request')
def send_request_to_admin(id_from, id_to,classid,pushcontent): if pushcontent is None : pushcontent = 'send enroll request' return client.message_system_publish( from_user_id=id_from, to_user_id=id_to, object_name='RC:ContactNtf', content=json.dumps({"message": u"加入班级请求:" + pushcontent, "sourceUserId":id_from,"targetUserId":id_to,"operation":"add","extra":classid}), push_content= pushcontent, push_data= pushcontent)