From c3a298a5dfb6666d800fc7a028f5a8a602ab6db5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 28 May 2015 11:35:18 +0100 Subject: [PATCH] Fix sort order for VoIP events. --- event-schemas/schema/v1/m.call.answer | 1 + templating/matrix_templates/sections.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/event-schemas/schema/v1/m.call.answer b/event-schemas/schema/v1/m.call.answer index 78b68ce1..598554f0 100644 --- a/event-schemas/schema/v1/m.call.answer +++ b/event-schemas/schema/v1/m.call.answer @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "This event is sent by the callee when they wish to answer the call.", "allOf": [{ "$ref": "core#/definitions/room_event" }], diff --git a/templating/matrix_templates/sections.py b/templating/matrix_templates/sections.py index a4a9c27f..0b94e100 100644 --- a/templating/matrix_templates/sections.py +++ b/templating/matrix_templates/sections.py @@ -63,7 +63,16 @@ class MatrixSections(Sections): def render_voip_events(self): def filterFn(eventType): return eventType.startswith("m.call") - return self._render_events(filterFn, sorted) + def sortFn(eventTypes): + ordering = [ + "m.call.invite", "m.call.candidates", "m.call.answer", + "m.call.hangup" + ] + rest = [ + k for k in eventTypes if k not in ordering + ] + return ordering + rest + return self._render_events(filterFn, sortFn) def render_presence_events(self): def filterFn(eventType):