Skip to content

Commit 1505d69

Browse files
committed
handle HTTP requests to unfollow a user
1 parent dc51ef2 commit 1505d69

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

backend/endpoints.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Dict, Union
22
from data import blooms
3-
from data.follows import follow, get_followed_usernames, get_inverse_followed_usernames
3+
from data.follows import follow, get_followed_usernames, get_inverse_followed_usernames, unfollow
44
from data.users import (
55
UserRegistrationError,
66
get_suggested_follows,
@@ -149,6 +149,22 @@ def do_follow():
149149
}
150150
)
151151

152+
@jwt_required()
153+
def do_unfollow(unfollow_username):
154+
current_user = get_current_user()
155+
unfollow_user = get_user(unfollow_username)
156+
157+
if unfollow_user is None:
158+
return make_response(
159+
(f"Cannot unfollow {unfollow_username} - user does not exist", 404)
160+
)
161+
162+
unfollow(current_user, unfollow_user)
163+
return jsonify(
164+
{
165+
"success": True,
166+
}
167+
)
152168

153169
@jwt_required()
154170
def send_bloom():

0 commit comments

Comments
 (0)