matterhorn
matterhorn copied to clipboard
Add support for attachments provided in post props
At present, if a post comes in with an attachment and no text, nothing is rendered.
Per the docs:
fallback: A required plain-text summary of the post. This is used in notifications, and in clients that don’t support formatted text (eg IRC).
It would be nice if Matterhorn would render this fallback text instead of nothing.
Oh, thanks - we didn't know about that!
Oh, interesting. It appears matterhorn does render the fallback message if the message type is in_channel
but not ephemeral
.
Interesting - I'll have to take a look.
Oh, interesting. It appears matterhorn does render the fallback message if the message type is in_channel but not ephemeral.
Can you elaborate on what you observed to draw this conclusion? The message types you mentioned only apply to "command responses," and Matterhorn never considers the command response type when deciding how to render anything.
It would also help if you could provide an example of how such a message gets posted. For example, if I go to the web client and post a message with just an (image) attachment and no text, Matterhorn shows the attachment filename, e.g.,
[15:10] user:
[attached: `image.png`]
So that makes me wonder if the attachments in your case have a different structure.
While developing a custom slash command, I set the response_type
to ephemeral
so as not to clutter the channel while testing the output.
Example, in the web client:
In Matterhorn:
When I change response_type
to in_channel
after finishing up, I see the fallback
text in Matterhorn as expected:
Here is the JSON response being provided by the webhook:
{"response_type": "ephemeral", "attachments": [{"author_name": "Callook", "title_link": "https://callook.info/n8vnr", "title": "N8VNR", "author_icon": "https://callook.info/favicon.ico", "author_link": "https://callook.info", "fallback": "N8VNR, KEVIN J OTTE, HILLSBOROUGH, NC 27278, EXTRA - https://callook.info/n8vnr", "fields": [{"title": "Name", "value": "KEVIN J OTTE", "short": true}, {"title": "Class", "value": "EXTRA", "short": true}, {"title": "Location", "value": "HILLSBOROUGH, NC 27278", "short": true}]}]}
Would it be possible for you to:
- Enable logging in Matterhorn (with
-l
at startup, or with/log-start
at runtime) - Post such a message as demonstrated above while logging is in progress
- Either post the log here or, if you aren't comfortable with that, send it to me at
jtd AT galois DOT com
As requested: attachment-debug.log
It occurs to me I should probably log a working one for you to compare with: attach-inchannel.log
Thanks; your first log gave me enough to go on. The issue is that our support for "ephemeral" posts is very limited. Currently Matterhorn doesn't look at any aspect of the ephemeral post except the text, which is why you aren't seeing anything in the case described here. I'll discuss this with the server developers and I'll update here when there's progress. Thanks for all the details!
Alrighty. I realize this has turned into something of a corner case, so if it's not going to be an easy fix I understand if you want to close it out.
Oh, not at all - this is definitely worth fixing and just goes to show how often we Matterhorn developers encounter this kind of message (never). :)
From Harrison H., ephemeral posts persist only until the client is restarted. For our purposes is this equivalent to another message abstraction we already have, so that's good. Now that I've confirmed there's no new functionality we need to support there, this ticket is just about improving how those incoming ephemeral messages are presented.
@nivex out of curiosity, do you run Matterhorn from a binary release, or do you build it from source?
Binary release.
After asking around on the Mattermost dev team, it turns out that the docs are not quite right: the fallback message is intended to be displayed in place of the attachment, not the post, if the attachment cannot be displayed. And Matterhorn can display all attachments, because it doesn't display the contents.
Matterhorn definitely does not bother displaying attachments of ephemeral posts. It turns out Matterhorn does not handle attachments at all, for any posts, if those attachments are delivered as part of the post's props
/attachments
list. Matterhorn only looks at file attachments, which, strangely enough, are represented elsewhere in the JSON data.
So I think this boils down to: Matterhorn doesn't support "attachments" (Slack parlance) at all, and if it did, it would need to honor the fallback
message if it was provided.
To round this out even further, the Matterhorn devs state that the content of the attachments
field is undefined, i.e., it could contain anything and you had better be able to deal with that. Which means we can do our best to handle the contents, but there could be issues and we may have to omit attachment metadata if it cannot be reliably parsed.
Due to extremely limited time on my part, I'm going to close this as something I am not going to be able to prioritize. If this needs to be prioritized in the future, let's re-open it or create a new ticket.