mirror of https://gitlab.com/litecord/litecord.git
relationships: move self-self check to make_friend
This commit is contained in:
parent
f05b807f60
commit
6e9ddd89f8
|
|
@ -63,6 +63,9 @@ async def make_friend(
|
||||||
_friend = RelationshipType.FRIEND.value
|
_friend = RelationshipType.FRIEND.value
|
||||||
_block = RelationshipType.BLOCK.value
|
_block = RelationshipType.BLOCK.value
|
||||||
|
|
||||||
|
if user_id == peer_id:
|
||||||
|
raise RelationshipFailed("Self-relationships are disallowed")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await app.db.execute(
|
await app.db.execute(
|
||||||
"""
|
"""
|
||||||
|
|
@ -228,9 +231,6 @@ async def post_relationship():
|
||||||
if not uid:
|
if not uid:
|
||||||
raise RelationshipFailed("No users with DiscordTag exist")
|
raise RelationshipFailed("No users with DiscordTag exist")
|
||||||
|
|
||||||
if uid == user_id:
|
|
||||||
raise RelationshipFailed("Tried to add themselves as friend")
|
|
||||||
|
|
||||||
res = await make_friend(user_id, uid)
|
res = await make_friend(user_id, uid)
|
||||||
|
|
||||||
if res is None:
|
if res is None:
|
||||||
|
|
@ -247,7 +247,6 @@ async def add_relationship(peer_id: int):
|
||||||
rel_type = payload["type"]
|
rel_type = payload["type"]
|
||||||
|
|
||||||
res = await make_friend(user_id, peer_id, rel_type)
|
res = await make_friend(user_id, peer_id, rel_type)
|
||||||
|
|
||||||
if res is not None:
|
if res is not None:
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue