Add helpers for getting prev and auth events (#4139)

* Add helpers for getting prev and auth events

This is in preparation for allowing the event format to change between
room versions.
This commit is contained in:
Erik Johnston 2018-11-05 13:35:15 +00:00 committed by Amber Brown
parent 0467384d2f
commit bc80b3f454
10 changed files with 62 additions and 45 deletions

View file

@ -159,6 +159,24 @@ class EventBase(object):
def keys(self):
return six.iterkeys(self._event_dict)
def prev_event_ids(self):
"""Returns the list of prev event IDs. The order matches the order
specified in the event, though there is no meaning to it.
Returns:
list[str]: The list of event IDs of this event's prev_events
"""
return [e for e, _ in self.prev_events]
def auth_event_ids(self):
"""Returns the list of auth event IDs. The order matches the order
specified in the event, though there is no meaning to it.
Returns:
list[str]: The list of event IDs of this event's auth_events
"""
return [e for e, _ in self.auth_events]
class FrozenEvent(EventBase):
def __init__(self, event_dict, internal_metadata_dict={}, rejected_reason=None):