Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
erikjohnston committed Jul 18, 2017
1 parent 3431ec5 commit 14a34f1
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion synapse/federation/transport/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ def on_POST(self, origin, content, query, group_id, room_id):
if get_domain_from_id(requester_user_id) != origin:
raise SynapseError(403, "requester_user_id doesn't match origin")

new_content = yield self.handler.add_room(
new_content = yield self.handler.add_room_to_group(
group_id, requester_user_id, room_id, content
)

Expand Down
2 changes: 1 addition & 1 deletion synapse/groups/groups_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ def get_rooms_in_group(self, group_id, requester_user_id):
})

@defer.inlineCallbacks
def add_room(self, group_id, requester_user_id, room_id, content):
def add_room_to_group(self, group_id, requester_user_id, room_id, content):
"""Add room to group
"""
yield self.check_group_is_ours(
Expand Down
29 changes: 19 additions & 10 deletions synapse/handlers/groups_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def __init__(self, hs):
get_group_profile = _create_rerouter("get_group_profile")
get_rooms_in_group = _create_rerouter("get_rooms_in_group")

add_room_to_group = _create_rerouter("add_room_to_group")

update_group_summary_room = _create_rerouter("update_group_summary_room")
delete_group_summary_room = _create_rerouter("delete_group_summary_room")

Expand Down Expand Up @@ -130,6 +132,9 @@ def get_group_summary(self, group_id, requester_user_id):
defer.returnValue(res)

def create_group(self, group_id, user_id, content):
"""Create a group
"""

logger.info("Asking to create group with ID: %r", group_id)

if self.is_mine_id(group_id):
Expand All @@ -141,18 +146,10 @@ def create_group(self, group_id, user_id, content):
get_domain_from_id(group_id), group_id, user_id, content,
) # TODO

def add_room(self, group_id, user_id, room_id, content):
if self.is_mine_id(group_id):
return self.groups_server_handler.add_room(
group_id, user_id, room_id, content
)

return self.transport_client.add_room_to_group(
get_domain_from_id(group_id), group_id, user_id, room_id, content,
)

@defer.inlineCallbacks
def get_users_in_group(self, group_id, requester_user_id):
"""Get users in a group
"""
if self.is_mine_id(group_id):
res = yield self.groups_server_handler.get_users_in_group(
group_id, requester_user_id
Expand Down Expand Up @@ -184,10 +181,14 @@ def get_users_in_group(self, group_id, requester_user_id):

@defer.inlineCallbacks
def join_group(self, group_id, user_id, content):
"""Request to join a group
"""
raise NotImplementedError() # TODO

@defer.inlineCallbacks
def accept_invite(self, group_id, user_id, content):
"""Accept an invite to a group
"""
if self.is_mine_id(group_id):
yield self.groups_server_handler.accept_invite(
group_id, user_id, content
Expand Down Expand Up @@ -222,6 +223,8 @@ def accept_invite(self, group_id, user_id, content):

@defer.inlineCallbacks
def invite(self, group_id, user_id, requester_user_id, config):
"""Invite a user to a group
"""
content = {
"requester_user_id": requester_user_id,
"config": config,
Expand All @@ -240,6 +243,8 @@ def invite(self, group_id, user_id, requester_user_id, config):

@defer.inlineCallbacks
def on_invite(self, group_id, user_id, content):
"""One of our users were invited to a group
"""
# TODO: Support auto join and rejection

if not self.is_mine_id(user_id):
Expand All @@ -262,6 +267,8 @@ def on_invite(self, group_id, user_id, content):

@defer.inlineCallbacks
def remove_user_from_group(self, group_id, user_id, requester_user_id, content):
"""Remove a user from a group
"""
if user_id == requester_user_id:
yield self.store.register_user_group_membership(
group_id, user_id,
Expand All @@ -286,6 +293,8 @@ def remove_user_from_group(self, group_id, user_id, requester_user_id, content):

@defer.inlineCallbacks
def user_removed_from_group(self, group_id, user_id, content):
"""One of our users was removed/kicked from a group
"""
# TODO: Check if user in group
yield self.store.register_user_group_membership(
group_id, user_id,
Expand Down
4 changes: 3 additions & 1 deletion synapse/rest/client/v2_alpha/groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,9 @@ def on_PUT(self, request, group_id, room_id):
user_id = requester.user.to_string()

content = parse_json_object_from_request(request)
result = yield self.groups_handler.add_room(group_id, user_id, room_id, content)
result = yield self.groups_handler.add_room_to_group(
group_id, user_id, room_id, content,
)

defer.returnValue((200, result))

Expand Down

0 comments on commit 14a34f1

Please sign in to comment.