-
Notifications
You must be signed in to change notification settings - Fork 379
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
Attaching data to messages #93
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
Abstract | ||
======== | ||
|
||
The specification does not define an extensible way to attach data to an | ||
``m.room.message`` event. Whilst we freely say that keys can be "anything you | ||
want", this does not ensure interoperability between client implementations | ||
which may have subtly different ways to express the same data. This proposal | ||
defines a set of **guidelines** which clients SHOULD use when attaching data to | ||
``m.room.message`` events. | ||
|
||
Motivation | ||
========== | ||
|
||
It would be nice to allow complex messages to be displayed to the client. For | ||
example, bringing up a JIRA issue and allowing the client to hit "assign to me" | ||
or "resolve" from within Matrix. This is currently hard to do because we don't | ||
contain fields with the information required in the message itself. Even rich | ||
text messages are not rich enough to provide this ability (which requires the | ||
client to know about JIRA, be able to get tokens and hit endpoints). With the | ||
anticipation that attaching data to messages will become prolific, this document | ||
tries to define a set of guidelines to get a more consistent representation of | ||
the same data. | ||
|
||
Proposal | ||
======== | ||
|
||
All custom data SHOULD be grouped under a ``data`` key. All subsequent keys | ||
mentioned are assumed to be contained under this key. | ||
|
||
Messages may be linked to an HTTP URL. This URL SHOULD be represented as a | ||
string under a ``link`` key. This link applies to the entire message (as if | ||
the message was wrapped in an ``<a>`` tag). Clients MAY choose to clobber this | ||
if URLs are present in the message body. | ||
|
||
Similarly, if a message contains an entity which can be represented as a URI | ||
(e.g. ``mailto``, ``irc``, ``xmpp``) it SHOULD be represented under a ``uri`` | ||
key. | ||
|
||
Contextual data for this message SHOULD be contained under a ``context`` key. | ||
If the message data is related to a website (Github, Google, Facebook, etc) then | ||
a string ``domain`` should be specified within ``context``. Likewise, if the | ||
message data involves an entity (a Facebook user, a Github user, etc) then a string | ||
``entity`` should be specified within ``context``. Extra data which only makes | ||
sense within the given context should be added as keys within the ``context`` | ||
object. | ||
|
||
|
||
:: | ||
|
||
type: "m.room.message", | ||
content: { | ||
msgtype: "m.text", | ||
body: "[matrix-org/matrix-ios-sdk] manuroe pushed 4 commits to develop", | ||
data: { | ||
"context": { | ||
"domain": "github.com", | ||
"entity": "manuroe", | ||
"commits": ["fe34764", "4cdd8ae", "528da705", "56bfc717"] | ||
} | ||
"link": "https://github.com/matrix-org/matrix-ios-sdk/commit/56bfc717", | ||
"uri": "https://github.com/matrix-org/matrix-ios-sdk.git" | ||
} | ||
} | ||
|
||
|
||
Rationale | ||
========= | ||
|
||
Extensible data is inserted under the ``data`` key to avoid polluting the | ||
top-level ``body`` namespace. | ||
|
||
Clients may wish to display messages which can be linkified. A standard way to | ||
represent this is desirable beyond manually parsing the ``body`` looking for | ||
"http-like" links. This also allows anything to be linked even if it doesn't | ||
look like a URL (e.g. random text, images). The intention of ``link`` is to | ||
allow an entire message to be clickable (e.g. linking through to git commits). | ||
If there are multiple links, the intention is that they are done in the body | ||
itself as HTTP URLs which are then linkified. | ||
|
||
The ``uri`` key exists to act as a "domain-specific" link, which only makes sense | ||
if you know how to process the URI. For example, an IRC message could have | ||
a ``link`` taking you to an IRC web-client to respond or a ``uri`` which contains | ||
the ``irc://`` room in which the user spoke. Knowledgeable clients who know how | ||
to process ``irc`` URIs can do so, but dumb clients can just display the ``link``. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've read this three times and I'm still not sure I can see the distinction between There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I mean by this is |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is expressive enough to be generally useful. For sure I can see uses, but I think restricting to one entity for the message is limiting.
Slack's API I think has this down pretty well; anything which has more context will be in a <> tag, and the context is on the left of a pipe, e.g.
"Just FYI, <@U1234|manuroe> pushed some commits, yo"
would turn manuroe into a link to the user with ID @U1234, but if your client doesn't understand, it would just print:
"Just FYI, manuroe pushed some commits, yo"
I could imagine having a list of entities in the data or context key, and being able to refer to them by index, e.g.
But I think limiting to a top-level context is slightly limiting.
I am not sure how I feel about by default having something which is always interpretable in body, or requiring a separate interpolated_body or something...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like your idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
Allowing multiple entities and allowing them to associate with specific parts of the message looks very nice - e.g. a Jenkins failure report relating to a git commit would probably have three or four different linkable entities.