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

[msteam post suggestion] #66863

Open
arnebjarne opened this issue Aug 30, 2024 · 1 comment
Open

[msteam post suggestion] #66863

arnebjarne opened this issue Aug 30, 2024 · 1 comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. needs-triage

Comments

@arnebjarne
Copy link

Is your feature request related to a problem? Please describe.
Microsoft have changed their Microsoft Teams integration and now require a Workflow integration

Describe the solution you'd like
I have a code suggestion for a temporary fix which ofc should be extended by someone

Describe alternatives you've considered
Since MS has revoked their integration there is not really other alternatives

Additional context
code diff:

--- /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/msteams.py.bak        2024-08-30 11:23:50.394257716 +0000
+++ /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/msteams.py    2024-08-30 12:53:05.265724774 +0000
@@ -68,7 +68,37 @@
     if not message:
         log.error("message is a required option.")

-    payload = {"text": message, "title": title, "themeColor": theme_color}
+    payload = {
+        "type": "message",
+        "attachments": [
+            {"contentType": "application/vnd.microsoft.card.adaptive",
+             "contentUrl": None,
+             "content": {
+                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
+                "type": "AdaptiveCard",
+                "version": "1.2",
+                "msteams": {
+                    "width": "Full"
+                },
+                "body": [
+                    {
+                        "type":   "TextBlock",
+                        "text":   title,
+                        "color":  theme_color,
+                        "weight": "bolder",
+                        "size":   "large",
+                        "wrap":   True
+                    },
+                    {
+                        "type":   "CodeBlock",
+                        "codeSnippet":   message,
+                        "language":   "PlainText"
+                    }
+                ]
+            }
+        }
+        ]
+    }

     headers = {
         "Content-Type": "application/json",
@@ -82,7 +112,7 @@
         status=True,
     )

-    if result["status"] <= 201:
+    if result["status"] <= 202:
         return True
     else:
         return {"res": False, "message": result.get("body", result["status"])}

Please Note
If this feature request would be considered a substantial change or addition, this should go through a SEP process here https://github.com/saltstack/salt-enhancement-proposals, instead of a feature request.

@arnebjarne arnebjarne added Feature new functionality including changes to functionality and code refactors, etc. needs-triage labels Aug 30, 2024
@max-arnold
Copy link
Contributor

As of Salt 3008 (upcoming), the msteams state/module no longer will be shipped with Salt (see #65971). If you want to fix the module and continue using it, please consider porting it to a Salt extension so it can be developed and released independently and much faster.

The Salt extensions community created a new guide and tooling for extension maintainers https://salt-extensions.github.io/salt-extension-copier/

If you need some help or encounter difficulties in using the tools on a Windows machine, feel free to join the #salt-extensions channel on Discord and ask there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature new functionality including changes to functionality and code refactors, etc. needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants