Ejemplo n.º 1
0
    def make_routing_table(self, channels=(), conversations=(), routing=()):
        routing_table = {
            u'campaign_id': self.user_helper.account_key,
            u'channels': [],
            u'conversations': [],
            u'routers': [],
            u'routing_entries': [],
        }

        for channel in channels:
            routing_table[u'channels'].append(
                ChannelType.format_channel(channel))

        for conv in conversations:
            routing_table[u'conversations'].append(
                ConversationType.format_conversation(conv))

        # TODO: routers

        def mkconn(thing):
            if isinstance(thing, tuple):
                # It's a tuple, so assume it's a tag.
                return u'TRANSPORT_TAG:%s:%s' % thing
            else:
                # Assume it's a conversation.
                return u'CONVERSATION:%s:%s' % (thing.conversation_type,
                                                thing.key)

        for src, dst in routing:
            routing_table[u'routing_entries'].append(
                RoutingEntryType.format_entry((mkconn(src), 'default'),
                                              (mkconn(dst), 'default')))
        return routing_table
Ejemplo n.º 2
0
    def make_routing_table(self, channels=(), conversations=(), routing=()):
        routing_table = {
            u'campaign_id': self.user_helper.account_key,
            u'channels': [],
            u'conversations': [],
            u'routers': [],
            u'routing_entries': [],
        }

        for channel in channels:
            routing_table[u'channels'].append(
                ChannelType.format_channel(channel))

        for conv in conversations:
            routing_table[u'conversations'].append(
                ConversationType.format_conversation(conv))

        # TODO: routers

        def mkconn(thing):
            if isinstance(thing, tuple):
                # It's a tuple, so assume it's a tag.
                return u'TRANSPORT_TAG:%s:%s' % thing
            else:
                # Assume it's a conversation.
                return u'CONVERSATION:%s:%s' % (
                    thing.conversation_type, thing.key)

        for src, dst in routing:
            routing_table[u'routing_entries'].append(
                RoutingEntryType.format_entry(
                    (mkconn(src), 'default'), (mkconn(dst), 'default')))
        return routing_table
Ejemplo n.º 3
0
 def format_conversations(convs):
     return [ConversationType.format_conversation(c) for c in convs]