maintenance.rb 981 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Copyright (C) 2012-2022 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::ZammadSchema.subscriptions.trigger(
  18. Gql::Subscriptions::PushMessages.field_name,
  19. {},
  20. {
  21. title: data['head'],
  22. text: data['message'],
  23. }
  24. )
  25. false
  26. end
  27. end