diff --git a/docsrc/markdown/stream_service.md b/docsrc/markdown/stream_service.md index d3beafb1..f5d5ebf8 100644 --- a/docsrc/markdown/stream_service.md +++ b/docsrc/markdown/stream_service.md @@ -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) diff --git a/examples/services/streams.py b/examples/services/streams.py index df5d9c6a..0c90c312 100644 --- a/examples/services/streams.py +++ b/examples/services/streams.py @@ -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)) diff --git a/symphony/bdk/core/service/stream/stream_service.py b/symphony/bdk/core/service/stream/stream_service.py index 53389664..d1970f82 100644 --- a/symphony/bdk/core/service/stream/stream_service.py +++ b/symphony/bdk/core/service/stream/stream_service.py @@ -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 `_ endpoint. + Wraps the `Create IM `_ 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 diff --git a/tests/core/service/stream/stream_service_test.py b/tests/core/service/stream/stream_service_test.py index 11a514fe..9fec764a 100644 --- a/tests/core/service/stream/stream_service_test.py +++ b/tests/core/service/stream/stream_service_test.py @@ -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" @@ -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) diff --git a/tests/resources/stream/create_im_or_mim.json b/tests/resources/stream/create_im.json similarity index 100% rename from tests/resources/stream/create_im_or_mim.json rename to tests/resources/stream/create_im.json