Exemplo n.º 1
0
    def _calculate_popularity(cls, video, viewer_uuid, timestamp):

        friendship_bonus = int(UsersDAO.are_friends(video.uuid,
                                                    viewer_uuid)) * 10

        influencer_bonus = UsersDAO.count_friends(video.uuid) * 2

        time_bonus = 60 / (cls._minutes_passed(timestamp) / 1440 + 1)

        return video.cached_relevance + friendship_bonus + int(
            time_bonus) + influencer_bonus
Exemplo n.º 2
0
    def post(self, other_user_id):
        parser = reqparse.RequestParser()
        parser.add_argument("x-access-token", location='headers', required=True, help='Missing user token!')
        parser.add_argument("text", location='json', type=str, required=True, help='You must include the text to be sent!')
        
        args = parser.parse_args()

        if args["text"] == "":
            raise BadRequestError("Invalid message length")

        sender_uuid = AuthSender.get_uuid_from_token(args['x-access-token'])
        author_name = AuthSender.get_author_name(sender_uuid, args["x-access-token"])

        if not UsersDAO.are_friends(sender_uuid, other_user_id):
            raise BadRequestError("You are not friends with this user")

        msg = ChatsDAO.send_message(sender_uuid, other_user_id, args["text"], author_name)

        self.logger.info(f"Succesfully sent message from user {sender_uuid} to {other_user_id}. RESPONSECODE:200")
        return msg, 201
Exemplo n.º 3
0
 def _cant_view(cls, is_private, user1_id, user2_id):
     return is_private and not AuthSender.has_permission(
         user1_id, user2_id) and not UsersDAO.are_friends(
             user1_id, user2_id)