Skip to content

Commit 703e4c2

Browse files
Added Update message to OBO
1 parent 172b9fe commit 703e4c2

1 file changed

Lines changed: 35 additions & 35 deletions

File tree

symphony/bdk/core/service/message/message_service.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,40 @@ async def suppress_message(
126126
}
127127
return await self._message_suppression_api.v1_admin_messagesuppression_id_suppress_post(**params)
128128

129+
@retry
130+
async def update_message(self, stream_id: str, message_id: str, message: Union[str, Message], data=None,
131+
version: str = "", silent=True) -> V4Message:
132+
"""Update an existing message. The existing message must be a valid social message, that has not been deleted.
133+
See: `Update Message <https://developers.symphony.com/restapi/reference/update-message-v4>`_
134+
135+
:param stream_id: The ID of the stream where the message is being updated.
136+
:param message_id: The ID of the message that is being updated.
137+
:param message: a :py:class:`Message` instance or a string containing the MessageML content to be sent.
138+
If it is a :py:class:`Message` instance, other parameters will be ignored.
139+
If it is a string, ``<messageML>`` tags can be omitted.
140+
:param data: an object (e.g. dict) that will be serialized into JSON using ``json.dumps``.
141+
:param silent: a bool flag that will determine if the updated message is going to be marked as read (when true,
142+
which is default value) or unread (when false).
143+
:param version: Optional message version in the format "major.minor".
144+
If empty, defaults to the latest supported version.
145+
146+
:return: a V4Message object containing the details of the updated message.
147+
"""
148+
message_object = message if isinstance(message, Message) else Message(content=message, data=data, silent=silent,
149+
version=version)
150+
151+
params = {
152+
"sid": stream_id,
153+
"mid": message_id,
154+
"session_token": await self._auth_session.session_token,
155+
"key_manager_token": await self._auth_session.key_manager_token,
156+
"message": message_object.content,
157+
"data": message_object.data,
158+
"version": message_object.version,
159+
"silent": str(message_object.silent)
160+
}
161+
return await self._messages_api.v4_stream_sid_message_mid_update_post(**params)
162+
129163
@retry
130164
async def get_attachment_types(self) -> List[str]:
131165
"""Retrieves a list of supported file extensions for attachments.
@@ -172,7 +206,7 @@ async def blast_message(
172206
@retry
173207
async def _blast_message(
174208
self,
175-
stream_ids: [str],
209+
stream_ids: List[str],
176210
message: str,
177211
data: str = "",
178212
version: str = "",
@@ -464,40 +498,6 @@ async def search_messages_one_page(skip, limit):
464498

465499
return offset_based_pagination(search_messages_one_page, chunk_size, max_number)
466500

467-
@retry
468-
async def update_message(self, stream_id: str, message_id: str, message: Union[str, Message], data=None,
469-
version: str = "", silent=True) -> V4Message:
470-
"""Update an existing message. The existing message must be a valid social message, that has not been deleted.
471-
See: `Update Message <https://developers.symphony.com/restapi/reference/update-message-v4>`_
472-
473-
:param stream_id: The ID of the stream where the message is being updated.
474-
:param message_id: The ID of the message that is being updated.
475-
:param message: a :py:class:`Message` instance or a string containing the MessageML content to be sent.
476-
If it is a :py:class:`Message` instance, other parameters will be ignored.
477-
If it is a string, ``<messageML>`` tags can be omitted.
478-
:param data: an object (e.g. dict) that will be serialized into JSON using ``json.dumps``.
479-
:param silent: a bool flag that will determine if the updated message is going to be marked as read (when true,
480-
which is default value) or unread (when false).
481-
:param version: Optional message version in the format "major.minor".
482-
If empty, defaults to the latest supported version.
483-
484-
:return: a V4Message object containing the details of the updated message.
485-
"""
486-
message_object = message if isinstance(message, Message) else Message(content=message, data=data, silent=silent,
487-
version=version)
488-
489-
params = {
490-
"sid": stream_id,
491-
"mid": message_id,
492-
"session_token": await self._auth_session.session_token,
493-
"key_manager_token": await self._auth_session.key_manager_token,
494-
"message": message_object.content,
495-
"data": message_object.data,
496-
"version": message_object.version,
497-
"silent": str(message_object.silent)
498-
}
499-
return await self._messages_api.v4_stream_sid_message_mid_update_post(**params)
500-
501501
@staticmethod
502502
def _validate_message_search_query(query: MessageSearchQuery):
503503
# Check streamType value among accepted ones if specified

0 commit comments

Comments
 (0)