aboutsummaryrefslogtreecommitdiff
path: root/api/social/create_relation.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-16 16:57:26 +0200
commit07c2b124e4348b15f1e5ec18c6cdfd77248c6bc8 (patch)
treee4a29123d3ebedc1d25500390c904c66b3b02489 /api/social/create_relation.py
parentaa2c999702dadba2afbcf2be9f597f890aafcc87 (diff)
spaces > tabs in python :(
Diffstat (limited to 'api/social/create_relation.py')
-rw-r--r--api/social/create_relation.py44
1 files changed, 22 insertions, 22 deletions
diff --git a/api/social/create_relation.py b/api/social/create_relation.py
index 5367ac5..01ad0eb 100644
--- a/api/social/create_relation.py
+++ b/api/social/create_relation.py
@@ -6,46 +6,46 @@ import time
def create_relation(user_1_id, user_2_id, relation_type):
- remove_relation(user_1_id, user_2_id)
- 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]
- )
- connection.commit()
+ remove_relation(user_1_id, user_2_id)
+ 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]
+ )
+ connection.commit()
# 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]
- )
- connection.commit()
+ cursor.execute(
+ "delete from social where user_1_id = ? and user_2_id = ?",
+ [user_1_id, user_2_id]
+ )
+ connection.commit()
def create_relation_route(relation_type):
- @two_person
- def route(user_1_id, user_2_id):
- create_relation(user_1_id, user_2_id, relation_type)
+ @two_person
+ def route(user_1_id, user_2_id):
+ create_relation(user_1_id, user_2_id, relation_type)
- if relation_type == "outgoing":
- io.emit("incomingFriendRequest", room="user-" + user_2_id)
+ if relation_type == "outgoing":
+ io.emit("incomingFriendRequest", room="user-" + user_2_id)
- return "", 200
+ return "", 200
- return route
+ return route
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]]