def resolve_message_ids(self, entity):
    ctx = self.manager.stage.job.dataset.name
    for message_id in entity.get('messageId'):
        key = self.cache_key('mid-ent', ctx, message_id)
        self.add_cache_set(key, entity.id)
        rev_key = self.cache_key('ent-mid', ctx, message_id)
        for response_id in self.get_cache_set(rev_key):
            if (response_id == entity.id):
                continue
            email = self.manager.make_entity('Email')
            email.id = response_id
            email.add('inReplyToEmail', entity.id)
            fragment = safe_fragment(message_id)
            self.manager.emit_entity(email, fragment=fragment)
    for message_id in entity.get('inReplyTo'):
        key = self.cache_key('mid-ent', ctx, message_id)
        for email_id in self.get_cache_set(key):
            if (email_id != entity.id):
                entity.add('inReplyToEmail', email_id)
        rev_key = self.cache_key('ent-mid', ctx, message_id)
        self.add_cache_set(rev_key, entity.id)
def resolve_message_ids(self, entity):
    ctx = self.manager.stage.job.dataset.name
    for message_id in entity.get('messageId'):
        key = self.cache_key('mid-ent', ctx, message_id)
        self.add_cache_set(key, entity.id)
        rev_key = self.cache_key('ent-mid', ctx, message_id)
        for response_id in self.get_cache_set(rev_key):
            if (response_id == entity.id):
                continue
            email = self.manager.make_entity('Email')
            email.id = response_id
            email.add('inReplyToEmail', entity.id)
            fragment = safe_fragment(message_id)
            self.manager.emit_entity(email, fragment=fragment)
    for message_id in entity.get('inReplyTo'):
        key = self.cache_key('mid-ent', ctx, message_id)
        for email_id in self.get_cache_set(key):
            if (email_id != entity.id):
                entity.add('inReplyToEmail', email_id)
        rev_key = self.cache_key('ent-mid', ctx, message_id)
        self.add_cache_set(rev_key, entity.id)