Add {{presence_events}}. Factor out common code in MatrixSections.
This commit is contained in:
parent
9abadaf7af
commit
ac7ccfa622
3 changed files with 30 additions and 69 deletions
|
@ -38,38 +38,14 @@ outlined below.
|
||||||
Presence Events
|
Presence Events
|
||||||
~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
``m.presence``
|
{{presence_events}}
|
||||||
Summary:
|
|
||||||
Informs you of a user's presence state changes.
|
Each user has the concept of presence information. This encodes the
|
||||||
|
"availability" of that user, suitable for display on other user's clients.
|
||||||
Type:
|
This is transmitted as an ``m.presence`` event and is one of the few events
|
||||||
Presence event
|
which are sent *outside the context of a room*. The basic piece of presence
|
||||||
|
information is represented by the ``presence`` key, which is an enum of one
|
||||||
JSON format::
|
of the following:
|
||||||
|
|
||||||
{
|
|
||||||
"displayname": "utf-8 string",
|
|
||||||
"avatar_url": "url",
|
|
||||||
"presence": "enum [ online|unavailable|offline|free_for_chat|hidden ]",
|
|
||||||
"last_active_ago": "milliseconds"
|
|
||||||
}
|
|
||||||
|
|
||||||
Example::
|
|
||||||
|
|
||||||
{
|
|
||||||
"displayname": "Matthew",
|
|
||||||
"avatar_url": "mxc://domain/id",
|
|
||||||
"presence": "online",
|
|
||||||
"last_active_ago": 10000
|
|
||||||
}
|
|
||||||
|
|
||||||
Description:
|
|
||||||
Each user has the concept of presence information. This encodes the
|
|
||||||
"availability" of that user, suitable for display on other user's clients.
|
|
||||||
This is transmitted as an ``m.presence`` event and is one of the few events
|
|
||||||
which are sent *outside the context of a room*. The basic piece of presence
|
|
||||||
information is represented by the ``presence`` key, which is an enum of one
|
|
||||||
of the following:
|
|
||||||
|
|
||||||
- ``online`` : The default state when the user is connected to an event
|
- ``online`` : The default state when the user is connected to an event
|
||||||
stream.
|
stream.
|
||||||
|
@ -81,14 +57,14 @@ Presence Events
|
||||||
state anyway and generally interact with client features. (Not yet
|
state anyway and generally interact with client features. (Not yet
|
||||||
implemented in synapse).
|
implemented in synapse).
|
||||||
|
|
||||||
In addition, the server maintains a timestamp of the last time it saw a
|
In addition, the server maintains a timestamp of the last time it saw a
|
||||||
pro-active event from the user; either sending a message to a room, or
|
pro-active event from the user; either sending a message to a room, or
|
||||||
changing presence state from a lower to a higher level of availability
|
changing presence state from a lower to a higher level of availability
|
||||||
(thus: changing state from ``unavailable`` to ``online`` counts as a
|
(thus: changing state from ``unavailable`` to ``online`` counts as a
|
||||||
proactive event, whereas in the other direction it will not). This timestamp
|
proactive event, whereas in the other direction it will not). This timestamp
|
||||||
is presented via a key called ``last_active_ago``, which gives the relative
|
is presented via a key called ``last_active_ago``, which gives the relative
|
||||||
number of milliseconds since the message is generated/emitted that the user
|
number of milliseconds since the message is generated/emitted that the user
|
||||||
was last seen active.
|
was last seen active.
|
||||||
|
|
||||||
|
|
||||||
Events on Change of Profile Information
|
Events on Change of Profile Information
|
||||||
|
|
|
@ -14,7 +14,7 @@ class MatrixSections(Sections):
|
||||||
def render_spec_version(self):
|
def render_spec_version(self):
|
||||||
return "0.1.0"
|
return "0.1.0"
|
||||||
|
|
||||||
def _render_events(self, filterFn, sortFn):
|
def _render_events(self, filterFn, sortFn, title_kind="~"):
|
||||||
template = self.env.get_template("events.tmpl")
|
template = self.env.get_template("events.tmpl")
|
||||||
examples = self.units.get("event_examples")
|
examples = self.units.get("event_examples")
|
||||||
schemas = self.units.get("event_schemas")
|
schemas = self.units.get("event_schemas")
|
||||||
|
@ -24,24 +24,18 @@ class MatrixSections(Sections):
|
||||||
continue
|
continue
|
||||||
sections.append(template.render(
|
sections.append(template.render(
|
||||||
example=examples[event_name],
|
example=examples[event_name],
|
||||||
event=schemas[event_name]
|
event=schemas[event_name],
|
||||||
|
title_kind=title_kind
|
||||||
))
|
))
|
||||||
return "\n\n".join(sections)
|
return "\n\n".join(sections)
|
||||||
|
|
||||||
def render_room_events(self):
|
def render_room_events(self):
|
||||||
template = self.env.get_template("events.tmpl")
|
def filterFn(eventType):
|
||||||
examples = self.units.get("event_examples")
|
return (
|
||||||
schemas = self.units.get("event_schemas")
|
eventType.startswith("m.room") and
|
||||||
sections = []
|
not eventType.startswith("m.room.message#m.")
|
||||||
for event_name in sorted(schemas):
|
)
|
||||||
if (not event_name.startswith("m.room") or
|
return self._render_events(filterFn, sorted)
|
||||||
event_name.startswith("m.room.message#m.")):
|
|
||||||
continue
|
|
||||||
sections.append(template.render(
|
|
||||||
example=examples[event_name],
|
|
||||||
event=schemas[event_name]
|
|
||||||
))
|
|
||||||
return "\n\n".join(sections)
|
|
||||||
|
|
||||||
def render_msgtype_events(self):
|
def render_msgtype_events(self):
|
||||||
template = self.env.get_template("msgtypes.tmpl")
|
template = self.env.get_template("msgtypes.tmpl")
|
||||||
|
@ -67,23 +61,14 @@ class MatrixSections(Sections):
|
||||||
return "\n\n".join(sections)
|
return "\n\n".join(sections)
|
||||||
|
|
||||||
def render_voip_events(self):
|
def render_voip_events(self):
|
||||||
template = self.env.get_template("events.tmpl")
|
def filterFn(eventType):
|
||||||
examples = self.units.get("event_examples")
|
return eventType.startswith("m.call")
|
||||||
schemas = self.units.get("event_schemas")
|
return self._render_events(filterFn, sorted)
|
||||||
sections = []
|
|
||||||
for event_name in sorted(schemas):
|
|
||||||
if not event_name.startswith("m.call"):
|
|
||||||
continue
|
|
||||||
sections.append(template.render(
|
|
||||||
example=examples[event_name],
|
|
||||||
event=schemas[event_name]
|
|
||||||
))
|
|
||||||
return "\n\n".join(sections)
|
|
||||||
|
|
||||||
def render_presence_events(self):
|
def render_presence_events(self):
|
||||||
def filterFn(eventType):
|
def filterFn(eventType):
|
||||||
return eventType.startswith("m.presence")
|
return eventType.startswith("m.presence")
|
||||||
return self._render_events(filterFn, sorted)
|
return self._render_events(filterFn, sorted, title_kind="+")
|
||||||
|
|
||||||
def _render_ce_type(self, type):
|
def _render_ce_type(self, type):
|
||||||
template = self.env.get_template("common-event-fields.tmpl")
|
template = self.env.get_template("common-event-fields.tmpl")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
``{{event.type}}``
|
``{{event.type}}``
|
||||||
{{(4 + event.type | length) * '~'}}
|
{{(4 + event.type | length) * title_kind}}
|
||||||
*{{event.typeof}}*
|
*{{event.typeof}}*
|
||||||
{{event.typeof_info}}
|
{{event.typeof_info}}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue