Beispiel #1
0
    def post(self, params):
        # 查询用户uid
        user_id_relation_model = UserIdRelationModel.query_user_by_ease_mob_id(
            params["to_uid"])
        params[
            "to_uid"] = user_id_relation_model.user_id if user_id_relation_model else params[
                "to_uid"]

        params["chatfrom"] = g.account["user_id"]
        params["chatto"] = params["to_uid"]
        params["type"] = 1

        if params["msg_type"] == 2:
            json_data = {"image": params["image"]}
        elif params["msg_type"] == 3:
            json_data = {"audio": params["audio"]}
        elif params["msg_type"] == 4:
            json_data = {"video": params["video"]}
        else:
            json_data = {}
        if json_data:
            params["json_data"] = json.dumps(json_data)

        im_model = IMMsgModel(params=params)
        return json_success_response(im_model.to_dict())
Beispiel #2
0
    def get(self, params):
        login_user_id = g.account["user_id"]

        RedisModel.reset_new_message(login_user_id, RedisModel.new_visitor)

        visitor_list = list()
        while not visitor_list:
            visitor_list = VisitorRecordModel.query_visitor_list_by_day(
                login_user_id, 20, params["last_id"])
            params["last_id"] += 1

            # 最多查询30天
            if params["last_id"] > 30:
                break

        visitor_dict_list = list()
        for visitor in visitor_list:
            item = dict()
            user_info = UserInfoModel.query_user_model_by_id(
                visitor.visitor_user_id)
            item["user_info"] = UserInfoModel.format_user_info(
                user_info) if user_info else {}
            item["time"] = visitor.created_time
            visitor_dict_list.append(item)

        return json_success_response({
            "last_id": params["last_id"],
            "list": visitor_dict_list
        })
Beispiel #3
0
    def get(self, params):
        login_user_id = g.account["user_id"]

        is_self = params["user_id"] == login_user_id

        share_model_list = ShareModel.query_user_share_list(
            params["user_id"] if not is_self else None,
            login_user_id if is_self else 0, 20, params["last_id"])
        result = ShareModel.format_share_model(share_model_list, login_user_id)
        return json_success_response(result)
Beispiel #4
0
    def get(self, params):

        user_id = g.account["user_id"]

        follow_user_id_list = FollowModel.query_follow_user_list(user_id)
        follow_user_id_list = list(set(follow_user_id_list))
        share_model_list = ShareModel.query_user_share_list(
            follow_user_id_list, user_id, 20, params["last_id"], 0)
        share_info_list = ShareModel.format_share_model(
            share_model_list, user_id)
        return json_success_response(share_info_list)
    def post(self, params):

        result = UserBlackModel.update_black_status(g.account["user_id"],
                                                    params["black_user_id"],
                                                    params["status"])

        if not result:
            return json_fail_response(2110)

        UserBlackModel.query_black_people(g.account["user_id"], True)

        return json_success_response(result)
Beispiel #6
0
    def get(self, params):
        pri_img_model = ImageModel.query.filter_by(user_id=params["user_id"],
                                                   type=11,
                                                   status=1).first()
        pri_video_model = None

        result = dict()
        result["pri_image_status"] = 1 if pri_img_model else 0
        result["pri_video_status"] = 1 if pri_video_model else 0
        result["wechat_info"] = UserWeChatModel.full_wechat_info(
            params["user_id"], g.account["user_id"])

        return json_success_response(result)
Beispiel #7
0
    def post(self, params):
        if params["user_id"] == g.account["user_id"]:
            return json_fail_response(2411)

        result = dict()

        RedisModel.add_new_message(
            params["user_id"], RedisModel.private_image_want
            if params["type"] == 11 else RedisModel.private_video_want)

        result["data"] = 1
        result["message"] = "邀请成功"

        return json_success_response(result)
Beispiel #8
0
    def post(self):
        image_uploader = UploadImage()
        image_uploader.save_images()

        result = list()

        for image_dict in image_uploader.images:
            image_model = image_dict.get("image", None)
            if not image_model:
                continue

            image_dict = image_model.format_model(attr_list=["image_id", "image_width", "image_height"])
            image_dict["image_url"] = ImageModel.generate_image_url(image_model)
            image_dict["tiny_img"] = ImageModel.generate_image_url(image_model, 'e')

            result.append(image_dict)

        return json_success_response(result[0])
Beispiel #9
0
    def get(self, params):
        result = {"offset": 0, "want_buy": 0, "result_data": list()}

        # 私密照片
        if params["type"] == 11:
            # 自己看自己的私密照片
            if params["user_id"] == g.account["user_id"]:
                result["result_data"] = ImageModel.query_private_image(
                    params["user_id"], g.account["user_id"], params["last_id"])
            # 查看别人的私密照片
            else:
                # 第一次请求,需要生成一个随机量
                if params["offset"] == 0 and params["last_id"] == 0:
                    params["offset"] = int(
                        PrivateLibraryHandler.random_private_library_offset(
                            params["type"], params["user_id"]))

                result["result_data"] = ImageModel.query_random_private_image(
                    params["user_id"], g.account["user_id"], params["last_id"],
                    params["offset"])

            result["want_buy"] = RedisModel.query_new_message(
                params["user_id"], RedisModel.private_image_want)
        # 私密视频
        else:
            if params["user_id"] == g.account["user_id"]:
                result["result_data"] = VideoModel.query_private_video(
                    params["user_id"], g.account["user_id"], params["last_id"])
            else:
                if params["offset"] == 0 and params["last_id"] == 0:
                    params["offset"] = int(
                        PrivateLibraryHandler.random_private_library_offset(
                            params["type"], params["user_id"]))

                result["result_data"] = VideoModel.query_random_private_video(
                    params["user_id"], g.account["user_id"], params["last_id"],
                    params["offset"])
            result["want_buy"] = RedisModel.query_new_message(
                params["user_id"], RedisModel.private_video_want)
        return json_success_response(result)
Beispiel #10
0
    def post(self):
        upload_video = UploadVideo()
        upload_image = UploadImage()

        if not upload_video.videos:
            return json_fail_response(2202)
        if not upload_image.images:
            return json_fail_response(2203)

        upload_video.save_videos()
        upload_image.save_images()

        img_model = upload_image.images[0]["image"]
        video_model = upload_video.videos[0]["video"]

        video_model.cover_id = img_model.image_id
        db.session.commit()

        video_info = VideoModel.format_video_info(video_model)
        video_info["video_id"] = video_model.video_id
        video_info["tiny_img"] = ImageModel.generate_image_url(img_model, "e")

        return json_success_response(video_info)
Beispiel #11
0
    def post(self, params):
        img_uploader = UploadImage()

        result = []

        if params["type"] == 11:
            if not img_uploader.images:
                return json_fail_response(2402)

            img_uploader.save_images()

            result = UploadPrivateLibraryHandler.upload_private_images(
                img_uploader.images, g.account["user_id"])
            RedisModel.reset_new_message(g.account["user_id"],
                                         RedisModel.private_image_want)
        elif params["type"] == 31:
            if not img_uploader.images:
                return json_fail_response(2203)

            video_uploader = UploadVideo()
            if not video_uploader.videos:
                return json_fail_response(2410)

            img_uploader.save_images()
            video_uploader.save_videos()

            result = UploadPrivateLibraryHandler.upload_private_video(
                video_uploader.videos[0]["video"],
                img_uploader.images[0]["image"], g.account["user_id"],
                params["price"])

            RedisModel.reset_new_message(g.account["user_id"],
                                         RedisModel.private_video_want)

        PrivateLibraryHandler.random_private_library_offset(
            params["type"], g.account["user_id"], True)
        return json_success_response(result)
Beispiel #12
0
 def post(self):
     uploader = UploadVideo()
     uploader.save_videos()
     return json_success_response({})