Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docsrc/markdown/stream_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ More precisely:
* [Share third-party content](https://rest-api.symphony.com/main/streams-conversations/all-streams-endpoints/share-v3)
* [Promote user to room owner](https://rest-api.symphony.com/main/streams-conversations/room-endpoints/promote-owner)
* [Demote owner to room participant](https://rest-api.symphony.com/main/streams-conversations/room-endpoints/demote-owner)
* [Create IM or MIM](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/create-im-or-mim)
* [Create IM or MIM non-inclusive](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/create-im-or-mim-admin)
* [Update IM or MIM](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/update-im)
* [Create IM](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/create-im-or-mim)
* [Create IM non-inclusive](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/create-im-or-mim-admin)
* [Update IM](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/update-im)
* [Get IM information](https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/im-info)
* [Create room](https://rest-api.symphony.com/main/streams-conversations/room-endpoints/create-room-v3)
* [Search for rooms](https://rest-api.symphony.com/main/streams-conversations/room-endpoints/search-rooms-v3)
Expand Down
2 changes: 1 addition & 1 deletion examples/services/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def run():
async with SymphonyBdk(config) as bdk:
streams = bdk.streams()

await streams.create_im_or_mim([13056700579872, 13056700579891, 13056700579850])
await streams.create_im(13056700579872)
await streams.create_room(V3RoomAttributes(name="New fancy room", description="test room"))

logging.debug(await streams.get_stream(stream_id))
Expand Down
14 changes: 5 additions & 9 deletions symphony/bdk/core/service/stream/stream_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,16 @@ def __init__(self, streams_api: StreamsApi, room_membership_api: RoomMembershipA
self._retry_config = retry_config

@retry
async def create_im_or_mim(self, user_ids: [int]) -> Stream:
"""Create a new single or multi party instant message conversation between the caller and specified users.
async def create_im(self, user_id: int) -> Stream:
"""Create a new single party instant message conversation between the caller and specified user.
The caller is implicitly included in the members of the created chat.
Duplicate users will be included in the membership of the chat but the duplication will be silently ignored.
If there is an existing IM conversation with the same set of participants then the id of that existing stream
will be returned.
If the given list of user ids contains only one id, an IM will be created, otherwise, a MIM will be created.

Wraps the `Create IM or MIM <https://developers.symphony.com/restapi/reference/create-im-or-mim>`_ endpoint.
Wraps the `Create IM <https://rest-api.symphony.com/main/streams-conversations/im-mim-endpoints/create-im-or-mim>`_ endpoint.

:param user_ids: the list of user ids ti be put as room participants.
:param user_id: the user id to be put as room participant.
:return: the created stream.
"""
return await self._streams_api.v1_im_create_post(uid_list=UserIdList(value=user_ids),
return await self._streams_api.v1_im_create_post(uid_list=UserIdList(value=[user_id]),
session_token=await self._auth_session.session_token)

@retry
Expand Down
10 changes: 5 additions & 5 deletions tests/core/service/stream/stream_service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ async def test_demote_owner(stream_service, room_membership_api):
@pytest.mark.asyncio
async def test_create_im(mocked_api_client, stream_service, streams_api):
mocked_api_client.call_api.return_value = get_deserialized_object_from_resource(Stream,
"stream/create_im_or_mim.json")
"stream/create_im.json")

user_ids = [12334]
stream = await stream_service.create_im_or_mim(user_ids)
user_id = 12334
stream = await stream_service.create_im(user_id)

streams_api.v1_im_create_post.assert_called_once_with(uid_list=UserIdList(value=user_ids),
streams_api.v1_im_create_post.assert_called_once_with(uid_list=UserIdList(value=[user_id]),
session_token=SESSION_TOKEN)
assert stream.id == "-M8s5WG7K8lAP7cpIiuyTH___oh4zK8EdA"

Expand Down Expand Up @@ -314,7 +314,7 @@ async def test_update_im(mocked_api_client, stream_service, streams_api):
@pytest.mark.asyncio
async def test_create_im_admin(mocked_api_client, stream_service, streams_api):
mocked_api_client.call_api.return_value = get_deserialized_object_from_resource(Stream,
"stream/create_im_or_mim.json")
"stream/create_im.json")

user_ids = [12334]
stream = await stream_service.create_im_admin(user_ids)
Expand Down
Loading