diff options
Diffstat (limited to 'api/social')
-rw-r--r-- | api/social/create_relation.py | 14 | ||||
-rw-r--r-- | api/social/friend_accept.py | 4 | ||||
-rw-r--r-- | api/social/request_list.py | 4 | ||||
-rw-r--r-- | api/social/search.py | 4 |
4 files changed, 13 insertions, 13 deletions
diff --git a/api/social/create_relation.py b/api/social/create_relation.py index f58e105..af81b69 100644 --- a/api/social/create_relation.py +++ b/api/social/create_relation.py @@ -14,7 +14,7 @@ def two_person_endpoint(func): user_2_id = data.get("id") or "" if not user_1_id or \ - not user_2_id: + not user_2_id: return "", 403 return func(user_1_id, user_2_id) @@ -28,8 +28,8 @@ def create_relation(user_1_id, user_2_id, relation_type): remove_relation(user_2_id, user_1_id) timestamp = int(time.time() * 1000) cursor.execute( - "insert into social values (?, ?, ?, ?)", - [user_1_id, user_2_id, relation_type, timestamp] + "insert into social values (?, ?, ?, ?)", + [user_1_id, user_2_id, relation_type, timestamp] ) connection.commit() @@ -37,8 +37,8 @@ def create_relation(user_1_id, user_2_id, relation_type): # remove relation between user_1_id and user_2_id (one-way) def remove_relation(user_1_id, user_2_id): cursor.execute( - "delete from social where user_1_id = ? and user_2_id = ?", - [user_1_id, user_2_id] + "delete from social where user_1_id = ? and user_2_id = ?", + [user_1_id, user_2_id] ) connection.commit() @@ -58,12 +58,12 @@ def create_relation_route(relation_type): friend_request = Blueprint('friend_request', __name__) friend_request.add_url_rule( - '/request', 'route', create_relation_route("outgoing"), methods=["POST"] + '/request', 'route', create_relation_route("outgoing"), methods=["POST"] ) block = Blueprint('block', __name__) block.add_url_rule( - '/block', 'route', create_relation_route("block"), methods=["POST"] + '/block', 'route', create_relation_route("block"), methods=["POST"] ) dynamic_routes = [["/social", friend_request], ["/social", block]] diff --git a/api/social/friend_accept.py b/api/social/friend_accept.py index 75dd3b9..4eb4837 100644 --- a/api/social/friend_accept.py +++ b/api/social/friend_accept.py @@ -11,8 +11,8 @@ accept = Blueprint('accept', __name__) @two_person_endpoint def route(user_1_id, user_2_id): cursor.execute( - "update social set type = \"friendship\" where user_1_id = ? and user_2_id = ?", - [user_2_id, user_1_id] + "update social set type = \"friendship\" where user_1_id = ? and user_2_id = ?", + [user_2_id, user_1_id] ) connection.commit() diff --git a/api/social/request_list.py b/api/social/request_list.py index 8d1acd6..9b79203 100644 --- a/api/social/request_list.py +++ b/api/social/request_list.py @@ -12,8 +12,8 @@ requests = Blueprint('requests', __name__) def route(user_2_id): # get a list of friend requests request_list = cursor.execute( - "select user_1_id from social where user_2_id = ? and type = \"outgoing\"", - [user_2_id] + "select user_1_id from social where user_2_id = ? and type = \"outgoing\"", + [user_2_id] ).fetchall() # get user_id for each result to prevent repeat user/info requests diff --git a/api/social/search.py b/api/social/search.py index a22ea73..f0ce8a2 100644 --- a/api/social/search.py +++ b/api/social/search.py @@ -17,8 +17,8 @@ def index(): # use levenshtein with max distance 3 to search for users #TODO: use mysql and sort by best match results = cursor.execute( - "select user_id from users where levenshtein(lower(username), lower(?), 3)", - [query] + "select user_id from users where levenshtein(lower(username), lower(?), 3)", + [query] ).fetchmany(20) formatted = {"results": []} |