diff options
| author | lonkaars <l.leblansch@gmail.com> | 2021-03-21 11:30:04 +0100 | 
|---|---|---|
| committer | lonkaars <l.leblansch@gmail.com> | 2021-03-21 11:30:04 +0100 | 
| commit | d8169484077c4ce25e195747602f06bce9d4ded0 (patch) | |
| tree | 3c523fefec52e7ed801532d08bcebdd2511258c3 /api | |
| parent | eed11fd96cf1458a7a91659cdf5efafbadda1b2b (diff) | |
changedRelation api event
Diffstat (limited to 'api')
| -rw-r--r-- | api/readme.md | 1 | ||||
| -rw-r--r-- | api/social/destroy_relation.py | 7 | ||||
| -rw-r--r-- | api/social/friend_accept.py | 4 | 
3 files changed, 11 insertions, 1 deletions
| diff --git a/api/readme.md b/api/readme.md index 48e9b14..26ef02b 100644 --- a/api/readme.md +++ b/api/readme.md @@ -50,6 +50,7 @@ resign|send to resign, is then forwarded to all subscribed clients|`none`|`s <->  newMove|send a new move|`{ move: int, game_id: string }`|`s <-  c`|game  registerGameListener|listen to events for a game|`{ id: string }`|`s <-  c`|game  incomingFriendRequest|get notified of friend request|`none`|`s  -> c`|global +changedRelation|get notified of a different relation to someone|`{ id: string }`|`s  -> c`|global  ## How to test API endpoints  ```sh diff --git a/api/social/destroy_relation.py b/api/social/destroy_relation.py index 09b42f0..a08175f 100644 --- a/api/social/destroy_relation.py +++ b/api/social/destroy_relation.py @@ -3,6 +3,7 @@ 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 +from socket_io import io  import time  remove = Blueprint('remove', __name__) @@ -22,10 +23,14 @@ def index():             return "", 403      relation = get_relation_to(user_1_id, user_2_id) -    if relation == "none": return 403 +    if relation == "none": return "", 403      remove_relation(user_1_id, user_2_id)      remove_relation(user_2_id, user_1_id) + +    io.emit("changedRelation", { "id": user_2_id }, room="user-"+user_1_id) +    io.emit("changedRelation", { "id": user_1_id }, room="user-"+user_2_id) +      return "", 200  unblock = Blueprint('unblock', __name__) diff --git a/api/social/friend_accept.py b/api/social/friend_accept.py index bc850d2..8340274 100644 --- a/api/social/friend_accept.py +++ b/api/social/friend_accept.py @@ -1,6 +1,7 @@  from flask import Blueprint, request  from db import cursor, connection  from auth.login_token import token_login +from socket_io import io  import time  accept = Blueprint('accept', __name__) @@ -23,6 +24,9 @@ def route():              [user_1_id, user_2_id])      connection.commit() +    io.emit("changedRelation", { "id": user_2_id }, room="user-"+user_1_id) +    io.emit("changedRelation", { "id": user_1_id }, room="user-"+user_2_id) +      return "", 200  dynamic_route = ["/social", accept] |