mirror of https://gitlab.com/litecord/litecord.git
blueprints.relationships: sub/unsub friends on friend request changes
This commit is contained in:
parent
1d3520876d
commit
151715943b
|
|
@ -15,6 +15,17 @@ async def get_me_relationships():
|
||||||
return jsonify(await app.storage.get_relationships(user_id))
|
return jsonify(await app.storage.get_relationships(user_id))
|
||||||
|
|
||||||
|
|
||||||
|
async def _unsub_friend(user_id, peer_id):
|
||||||
|
await app.dispatcher.unsub('friend', user_id, peer_id)
|
||||||
|
await app.dispatcher.unsub('friend', peer_id, user_id)
|
||||||
|
|
||||||
|
|
||||||
|
async def _sub_friend(user_id, peer_id):
|
||||||
|
await app.dispatcher.sub('friend', user_id, peer_id)
|
||||||
|
await app.dispatcher.sub('friend', peer_id, user_id)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def make_friend(user_id: int, peer_id: int,
|
async def make_friend(user_id: int, peer_id: int,
|
||||||
rel_type=RelationshipType.FRIEND.value):
|
rel_type=RelationshipType.FRIEND.value):
|
||||||
_friend = RelationshipType.FRIEND.value
|
_friend = RelationshipType.FRIEND.value
|
||||||
|
|
@ -54,6 +65,8 @@ async def make_friend(user_id: int, peer_id: int,
|
||||||
'user': await app.storage.get_user(user_id)
|
'user': await app.storage.get_user(user_id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await _sub_friend(user_id, peer_id)
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
# check if friend AND not acceptance of fr
|
# check if friend AND not acceptance of fr
|
||||||
|
|
@ -70,6 +83,9 @@ async def make_friend(user_id: int, peer_id: int,
|
||||||
'user': await app.storage.get_user(user_id)
|
'user': await app.storage.get_user(user_id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# we don't make the pubsub link
|
||||||
|
# until the peer accepts the friend request
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
@ -116,6 +132,8 @@ async def add_relationship(peer_id: int):
|
||||||
'user': await app.storage.get_user(peer_id)
|
'user': await app.storage.get_user(peer_id)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await _unsub_friend(user_id, peer_id)
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -169,6 +187,8 @@ async def remove_relationship(peer_id: int):
|
||||||
'type': peer_del_type,
|
'type': peer_del_type,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await _unsub_friend(user_id, peer_id)
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
||||||
# was a block!
|
# was a block!
|
||||||
|
|
@ -182,4 +202,6 @@ async def remove_relationship(peer_id: int):
|
||||||
'type': _block,
|
'type': _block,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
await _unsub_friend(user_id, peer_id)
|
||||||
|
|
||||||
return '', 204
|
return '', 204
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue