Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove zoom-send-message foramt arguments #28042

Merged
merged 10 commits into from Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 2 additions & 8 deletions Packs/Zoom/Integrations/Zoom/README.md
Expand Up @@ -1605,14 +1605,8 @@ Sends chat messages on Zoom to either an individual user who is in your contact
| **Argument Name** | **Description** | **Required** |
| --- | --- | --- |
| user_id | Unique identifier of the user. | Required |
| at_contact | This field is required if the value of at_type field is set to 1. Email address of the contact. | Optional |
| at_type | The type of mention. You can use one of the following values: 1: Mention a contact. 2: Mention "all" to notify everyone in the channel. | Optional |
| end_position | The end position of the mention. | Optional |
| start_position | The start position of the mention("@") in the message string. | Optional |
| rt_start_position | The start position of the rich text in the message string. | Optional |
| rt_end_position | The end position of the rich text. | Optional |
| format_type | The type of rich text. There is some special logic which is the same as on the Zoom client. 1. AddLink's position can not cross multi lines. 2. A BulletedList will clear the formatting of a NumberedList, Quote, or LeftIndent after it. 3. Likewise, a NumberedList will clear the formatting of a BulletedList, Quote, or LeftIndent after it. 4. Only AddLink, NumberedList and BulletedList can apply to a message which already applied a Quote. 5. A Quote will clear the formatting of all styles after it except AddLink, NumberedList, BulletedList, or Italic. 6. An AddLink will clear the formatting of BackgroundColor, FontColor, or Underline after it. 7. BackgroundColor, FontColor and Underline can not apply to a message which already applied AddLink. 8. BulletedList, NumberedList, LeftIndent, Paragraph, and Quote will automatically expand to apply to the whole line. Possible values are: FontSize, FontColor, BackgroundColor, LeftIndent, Paragraph, AddLink. | Optional |
| format_attr | This field is required if the value of the format_type field is listed below: 1.FontSize value: s for small, m for medium, or l for large font size. 2.FontColor and BackgroundColor value: only supports RGB value. For example: FFC0CB 3.LeftIndent value: a positive pixel length. 4.Paragraph value: h1 for Heading 1, h2 for Heading 2, or h3 for Heading 3. 5.AddLink value: must be a valid URL, with an http or https prefix. For example: <https://example.com>. | Optional |
| at_contact | Email address of the mention contact. | Optional |
| is_markdown | if a markdown message provide in the message argument| Optional
| message | The message to be sent. Maximum of 1024 characters. | Required |
| entry_ids | A list of the file IDs to send. This field only accepts a maximum of six file IDs. | Optional |
| reply_main_message_id | The reply message's ID. This field only returns if the message is a reply message. | Optional |
Expand Down
32 changes: 5 additions & 27 deletions Packs/Zoom/Integrations/Zoom/Zoom.py
Expand Up @@ -1130,7 +1130,7 @@ def zoom_send_file_command(client, **args) -> CommandResults:

message_id = upload_response.get('id')
return CommandResults(
readable_output=f'Message with id {message_id} was successfully sent'
readable_output=f'Message with id {message_id} was successfully sent'
)


Expand Down Expand Up @@ -1367,14 +1367,7 @@ def zoom_send_message_command(client, **args) -> CommandResults:
"""
client = client
at_contact = args.get('at_contact')
at_type = AT_TYPE.get(args.get('at_type', None))
user_id = args.get('user_id')
end_position = arg_to_number(args.get('end_position'))
start_position = arg_to_number(args.get('start_position'))
rt_start_position = arg_to_number(args.get('rt_start_position'))
rt_end_position = arg_to_number(args.get('rt_end_position'))
format_type = args.get('format_type')
format_attr = args.get('format_attr')
message = args.get('message', '')
entry_ids = argToList(args.get('entry_ids', []))
reply_main_message_id = args.get('reply_main_message_id')
Expand All @@ -1394,10 +1387,6 @@ def zoom_send_message_command(client, **args) -> CommandResults:
zoom_file_id.append(res.get('id'))

# check if the text contain markdown to parse and also provide text style arguments
if is_markdown and (start_position or end_position
or format_attr or format_type or rt_end_position or rt_start_position or at_type):
raise DemistoException(MARKDOWN_AND_EXTRA_ARGUMENTS)

if is_markdown:
# check if text have more then 1 mention
if message.count('@') > 1 and at_contact:
Expand All @@ -1407,18 +1396,7 @@ def zoom_send_message_command(client, **args) -> CommandResults:
json_data_all.update({"file_ids": zoom_file_id, "reply_main_message_id": reply_main_message_id, "to_channel": to_channel,
"to_contact": to_contact})
else:
json_data_all = {"at_items": [
{
"at_contact": at_contact,
"at_type": at_type,
"end_position": end_position,
"start_position": start_position
}],
"rich_text":
[{"start_position": rt_start_position,
"end_position": rt_end_position,
"format_type": format_type,
"format_attr": format_attr}],
json_data_all = {
"message": message,
"file_ids": zoom_file_id,
"reply_main_message_id": reply_main_message_id,
Expand Down Expand Up @@ -1548,7 +1526,7 @@ def zoom_list_messages_command(client, **args) -> CommandResults:
search_key = args.get('search_key')
exclude_child_message = args.get('exclude_child_message', False)
limit = arg_to_number(args.get('limit', 50))
page_size = limit if limit and limit <= 50 else 50
page_size = args.get('page_size')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not understand why this change was made. is limit even used?


if not to_contact and not to_channel:
raise DemistoException(MISSING_ARGUMENT)
Expand Down Expand Up @@ -1604,9 +1582,9 @@ def zoom_list_messages_command(client, **args) -> CommandResults:
md += '\n' + 'Messages next token:' + raw_data.get('next_page_token', '')

return CommandResults(
outputs_prefix='Zoom.ChatMessage',
outputs_prefix='Zoom',
readable_output=md,
outputs={'messages': all_messages,
outputs={'ChatMessage': all_messages,
'ChatMessageNextToken': raw_data.get('next_page_token')},
raw_response=raw_data
)
Expand Down
53 changes: 4 additions & 49 deletions Packs/Zoom/Integrations/Zoom/Zoom.yml
Expand Up @@ -846,7 +846,7 @@ script:
Sends chat messages on Zoom to either an individual user who is in your contact list or to a channel of which you are a member. Use the command zoom-list-users to get the user id by the user email (for to_contact).
Use the command zoom-list-user-channels in order to fetch the channel ID by the channel name (for to_channel).
In order to send a message, you need to provide at least a message (message text) and to_contact (contact to send) or to_channel (channel to send to), but not both of them.
In order to send a style message you need to provide is-markdown=true and not provide any format_type or format_attr.
In order to send a style message you need to provide is-markdown=true and the message can contain a markdown format
If you are using mention markdown in a message, provide the email address in the at_contact argument.
arguments:
- name: user_id
Expand All @@ -855,27 +855,16 @@ script:
required: true
- name: at_contact
description: >
This field is required if the value of at_type field is set to 1.
Email address of the contact.
Email address of the mention contact.
type: string
- name: at_type
description: >
The type of mention. You can use one of the following values:
1: Mention a contact.
2: Mention "all" to notify everyone in the channel.
type: string
auto: PREDEFINED
predefined:
- Mention a contact
- Mention "all" to notify everyone in the channel
- name: is_markdown
auto: PREDEFINED
predefined:
- "true"
- "false"
defaultValue: false
description: |-
You can provide a markdown message without any other arguments like format type,format attr,start and end position and rt start and end_position
You can provide a markdown message in the message argument.
| Element | Markdown Syntax |
|------------|-------------------|
| Paragraph | # H1 , ## H2 ,### H3|
Expand All @@ -885,43 +874,10 @@ script:
| FontSize | [s|m|l](text)|
| BackgroundColor| [#<rgb>bg](text)|
| Mention | @<text> if mention is not @all please provide argument at_contact= email|

- name: end_position
description: The end position of the mention.
type: string
- name: start_position
description: The start position of the mention ("@") in the message string.
type: string
- name: rt_start_position
description: The start position of the rich text in the message string.
type: string
- name: rt_end_position
description: The end position of the rich text.
type: string
- name: format_type
description: The type of rich text. There is some special logic which is the same as on the Zoom client. 1. AddLink's position can not cross multi lines. 2. A BulletedList will clear the formatting of a NumberedList, Quote, or LeftIndent after it. 3. Likewise, a NumberedList will clear the formatting of a BulletedList, Quote, or LeftIndent after it. 4. Only AddLink, NumberedList and BulletedList can apply to a message which already applied a Quote. 5. A Quote will clear the formatting of all styles after it except AddLink, NumberedList, BulletedList, or Italic. 6. An AddLink will clear the formatting of BackgroundColor, FontColor, or Underline after it. 7. BackgroundColor, FontColor and Underline can not apply to a message which already applied AddLink. 8. BulletedList, NumberedList, LeftIndent, Paragraph, and Quote will automatically expand to apply to the whole line.
type: string
auto: PREDEFINED
predefined:
- FontSize
- FontColor
- BackgroundColor
- LeftIndent
- Paragraph
- AddLink
- name: format_attr
description: >
This field is required if the value of the format_type field is listed below:
1.FontSize value: s for small, m for medium, or l for large font size.
2.FontColor and BackgroundColor value: only supports RGB value. For example: FFC0CB
3.LeftIndent value: a positive pixel length.
4.Paragraph value: h1 for Heading 1, h2 for Heading 2, or h3 for Heading 3.
5.AddLink value: must be a valid URL, with an http or https prefix. For example: https://example.com
type: string
- name: message
description: |-
The message to be sent. Maximum of 1024 characters.
You can provide a markdown message without any other arguments like format type,format attr,start and end position and rt start and end_position
You can provide a markdown format
| Element | Markdown Syntax |
|------------|-------------------|
| Paragraph | # H1 , ## H2 ,### H3|
Expand All @@ -931,7 +887,6 @@ script:
| FontSize | [s|m|l](text)|
| BackgroundColor| [#<rgb>bg](text)|
| Mention | @<text> if mention is not @all please provide argument at_contact= email|

required: true
type: string
- name: entry_ids
Expand Down
23 changes: 0 additions & 23 deletions Packs/Zoom/Integrations/Zoom/Zoom_test.py
Expand Up @@ -1240,7 +1240,7 @@

zoom_remove_from_channel_mock.assert_called_with(expected_url_suffix)


Check failure on line 1243 in Packs/Zoom/Integrations/Zoom/Zoom_test.py

View workflow job for this annotation

GitHub Actions / pre-commit

Packs/Zoom/Integrations/Zoom/Zoom_test.py.test_zoom_send_file_command

AssertionError: assert 'Message with...essfully sent' == 'Message with...essfully sent' - Message with id file_id was successfully sent ? - - + Message with id file_id was successfully sent
def test_zoom_send_file_command(mocker):
"""
Given -
Expand Down Expand Up @@ -1400,10 +1400,6 @@

zoom_send_message_command(client,
user_id=user_id,
at_contact='user2@example.com',
at_type='Mention a contact',
start_position=11,
end_position=16,
message='Hello from @dima!',
to_channel='channel1',
entry_ids='entry_id'
Expand All @@ -1429,21 +1425,6 @@
expected_request_payload = {
'message': 'Hello from @dima!',
'to_channel': 'channel1',
'at_items': [
{
'at_contact': 'user2@example.com',
'at_type': 1,
'start_position': 11,
'end_position': 16
}
],
'rich_text': [
{'start_position': None,
'end_position': None,
'format_type': None,
'format_attr': None
}
],
'file_ids': []
}

Expand All @@ -1459,10 +1440,6 @@

result = zoom_send_message_command(client,
user_id='user1',
at_contact='user2@example.com',
at_type='Mention a contact',
start_position=11,
end_position=16,
message='Hello from @dima!',
to_channel='channel1',

Expand Down Expand Up @@ -1548,7 +1525,7 @@

assert str(e.value) == "Too many mentions in text. you can provide only one mention in each message"


Check failure on line 1528 in Packs/Zoom/Integrations/Zoom/Zoom_test.py

View workflow job for this annotation

GitHub Actions / pre-commit

Packs/Zoom/Integrations/Zoom/Zoom_test.py.test_zoom_send_message_markdown_command_error_too_many_arguments

AssertionError: assert 'Connection T...om your host.' == 'Too many arg...r format_attr' + Connection Timeout Error - potential reasons might be that the Server URL parameter is incorrect or that the Server is not accessible from your host. - Too many arguments. If you choose is_markdown, - don't provide one of the following arguments: start_position, end_position, format_type, at_type, - rt_start_position, rt_end_position or format_attr
def test_zoom_send_message_markdown_command_error_too_many_arguments(mocker):
"""
Given -
Expand Down Expand Up @@ -1580,7 +1557,7 @@
don't provide one of the following arguments: start_position, end_position, format_type, at_type,
rt_start_position, rt_end_position or format_attr"""


Check failure on line 1560 in Packs/Zoom/Integrations/Zoom/Zoom_test.py

View workflow job for this annotation

GitHub Actions / pre-commit

Packs/Zoom/Integrations/Zoom/Zoom_test.py.test_zoom_list_messages_command

AssertionError: assert {'ChatMessage...tToken': None} == {'ChatMessage...der_2', ...}]} Omitting 1 identical items, use -vv to show Left contains 1 more item: {'ChatMessage': [{'date_time': '2023-03-07T10:30:00Z', 'id': 'message_id_1', 'message': 'Message 1', 'sender': 'sender_1', 'sender_display_name': 'Sender 1'},... ...Full output truncated (40 lines hidden), use '-vv' to show
def test_zoom_list_messages_command(mocker):
"""
Given -
Expand Down
6 changes: 6 additions & 0 deletions Packs/Zoom/ReleaseNotes/1_5_1.md
@@ -0,0 +1,6 @@

#### Integrations

##### Zoom

- Updated the zoom-send-message command
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we need to add braking changes disclaimer.

Suggested change
- Updated the zoom-send-message command
- **Breaking changes**: The following arguments were removed from ***zoom-send-message*** command, please use markdown in order to create formatted meseges:
- ***start_position***
- ***end_position***
- ***rt_start_position***
- ***rt_end_position***
- ***format_type***
- ***format_attr***

2 changes: 1 addition & 1 deletion Packs/Zoom/pack_metadata.json
Expand Up @@ -2,7 +2,7 @@
"name": "Zoom",
"description": "Use the Zoom integration manage your Zoom users and meetings",
"support": "xsoar",
"currentVersion": "1.5.0",
"currentVersion": "1.5.1",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down