'Edit the appservice/network specific public room list.
Each appservice can have a number of published room lists associated
with them, keyed off of an appservice defined `network_id`, which
basically represents a single instance of a bridge to a third party
network.
Args:
room_id (str)
appservice_id (str)
network_id (str)
is_public (bool): Whether to publish or unpublish the room from the
list.'

@defer.inlineCallbacks
def set_room_is_public_appservice(self, room_id, appservice_id, network_id, is_public):

    def set_room_is_public_appservice_txn(txn, next_id):
        if is_public:
            try:
                self._simple_insert_txn(txn, table='appservice_room_list', values={'appservice_id': appservice_id, 'network_id': network_id, 'room_id': room_id})
            except self.database_engine.module.IntegrityError:
                return
        else:
            self._simple_delete_txn(txn, table='appservice_room_list', keyvalues={'appservice_id': appservice_id, 'network_id': network_id, 'room_id': room_id})
        entries = self._simple_select_list_txn(txn, table='public_room_list_stream', keyvalues={'room_id': room_id, 'appservice_id': appservice_id, 'network_id': network_id}, retcols=('stream_id', 'visibility'))
        entries.sort(key=(lambda r: r['stream_id']))
        add_to_stream = True
        if entries:
            add_to_stream = (bool(entries[(-1)]['visibility']) != is_public)
        if add_to_stream:
            self._simple_insert_txn(txn, table='public_room_list_stream', values={'stream_id': next_id, 'room_id': room_id, 'visibility': is_public, 'appservice_id': appservice_id, 'network_id': network_id})
    with self._public_room_id_gen.get_next() as next_id:
        (yield self.runInteraction('set_room_is_public_appservice', set_room_is_public_appservice_txn, next_id))
    self.hs.get_notifier().on_new_replication_data()
