22from flask_jwt_extended import current_user
33from flask_jwt_extended import jwt_required
44from PyMatcha .models .like import Like
5+ from PyMatcha .models .match import Match
56from PyMatcha .models .user import get_user
67from PyMatcha .utils .errors import BadRequestError
78from PyMatcha .utils .errors import NotFoundError
@@ -22,7 +23,12 @@ def like_profile(uid):
2223 if current_user .already_likes (u .id ):
2324 raise BadRequestError ("You already liked this person" , "Try again" )
2425 Like .create (liker_id = current_user .id , liked_id = u .id )
25- return Success (f"Liked user { u .id } " )
26+
27+ if current_user .already_likes (u .id ):
28+ Match .create (user_1 = current_user .id , user_2 = u .id )
29+ return Success (f"Liked user { u .id } , it's a match !" )
30+
31+ return Success (f"Liked user { u .id } ." )
2632
2733
2834@like_bp .route ("/unlike/<uid>" , methods = ["POST" ])
@@ -37,4 +43,8 @@ def unlike_profile(uid):
3743 if not current_user .already_likes (u .id ):
3844 raise BadRequestError ("You never liked this person in the first place" , "Try again" )
3945 Like .get_multi (liked_id = u .id , liker_id = current_user .id ).delete ()
40- return Success (f"Unliked user { u .id } " )
46+ return Success (f"Unliked user { u .id } ." )
47+
48+
49+ # TODO: Likes received
50+ # TODO: Likes sent
0 commit comments