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

Render markdown from Teams plug-ins #18

Open
Gert-dev opened this issue Jul 9, 2022 · 12 comments
Open

Render markdown from Teams plug-ins #18

Gert-dev opened this issue Jul 9, 2022 · 12 comments

Comments

@Gert-dev
Copy link

Gert-dev commented Jul 9, 2022

Problem

Several Teams plug-ins, such as the GitLab plug-in, post notifications containing rich text. In Pidgin these are then also displayed, but the source markdown seems to be posted instead. For example:

Foo (userfoo) [commented on issue #123](https://gitlab.com/group/project/-/issues/123#note_1234567890) in [Group / Project](https://gitlab.com/group/project): *Title of issue in GitLab*

Steps To Reproduce

  1. Link a GitLab project to a Teams channel (or another plug-in that posts rich messages).
  2. Cause it to send a notification.
  3. See Pidgin plug-in post the notification's source markdown.

Expected Result / Possible Solutions

The markdown is converted to HTML or the rich formatting Pidgin supports to make it more readable.

Additional Info

  • Version: c01fddf
  • Operating System / Distribution: Arch Linux x86-64
  • Desktop Environment: GNOME 42
  • Kernel Version: 5.18.9
@EionRobb
Copy link
Owner

EionRobb commented Jul 9, 2022

Oh, weird! I didn't know messages could be either of html or markdown, I've only ever seen plain text or html

I think i need to add some additional debugging to be able to see exactly what the message coming though is, otherwise you'd have to pipe Pidgin through a proxy server (such as Charles proxy, burp or mitmproxy) to see what's coming though

Is it just gitlab that does this or is there another bot i could add to be able to see that?

@Gert-dev
Copy link
Author

Gert-dev commented Jul 11, 2022

We don't have any other plugins active that seem to do this, but I think this should work fine with a free GitLab account and private/public GitLab project. The panel to integrate it into a project can be found under Settings -> Integrations -> Microsoft Teams notifications and looks somewhat like this:

afbeelding

If you want, though, since I have a GitLab account, I can try setting up one of the integrations with a Teams instance of your choosing so you can see the data that comes in and try to cause a few notifications to emit on your signal.

@gardar
Copy link

gardar commented Apr 9, 2024

I'm definitely interested in markdown rendering as I use markdown quite a lot in chats, for code blocks, bulleted lists, highlights, etc.
But perhaps it should be a separate plugin so that other protocols would benefit from it?

@gardar
Copy link

gardar commented Apr 10, 2024

Actually it looks like there is some markdown rendering support in other @EionRobb plugins already.

https://github.com/EionRobb/purple-discord/blob/master/markdown.c
https://github.com/EionRobb/purple-mattermost/blob/master/libmattermost-markdown.c
https://github.com/EionRobb/telegram-purple?tab=readme-ov-file#code-tags

So perhaps it's easy to implement in purple-teams?

@EionRobb
Copy link
Owner

Yeah should be doable, i just need to sort out the debugging situation to show more of the low level stuff to see exactly what comes through to be able to parse it.

@EionRobb
Copy link
Owner

Looking at this some more, the messages are currently just dumped verbatim (eg the messages in #49) and there's a TODO in the code to parse it

//TODO process JSON blob of a Card into something vaguely HTML
. Looks like there's 7 potential types of Cards that can end up in there (based on https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#card-types ) but 3 being the most common (based on https://stackoverflow.com/questions/67921711/microsoft-teams-cards-as-html ), The webhooks I've set up on a test account mostly look like this one though https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-reference#example-of-a-connector-card-for-microsoft-365-groups

EionRobb added a commit that referenced this issue Apr 28, 2024
@EionRobb
Copy link
Owner

Added support for one of the 7 types, which should hopefully cover most incoming webhooks

@abwillis
Copy link

Works for the ones I had reported in #49.

@EionRobb
Copy link
Owner

Looks like the after-call recording notices are also Cards using a different format. Will add support for that one next.

@EionRobb
Copy link
Owner

EionRobb commented May 1, 2024

They're a bit scruffy looking, but I've added in support for a few more card types: Adaptive, Image/Video/Media, Hero/Thumnail. Adaptive Cards are the trickiest, since they're allowed to have columns but Pidgin doesn't support <table> or something that vaguely resembles them. They don't currently download and inline any of the images that they might reference, but would love some feedback!

@gardar
Copy link

gardar commented May 29, 2024

Any chance markdown code blocks could be rendered differently than regular text?

Not sure whats possible with pidgin, but something as simple as using a different (monospace) font would be beneficial. Although Syntax highlighting such as in PiFo would be a absolute killer.
https://raw.githubusercontent.com/forflo/PiFo/master/screenshots/hask.png

@EionRobb
Copy link
Owner

Any chance markdown code blocks could be rendered differently than regular text?

Do you have a side-by-side screenshot of how it looks in Pidgin vs Teams that you could share? First step is getting it to render at least the same, before adding any extra hotness on top 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants