Skip to content
Open
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
12 changes: 8 additions & 4 deletions plugins/microsoft_teams/.CHECKSUM
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"spec": "e5b1705c597ac7c4bfd4c299adcf1d5d",
"manifest": "0de3aa339215bd2d192cc68f0b2305e5",
"setup": "8d1fb841a1e95b276ddbd6034bfa903c",
"spec": "8e975c2a656a6df4a6bf3dd171ef61a3",
"manifest": "e342a061cc9eb310027752c70dad072d",
"setup": "c268bab4d87f8b39523156e03607a66a",
"schemas": [
{
"identifier": "add_channel_to_team/schema.py",
Expand Down Expand Up @@ -65,7 +65,7 @@
},
{
"identifier": "send_html_message/schema.py",
"hash": "cda9b2e48d700eed1457848740c473f5"
"hash": "31ad10a98184662e7470a0070d2b9c84"
},
{
"identifier": "send_message/schema.py",
Expand All @@ -79,6 +79,10 @@
"identifier": "connection/schema.py",
"hash": "c74d11e11b5a1e0fa64e8a1ba91a6700"
},
{
"identifier": "new_chat_message_received/schema.py",
"hash": "bbcd3d12d1705e1e8453a1c97eb6346f"
},
{
"identifier": "new_message_received/schema.py",
"hash": "46ff48b36b6cea4e3a4d27ef84fe9d77"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import insightconnect_plugin_runtime
from .schema import SendHtmlMessageInput, SendHtmlMessageOutput, Input, Output, Component
from .schema import (
SendHtmlMessageInput,
SendHtmlMessageOutput,
Input,
Output,
Component,
)

# Custom imports below
from icon_microsoft_teams.util.teams_utils import (
Expand All @@ -9,6 +15,7 @@
)
from icon_microsoft_teams.util.komand_clean_with_nulls import remove_null_and_clean
from icon_microsoft_teams.util.words_utils import add_words_values_to_message
from insightconnect_plugin_runtime.exceptions import PluginException


class SendHtmlMessage(insightconnect_plugin_runtime.Action):
Expand All @@ -22,18 +29,32 @@ def __init__(self):

def run(self, params={}):
message = params.get(Input.MESSAGE_CONTENT)

teams = get_teams_from_microsoft(self.logger, self.connection, params.get(Input.TEAM_NAME))
team_id = teams[0].get("id")
channels = get_channels_from_microsoft(self.logger, self.connection, team_id, params.get(Input.CHANNEL_NAME))

team = params.get(Input.TEAM_NAME, None)
channel = params.get(Input.CHANNEL_NAME, None)
chat_id = params.get(Input.CHAT_ID, None)
team_id = None
channel_id = None

if team and channel:
teams = get_teams_from_microsoft(self.logger, self.connection, team)
team_id = teams[0].get("id")
channels = get_channels_from_microsoft(self.logger, self.connection, team_id, channel)
channel_id = channels[0].get("id")

if not chat_id and not team_id and not channel_id:
raise PluginException(
cause="No chat ID or team ID with channel ID was provided.",
assistance="Please provide the chat ID to send the chat message or the team and channel details(name or"
" GUID) to send the message to a specific channel.",
)
message = send_html_message(
self.logger,
self.connection,
message,
team_id,
channels[0].get("id"),
channel_id,
thread_id=params.get(Input.THREAD_ID, None),
chat_id=chat_id,
)

message = remove_null_and_clean(message)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Component:

class Input:
CHANNEL_NAME = "channel_name"
CHAT_ID = "chat_id"
MESSAGE_CONTENT = "message_content"
TEAM_NAME = "team_name"
THREAD_ID = "thread_id"
Expand All @@ -31,11 +32,17 @@ class SendHtmlMessageInput(insightconnect_plugin_runtime.Input):
"description": "Channel name",
"order": 2
},
"chat_id": {
"type": "string",
"title": "Chat ID",
"description": "The ID of the chat",
"order": 4
},
"message_content": {
"type": "string",
"title": "Message Content",
"description": "HTML content to send",
"order": 4
"order": 5
},
"team_name": {
"type": "string",
Expand All @@ -51,9 +58,7 @@ class SendHtmlMessageInput(insightconnect_plugin_runtime.Input):
}
},
"required": [
"channel_name",
"message_content",
"team_name"
"message_content"
],
"definitions": {}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT

from .new_message_received.trigger import NewMessageReceived

from .new_chat_message_received.trigger import NewChatMessageReceived
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GENERATED BY INSIGHT-PLUGIN - DO NOT EDIT
from .trigger import NewChatMessageReceived
Loading