Open Tjird opened 6 years ago
If I understand the problem correct, you want the slack message attachments (https://api.slack.com/docs/message-attachments) to be sent to mattermost? (we're not talking about file attachments?)
Are you getting attachments which are missing the fallback
property so that you don't get a message on mattermost?
My issue with this is that the only bridge that supports slack attachments beside slack is mattermost. I want to keep stuff as generic as possible between the different bridges, so I'm not going to add this option at the moment.
Yes, I want that the whole slack attachments part is being sent through the bridge. And yes we are not talking about file attachments. The message has got the fallback property filled in, I'm getting a message but not the whole message that I got in slack.
I can understand your issue about this, it's easier the get everything nearly the same.
@42wim I have done some more research and it looks like the bot is sending only the Title and Text in the attachment part through, is this correct?
I also have a question on your answer, is it not possible to add an argument in the config file that sounds like SlackAttachments
. If this argument is set to true is sends the whole attachment part through and if it is set to false it stays the same as now a day. Is this an option?
Correct, if the Text
is not empty it uses the Text
and Title
. If the Text
is empty it uses Fallback
Yes, everything is possible, it just takes work :-)
I don't know if this is the issue for me, but some of the info/messages from github-bot on slack wont cross the bridge to mattermost:
Slack message: [osmc/osmc] New comment by samnazarko on issue "hashtag"534: [Installer] An error occurred while writing the image! Please consult logfile I've updated to Catalina's .1 point release, so can test this shortly.
Mattermost post: I've updated to Catalina's .1 point release, so can test this shortly.
Missing all the data on who posted and on which issue wher issue number and description is a link to issue on github.
We prefer the Slacks Github-bot to the Mattermost Github-bot.
@42wim I'm have no experiense with go at all, luckily VS-code has a go-lang plugin, forked this repository and cloned it localy and started to read through the code to the best of my general programming knowledge. I think i might have identified whats my problem. In short mattermost should convert the slack <url|linkdescription> but slack bridge never gives the bridge the data, I send this in slack: Okey [nl] \<http://google.com|Link-descrtiption >, text after desction-text that is a url [alot of other formating text testing] what is in debug log: "[0144] DEBUG slack: <= Message is &config.Message{Text:"Okey\nhttp://google.com/ , text after desction-text that is a url\n"
Since I'm no Go coder, i'm wondering is it in matterbridge slack "reader" or the slack webhook that stipps the "|description" part?
Been reading and playing around with the code, still have to Google 50% of the code to understand it somewhat. But from what I've gathered, Matterbridge was built with Matter most v. 4 api. Been reading up on v 5 and it's now possible to sent attachments via Api using post.prop.
Anyway, what I' wondering about is that if I write a code draft, which enable most slack-attachments in bridge out on mattermost, enabled via a config key in [matter most]. It will probably never pass code-checks for a matterbridge pr. Due to my complete lack of code optimization in golang.
Is there someone that can help a golang newbie to go from newbie draft to actual code that can be PR'ed?
After some more tinkering I did have a semi working solution: In bridge/slack/handlers.go HandleAttachments, if msg.extra != "", I added code that parsed attachments and contructed a msg.text with data derived from attachments, drawback any linebreak added to msg.txt to part header (attachment pretext + \n +title+title_link)) \n original msg.text/attachemt.txt(handle the links to mattermost-links) \n footer (attachment footer+footer_link). This was never gonna be accepted as a pr, and since it didn't accept my \n I scrapped the ide.
Next try, in bridge/mattermost/mattermost.go Send-function. Trying convert slackattachments from msg.Extra["slack_attachment" , converting for example AuthorName to author_name and change any slack-link to a mattermost link in fallback, pretext, text and footer. Ran into a problem two folded problem, no PostMessageProp in matterclient/messages.go(which i fixed, but late scrapped) and ranging msg.extra["slack_attachment"] din't populate properly (PEBKAC). Realized again that this wasn't the proper place for the code.
Last try, and this is where I am right now, in bridge/helper/helper.go "func HandleSlackAttachments" I thought it was a good idea to do the work needed:
check if Slack2MMattachment is set in toml (cant use IsKeySet, since i don't have a bridge to reference)
extract the need and parse info,
create a "footer-string" in msg.txt, by extracting attachment.footer attachment.footericon then set msg.text = attachment.text/msg.txt + footer-string.
@42wim any suggestions on how I can check if a key is set in toml, from bridge/helper/helper.go
If I manage to solve this, a MM2SlackAttachment funtion shouldn't be hard
Is your feature request related to a problem? Please describe. As far as I know not, looked into the issues that already exist.
Describe the solution you'd like Solution doesn't exist, it's a feature request.
Describe alternatives you've considered Alternative doesn't exist, it's a feature request.
Additional context Add support to send the whole attachment through the message. Now a day if the message doens't have text it is looking to the text in the attachment part. I have tested it with a webhook and user and doens't work atm.