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

Attachments #17

Closed
turt2live opened this issue Jul 11, 2017 · 15 comments
Closed

Attachments #17

turt2live opened this issue Jul 11, 2017 · 15 comments

Comments

@turt2live
Copy link
Owner

turt2live commented Jul 11, 2017

ref: https://api.slack.com/docs/message-attachments

The fallback should be treated as plain text (no formatting) and is used when the client (matrix) doesn't support the message.

Color / pretext

color: good, warning, danger, or any hex code like #439FE0

Slack renders this like:
image

we'll render it like this:
image
image

Attachments are otherwise rendered with a grey line. It's unfortunate that matrix doesn't support the line wrapping (pre-text) thing, but this will work for now.

This would be pretext<br>
<font color='#d9534f'>▌</font> danger is #d9534f<br>
<font color='#f0ad4e'>▌</font> warning is #f0ad4e<br>
<font color='#5cb85c'>▌</font> good is #5cb85c<br>
<font color='#439fe0'>▌</font> custom is #439fe0

Pretext is pretext

Use #f7f7f7 for default.

Authors

author_name, author_link, author_icon

image

<img src='mxc://t2bot.io/hcSELkhLCNMRxLLTXKffPPSn' width='16' height='16'> <a href='https://matrix.to/#/user/@voyager:t2bot.io'>Matrix Traveler</a>

Although the image may need cropping ahead of time.

Titles

title, title_link
image

Basically an h3 as an anchor

Fields

fields is an array of {title, value, short}. short is optional.
image

Images

image_url
image

thumb_url
image

Footers

footer and footer_icon (text & image). Treat much like the authors
image

ts (timestamp) - seconds since epoch

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

Hey. There's a veeeery crude implementation here. Feel free to have a look and you know.. provide some feedback.

Some notes (apart from code being a mess)

  • Images aren't working because they need to be uploaded
  • The sidebar looks ok in the synapse webclient but not much so in Riot Doneish
  • Fields doesn't really behave like Slack, they ignore the short thingy Kinda done
  • Maybe ditch the "bar" thing and use blockquote? Or just use the bar for title/pretext or something Done
  • Maybe not use h3 for title because margins and whatnot Done
  • Stuff like <https://honeybadger.io/path/to/event/|ReferenceError> from Slacks Honeybadger example isn't working but that would be fixed in Process slack links #14 I believe?

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

screen shot 2017-09-13 at 16 15 56

This is what it looks like in Riot atm

@turt2live
Copy link
Owner Author

The issue with using blockquotes would be that Riot strips all attempts at coloring it. Although that might be solved with a patch to Riot. I'll see if I can squeeze the patch in, but for now using blockquote should be fine.

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

That would be awesome! So ditch the bar thing?

Also I think I'll add a <br> after field title like in Slack. The table like formatting we'll have to live without tho

@turt2live
Copy link
Owner Author

Yea, ditch the bar thing and replace it with <blockquote style="border-color: #whatever;">...</blockquote>.

Technically Riot supports tables, they're just really ugly. A <br> is probably better.

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

screen shot 2017-09-13 at 19 20 35

Looks pretty decent?!

About the images, I guess I could use the util.uploadContentFromUrl somehow?

@turt2live
Copy link
Owner Author

Yea, it's just a promise thing. The avatar code should give a somewhat dirty example on how to use it.

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

I think I might drop the <h3> though.. h4 looks like bold on iOS and slightly larger on Riot desktop

@joenas
Copy link
Contributor

joenas commented Sep 13, 2017

Yea, it's just a promise thing. The avatar code should give a somewhat dirty example on how to use it.

Put it in its own layer, before slack_attachments? Is it possible for it to not resolve before the next layer starts doing its thing?
Also it needs bridge, which it guess we'd have to send as an argument to each layer?

@turt2live
Copy link
Owner Author

The layer can return a promise and it'll block on that.

@joenas
Copy link
Contributor

joenas commented Sep 14, 2017

screen shot 2017-09-14 at 11 38 06

Image uploading done! Anything else or should I create a PR and you can tear my JS-skillz apart? 😛
I opted to create a new class for the image uploading instead of a layer but injected in the layers.. kind of. It felt better to me but 🤷‍♂️

@joenas
Copy link
Contributor

joenas commented Sep 14, 2017

Maybe squash the commits?

@turt2live
Copy link
Owner Author

Opening a PR would probably be best so it's easier to see the changes.

@joenas joenas mentioned this issue Sep 14, 2017
3 tasks
@ghost ghost added the next label Sep 14, 2017
@ghost ghost removed the next label Sep 17, 2017
@turt2live
Copy link
Owner Author

Added. Thanks @joenas !

@werkkrew
Copy link

werkkrew commented Feb 1, 2020

Is supporting the "thumb_url" or "icon_url" slack message parameters in the plans? For example, I have a payload like this:


{
	"username":"PlexBot",
	"text":"Plex (Foo)\r\nAmerican Dharma was recently added to Plex.",
	"attachments":
	[{
		"title":"American Dharma (2019)",
		"text":"A portrait of controversial Breitbart honcho and Donald Trump advisor, Stephen K. Bannon.",
		"title_link":"https://www.imdb.com/title/tt8804284",
		"fields":
		[{
			"short":true,
			"value":"<https://www.imdb.com/title/tt8804284|IMDb>",
			"title":"View Details"
		}],
		"fallback":"Image for American Dharma (2019)",
		"thumb_url":"https://i.imgur.com/HzH2885.jpg"
	}],
	"icon_url":"https://i.imgur.com/iF8m9LE.png"
}

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

No branches or pull requests

3 participants