You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: topic_timestamp_changer.rb
    path of file: ./repos/discourse/app/services
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class TopicTimestampChanger
  class InvalidTimestampError < StandardError
  end

  def initialize(timestamp:, topic: nil, topic_id: nil)
    @topic = topic || Topic.with_deleted.find(topic_id)
    @posts = @topic.posts
    @current_timestamp = Time.zone.now
    @timestamp = Time.zone.at(timestamp)

    raise InvalidTimestampErr
    
  def change!
    ActiveRecord::Base.transaction do
      last_posted_at = @timestamp

      @posts.each do |post|
        if post.is_first_post?
          update_post(post, @timestamp)
        else
          new_created_at = Time.at(post.created_at.to_f + @time_difference)
          new_created_at = @current_timestamp if new_created_at > @current_timestamp
          last_posted_at = new_created_at if new_created_at > last_posted_at
          update_post(post, new_created_at)
        end
      end

      @topic.reset_bumped_at
      update_topic(last_posted_at)

      yield(@topic) if block_given?
    end