application_build_checksum.rb 762 B

1234567891011121314151617181920212223
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Queries
  3. class ApplicationBuildChecksum < BaseQuery
  4. description 'Checksum of the currently built front-end application. If this changes, the front-end(s) should reload.'
  5. type String, null: false
  6. def self.authorize(...)
  7. true # This query should be available for all (including unauthenticated) users.
  8. end
  9. def resolve(...)
  10. # Use a stable identifier for the development environment, as we use hot reloading there instead.
  11. return 'development-auto-build' if Rails.env.development?
  12. filename = Rails.public_path.join('assets/frontend/vite/.vite/manifest.json')
  13. Digest::MD5.hexdigest(File.read(filename))
  14. end
  15. end
  16. end