'Takes a list of receipts, stores them and informs the notifier.'

@defer.inlineCallbacks
def _handle_new_receipts(self, receipts):

    min_batch_id = None
    max_batch_id = None
    for receipt in receipts:
        room_id = receipt['room_id']
        receipt_type = receipt['receipt_type']
        user_id = receipt['user_id']
        event_ids = receipt['event_ids']
        data = receipt['data']
        res = (yield self.store.insert_receipt(room_id, receipt_type, user_id, event_ids, data))
        if (not res):
            continue
        (stream_id, max_persisted_id) = res
        if ((min_batch_id is None) or (stream_id < min_batch_id)):
            min_batch_id = stream_id
        if ((max_batch_id is None) or (max_persisted_id > max_batch_id)):
            max_batch_id = max_persisted_id
    if (min_batch_id is None):
        defer.returnValue(False)
    affected_room_ids = list(set([r['room_id'] for r in receipts]))
    with PreserveLoggingContext():
        self.notifier.on_new_event('receipt_key', max_batch_id, rooms=affected_room_ids)
        self.hs.get_pusherpool().on_new_receipts(min_batch_id, max_batch_id, affected_room_ids)
        defer.returnValue(True)
