diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-13 13:48:09 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-13 13:48:09 +0100 |
commit | 5d02095526c95676ad3f5a6d6763f247bf9e6951 (patch) | |
tree | e7155f63ab4a8d95479e9126feba98ec887a50a4 /api/social/destroy_relation.py | |
parent | d91b95b89bc61228f623effd82810e29d27b1c0c (diff) |
friend request delete :tada:
Diffstat (limited to 'api/social/destroy_relation.py')
-rw-r--r-- | api/social/destroy_relation.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/api/social/destroy_relation.py b/api/social/destroy_relation.py new file mode 100644 index 0000000..1107024 --- /dev/null +++ b/api/social/destroy_relation.py @@ -0,0 +1,31 @@ +from flask import Blueprint, request +from db import cursor +from auth.login_token import token_login +from social.create_relation import remove_relation +from user.info import get_relation_to +import time + +remove = Blueprint('remove', __name__) + +@remove.route('/remove', methods = ['POST']) +def index(): + data = request.get_json() + + user_2_id = data.get("id") or "" + token = request.cookies.get("token") or "" + + if not token: return "", 401 + user_1_id = token_login(token) or "" + + if not user_1_id or \ + not user_2_id: + return "", 403 + + relation = get_relation_to(user_1_id, user_2_id) + if relation == "none": return 403 + + remove_relation(user_1_id, user_2_id) + return "", 200 + +dynamic_route = ["/social", remove] + |