maintenance.rb 885 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Sessions::Event::Maintenance < Sessions::Event::Base
  3. database_connection_required
  4. =begin
  5. Event module to broadcast maintenance messages to all client connections.
  6. To execute this manually, just paste the following into the browser console
  7. App.WebSocket.send({event:'maintenance', data: {some: 'key'}})
  8. =end
  9. def run
  10. # check if sender is admin
  11. return if !permission_check('admin.maintenance', 'maintenance')
  12. Sessions.broadcast(@payload, 'public', @session['id'])
  13. # Maintenance mode start/stop messages are not needed for GraphQL, as clients
  14. # watch on changes of the config settings.
  15. data = @payload['data']
  16. return if data['type'] != 'message'
  17. Gql::Subscriptions::PushMessages.trigger({ title: data['head'], text: data['message'] })
  18. false
  19. end
  20. end