Moved to support client notify via module application base.

This commit is contained in:
Martin Edenhofer 2013-06-29 02:13:03 +02:00
parent dcd01d5862
commit 53a0ee3eab
5 changed files with 12 additions and 33 deletions

View file

@ -1,29 +0,0 @@
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
require 'session'
class Observer::WebSocketNotify < ActiveRecord::Observer
observe :ticket, :user, 'ticket::_article'
def after_create(record)
# return if we run import mode
return if Setting.get('import_mode')
Session.broadcast(
:event => record.class.name.downcase + ':created',
:data => { :id => record.id, :updated_at => record.updated_at }
)
end
def after_update(record)
# return if we run import mode
return if Setting.get('import_mode')
puts "#{record.class.name.downcase} UPDATED " + record.updated_at.to_s
Session.broadcast(
:event => record.class.name.downcase + ':updated',
:data => { :id => record.id, :updated_at => record.updated_at }
)
end
end

View file

@ -7,6 +7,9 @@ class Ticket < ApplicationModel
before_create :number_generate, :check_defaults
before_update :check_defaults
before_destroy :destroy_dependencies
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
belongs_to :group
has_many :articles, :class_name => 'Ticket::Article', :after_add => :cache_update, :after_remove => :cache_update

View file

@ -6,6 +6,9 @@ class Ticket::Article < ApplicationModel
belongs_to :ticket_article_type, :class_name => 'Ticket::Article::Type'
belongs_to :ticket_article_sender, :class_name => 'Ticket::Article::Sender'
belongs_to :created_by, :class_name => 'User'
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
attr_accessor :attachments

View file

@ -8,6 +8,9 @@ class User < ApplicationModel
before_create :check_name, :check_email, :check_login, :check_image, :check_geo, :check_password
before_update :check_password, :check_image, :check_geo, :check_email, :check_login_update
after_create :notify_clients_after_create
after_update :notify_clients_after_update
after_destroy :notify_clients_after_destroy
has_and_belongs_to_many :groups, :after_add => :cache_update, :after_remove => :cache_update
has_and_belongs_to_many :roles, :after_add => :cache_update, :after_remove => :cache_update

View file

@ -41,8 +41,7 @@ module Zammad
'observer::_ticket::_notification',
'observer::_tag::_ticket_history',
'observer::_ticket::_reset_new_state',
'observer::_ticket::_escalation_calculation',
'observer::_web_socket_notify'
'observer::_ticket::_escalation_calculation'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]