matrix-org/matrix-angular-sdk — pull request #3 by Kegsay (2014-12-17 14:49:48+00:00)
Title: Content repo v2 and annotated events

Annotated Events
------------------------
Events were previously just "plain old JS objects". This wasn't great because you couldn't add extra information ("annotations") about the event, such as the ``RoomMember`` who sent the event, or the sending status without ugly namespacing of keys e.g. ``event.__room_member``. What's worse, these "internal" keys would often leak when double-clicking on a message to view the event JSON since it was easy to forget to pop them from the event before displaying the dialog. This branch fixes this by introducing an ``AnnotatedEvent`` object which wraps the raw event. This allows annotations to sit alongside the event without occupying the same object e.g. the RoomMember is now ``annotatedEvent.sender`` whilst the event itself is ``annotatedEvent.event``. This also makes it possible to add helper functions to the events themselves, which can then be used in the html templates, such as the newly introduced ``httpUri`` for the content repo.

The downside to this is that a lot of code had to be touched to add in the extra nested layer. In addition, some variable names had to be changed to become clearer as to whether they were returning the event or an ``AnnotatedEvent``.

Content Repo v2
-----------------------
A new version of the content repository was added and docced at:
https://github.com/matrix-org/synapse/blob/develop/synapse/media/v1/media_repository.py#L28

This branch makes the web client use the new content repo. Other than uploading to a different endpoint (which is easy enough), it now requests thumbnails for ``mxc://`` style URIs. ``m.image`` is now looks like:
```
{
"content": {
"body": "cat_joy.png",
"info": {
"h": 300,
"mimetype": "image/png",
"size": 212106,
"w": 485
},
"msgtype": "m.image",
"url": "mxc://localhost/JdmQqlSpsYiPjqBXFEIWGbku"
},
"depth": 24,
"event_id": "$141882635528skiiY:localhost",
"origin": "localhost",
"origin_server_ts": 1418826355163,
"room_id": "!FLkGjoItsuSJhDANyt:localhost",
"type": "m.room.message",
"unsigned": {
"age": 94
},
"user_id": "@foobar:localhost"
}
```