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: reads_controller.rb
    path of file: ./repos/discourse/plugins/chat/app/controllers/chat/api
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

class Chat::Api::ReadsController < Chat::ApiController
  def update
    params.require(%i[channel_id message_id])

    with_service(Chat::UpdateUserLastRead) do
      on_success { render(json: success_json) }
      on_failure { render(json: failed_json, status: 422) }
      on_failed_policy(:ensu
    
  def update
    params.require(%i[channel_id message_id])

    with_service(Chat::UpdateUserLastRead) do
      on_success { render(json: success_json) }
      on_failure { render(json: failed_json, status: 422) }
      on_failed_policy(:ensure_message_id_recency) do
        raise Discourse::InvalidParameters.new(:message_id)
      end
      on_model_not_found(:message) { raise Discourse::NotFound }
      on_model_not_found(:active_membership) { raise Discourse::NotFound }
      on_model_not_found(:channel) { raise Discourse::NotFound }
      on_failed_policy(:invalid_access) { raise Discourse::InvalidAccess }
      on_failed_contract do |contract|
        render(json: failed_json.merge(errors: contract.errors.full_messages), status: 400)
      end
    end
  end