Skip to content

Commit

Permalink
matrix_client: Add remove room alias support
Browse files Browse the repository at this point in the history
Signed-off-by: Gal Pressman <galpressman@gmail.com>
  • Loading branch information
galpressman committed Nov 24, 2016
1 parent 2b37ef0 commit 7070ee5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
12 changes: 12 additions & 0 deletions matrix_client/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,15 @@ def set_room_alias(self, room_id, room_alias):

return self._send("PUT", "/directory/room/{}".format(quote(room_alias)),
content=data, api_path="/_matrix/client/r0")

def remove_room_alias(self, room_alias):
"""Remove mapping of an alias
Args:
room_alias(str): The alias to be removed.
Raises:
MatrixRequestError
"""
return self._send("DELETE", "/directory/room/{}".format(quote(room_alias)),
api_path="/_matrix/client/r0")
15 changes: 15 additions & 0 deletions matrix_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,3 +379,18 @@ def get_user(self, user_id):
"""

return User(self.api, user_id)

def remove_room_alias(self, room_alias):
"""Remove mapping of an alias
Args:
room_alias(str): The alias to be removed.
Returns:
bool: True if the alias is removed, False otherwise.
"""
try:
self.api.remove_room_alias(room_alias)
return True
except MatrixRequestError:
return False

0 comments on commit 7070ee5

Please sign in to comment.