'Retrieves events, pagination tokens and state around a given event
in a room.
Args:
user (UserID)
room_id (str)
event_id (str)
limit (int): The maximum number of events to return in total
(excluding state).
Returns:
dict, or None if the event isn\'t found'

@defer.inlineCallbacks
def get_event_context(self, user, room_id, event_id, limit):

    before_limit = math.floor((limit / 2.0))
    after_limit = (limit - before_limit)
    now_token = (yield self.hs.get_event_sources().get_current_token())
    users = (yield self.store.get_users_in_room(room_id))
    is_peeking = (user.to_string() not in users)
    def filter_evts(events):
        return filter_events_for_client(self.store, user.to_string(), events, is_peeking=is_peeking)
    event = (yield self.store.get_event(event_id, get_prev_content=True, allow_none=True))
    if (not event):
        defer.returnValue(None)
        return
    filtered = (yield filter_evts([event]))
    if (not filtered):
        raise AuthError(403, "You    don't    have    permission    to    access    that    event.")
    results = (yield self.store.get_events_around(room_id, event_id, before_limit, after_limit))
    results['events_before'] = (yield filter_evts(results['events_before']))
    results['events_after'] = (yield filter_evts(results['events_after']))
    results['event'] = event
    if results['events_after']:
        last_event_id = results['events_after'][(-1)].event_id
    else:
        last_event_id = event_id
    state = (yield self.store.get_state_for_events([last_event_id], None))
    results['state'] = state[last_event_id].values()
    results['start'] = now_token.copy_and_replace('room_key', results['start']).to_string()
    results['end'] = now_token.copy_and_replace('room_key', results['end']).to_string()
    defer.returnValue(results)
