'We\'ve got an invite event. Process and persist it. Sign it.
Respond with the now signed event.'

@defer.inlineCallbacks
def on_invite_request(self, origin, pdu):

    event = pdu
    is_blocked = (yield self.store.is_room_blocked(event.room_id))
    if is_blocked:
        raise SynapseError(403, 'This    room    has    been    blocked    on    this    server')
    membership = event.content.get('membership')
    if ((event.type != EventTypes.Member) or (membership != Membership.INVITE)):
        raise SynapseError(400, 'The    event    was    not    an    m.room.member    invite    event')
    sender_domain = get_domain_from_id(event.sender)
    if (sender_domain != origin):
        raise SynapseError(400, 'The    invite    event    was    not    from    the    server    sending    it')
    if (event.state_key is None):
        raise SynapseError(400, 'The    invite    event    did    not    have    a    state    key')
    if (not self.is_mine_id(event.state_key)):
        raise SynapseError(400, 'The    invite    event    must    be    for    this    server')
    event.internal_metadata.outlier = True
    event.internal_metadata.invite_from_remote = True
    event.signatures.update(compute_event_signature(event, self.hs.hostname, self.hs.config.signing_key[0]))
    context = (yield self.state_handler.compute_event_context(event))
    (event_stream_id, max_stream_id) = (yield self.store.persist_event(event, context=context))
    target_user = UserID.from_string(event.state_key)
    self.notifier.on_new_room_event(event, event_stream_id, max_stream_id, extra_users=[target_user])
    defer.returnValue(event)
