diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-12 20:36:33 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-12 20:36:33 +0100 |
commit | e6e74321b7dd62364172155e59b9c08454307f90 (patch) | |
tree | 113e68dd6757c12bf02a5603d1b67615a34dbb31 /api/social/request_list.py | |
parent | decb742136440a43ad35ac20908c72b44108f3fa (diff) |
friend requests are in the notification area now :tada:
Diffstat (limited to 'api/social/request_list.py')
-rw-r--r-- | api/social/request_list.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/api/social/request_list.py b/api/social/request_list.py new file mode 100644 index 0000000..56426dc --- /dev/null +++ b/api/social/request_list.py @@ -0,0 +1,26 @@ +from flask import Blueprint, request +from db import cursor, connection +from auth.login_token import token_login +from user.info import format_user +import time + +requests = Blueprint('requests', __name__) + +@requests.route("/requests") +def route(): + token = request.cookies.get("token") or "" + if not token: return "", 401 + user_2_id = token_login(token) or "" + if not user_2_id: return "", 403 + + request_list = cursor.execute("select user_1_id from social where user_2_id = ? and type = \"outgoing\"", + [user_2_id]).fetchall() + + formatted_request_list = [] + for user_1_id in [q[0] for q in request_list]: + formatted_request_list.append(format_user(user_1_id)) + + return { "requests": formatted_request_list }, 200 + +dynamic_route = ["/social/list", requests] + |