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

MSC2765: Widget avatars #2765

Merged
merged 4 commits into from
Nov 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions proposals/2765-widget-avatars.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# MSC2765: Widget avatars
Copy link
Contributor

@Sorunome Sorunome Sep 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Widgets aren't in the spec at all yet, a ctrl+f on the unstable c-s api for "widget" or "m.custom" yields nothing. If you are building on an existing MSC, please link it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's specifically not linked due to pending spec pr: #2764

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah great, thank you


Currently widgets have a name and title associated with them, though no opportunity for avatars
for a favicon-like experience. This proposal introduces such a concept.

## Proposal

A new optional paramater named `avatar_url` is added to the widget definition. This parameter is
an MXC URI to an image clients can use to associate with the widget, likely alongside the `name`
and/or `title`.

Widget avatars SHOULD be legible at small sizes, such as 20x20. The MXC URI in the `avatar_url`
should be the source material to allow clients to use the `/thumbnail` API to get a size for their
use case.

Rendering avatars is optional for clients, much like how clients are not required to use the `name`
or `title` of a widget.

An example widget would be:

```json
{
"creatorUserId": "@alice:example.org",
"data": {
"custom_key": "This is a custom key",
"title": "This is a witty description for the widget"
},
"id": "20200827_WidgetExample",
"name": "My Cool Widget",
"type": "m.custom",
"url": "https://example.org/my/widget.html?roomId=$matrix_room_id",
"waitForIframeLoad": true,
"avatar_url": "mxc://example.org/abc123"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why is this using underscores when the other properties are using camel case?

Copy link
Member Author

@turt2live turt2live Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historical consistency: when the widget API was introduced years ago it was done as a mix, and this is in line with the perceived standard set forth.

Thought it was located somewhere else. Ideally we'd fix this over time to be all underscored

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair enough I guess.

}
```

## Alternatives

We could define a whole structured system for different thumbnail sizes, though we have a thumbnail
API which can be used to request whatever size is needed by the client.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One consideration is that you can significantly improve the quality of icons by having specific bitmaps for each size, so that extra detail can be included in larger icons but smaller ones can be simple. We don't necessarily need to do this now but since you've said above that avatar_url should look good at 20x20, it implies this avatar is intended to be displayed fairly small, so we could introduce other fields for more detailed icons in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, this is definitely something for a future MSC. I'd like to solve the general case of client-supplied thumbnails at the same time, possibly for user/room avatars too. Something like "when you display my avatar as 500x500, use this one". Abuse/lying about different avatars would be an interesting problem to solve though.


## Security considerations

Widget avatars could be non-images. Clients should use the thumbnail API to encourage error responses
from the server when a widget avatar is a non-image.

## Unstable prefix

While this MSC is not in a released version of the specification, clients should use an alternative
event type for widgets or use `org.matrix.msc2765.avatar_url` when using `m.widget` or `m.widgets`
as an event type.