From 7a2e2cd1d2e698798b37252f1141fe97f5fe0759 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 5 Oct 2014 20:33:43 +0200 Subject: [PATCH 1/8] Small code cleanup. --- .../app/controllers/getting_started.js.coffee | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/assets/javascripts/app/controllers/getting_started.js.coffee b/app/assets/javascripts/app/controllers/getting_started.js.coffee index e0d61a29e..39fca2688 100644 --- a/app/assets/javascripts/app/controllers/getting_started.js.coffee +++ b/app/assets/javascripts/app/controllers/getting_started.js.coffee @@ -39,7 +39,7 @@ class Index extends App.ControllerContent ) render: -> - + console.log('RENDER 1') # check authentication, redirect to login if master user already exists if !@master_user && !@authenticate() @navigate '#login' @@ -51,13 +51,13 @@ class Index extends App.ControllerContent new App.ControllerForm( el: @el.find('#form-master') model: App.User - required: 'signup' + screen: 'signup' autofocus: true ) new App.ControllerForm( el: @el.find('#form-agent') model: App.User - required: 'invite_agent' + screen: 'invite_agent' autofocus: true ) @@ -94,8 +94,7 @@ class Index extends App.ControllerContent # save user user.save( - done: (r) => - + done: => if @master_user @master_user = false App.Auth.login( @@ -106,7 +105,7 @@ class Index extends App.ControllerContent success: @relogin # error: @error, ) - + @Config.set('system_init_done', true) App.Event.trigger 'notify', { type: 'success' msg: App.i18n.translateContent( 'Welcome to %s!', @Config.get('product_name') ) @@ -123,13 +122,13 @@ class Index extends App.ControllerContent # rerender page @render() - fail: (data) -> - App.Event.trigger 'notify', { - type: 'error' - msg: App.i18n.translateContent( 'Can\'t create user!' ) - timeout: 2500 - } + fail: (data) -> + App.Event.trigger 'notify', { + type: 'error' + msg: App.i18n.translateContent( 'Can\'t create user!' ) + timeout: 2500 + } # @modalHide() ) From e302bed16a777855d2d554aac375d85cf535652a Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 10 Oct 2014 09:50:44 +0200 Subject: [PATCH 2/8] Added more unit tests. --- test/fixtures/mail24.box | 48 ++++++++++++++++++++++++++++++++++ test/fixtures/mail25.box | 36 +++++++++++++++++++++++++ test/unit/email_parser_test.rb | 41 ++++++++++++++++++++++++++++- 3 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/mail24.box create mode 100644 test/fixtures/mail25.box diff --git a/test/fixtures/mail24.box b/test/fixtures/mail24.box new file mode 100644 index 000000000..3bac30941 --- /dev/null +++ b/test/fixtures/mail24.box @@ -0,0 +1,48 @@ +Return-Path: oracle@ELIG0-1-DB01.example.com +Received: by ELIG0-1-DB01 (Postfix, from userid 1000) + id 1F4D8383B7; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from ELIG0-1-DB01 (static-62-50-37-197.irtnet.net [62.50.37.197]) + by mail2.mail.example.com (Postfix) with ESMTP + id 43854316E9; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from mail2.mail.example.com (perls.mail.example.com [195.30.107.84]) + by mail.example.com (Postfix) with ESMTP id 4DE3C471003F; + Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from mail.example.com ([127.0.0.1]) + by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id AtfOMc9Eru0V; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.example.com (Postfix) with ESMTP id 3C7B54710042; + Thu, 18 Sep 2014 09:30:06 +0200 (CEST) +Received: from mail.example.com (LHLO mail.example.com) (195.30.107.40) by + mail.example.com with LMTP; Thu, 18 Sep 2014 09:30:06 +0200 (CEST) +Date: Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +From: oracle@IG0-1-DB01.example.com +To: support@example.com +Subject: Regelsets im Test-Status gefunden: 1 +Message-ID: <279749720.2270042.1412150446700.JavaMail.root@mail.example.com> +Content-Type: multipart/mixed; + boundary="=_ddc0e1e5-3d61-45a1-88f4-7f1b332d2495"; generated=true +X-Virus-Scanned: amavisd-new at mail.example.com +X-Spam-Flag: NO +X-Spam-Score: -1.897 +X-Spam-Level: +X-Spam-Status: No, score=-1.897 tagged_above=-10 required=6.6 + tests=[BAYES_00=-1.9, FSL_HELO_NON_FQDN_1=0.001, HELO_NO_DOMAIN=0.001, + TO_NO_BRKTS_PCNT=0.001] autolearn=ham +MIME-Version: 1.0 + +--=_ddc0e1e5-3d61-45a1-88f4-7f1b332d2495 +Content-Type: text/plain +Content-Transfer-Encoding: 7bit + + + +--=_ddc0e1e5-3d61-45a1-88f4-7f1b332d2495 +Content-Type: text/csv +Content-Disposition: attachment; filename=rulesets-report.csv +Content-Transfer-Encoding: 7bit + +RULESET_ID;NAME;ACTIV;RUN_MODE;AUDIT_MODIFY_DATE +387;DP DHL JOIN - EN : Einladung eAC;T;SM;1.09.14 + +--=_ddc0e1e5-3d61-45a1-88f4-7f1b332d2495-- diff --git a/test/fixtures/mail25.box b/test/fixtures/mail25.box new file mode 100644 index 000000000..1fb67a639 --- /dev/null +++ b/test/fixtures/mail25.box @@ -0,0 +1,36 @@ +Return-Path: oracle@IG0-1-DB01.example.com +Received: from mail.example.com (LHLO mail.example.com) (195.30.107.40) by + mail.example.com with LMTP; Thu, 18 Sep 2014 09:30:06 +0200 (CEST) +Received: from localhost (localhost.localdomain [127.0.0.1]) + by mail.example.com (Postfix) with ESMTP id 3C7B54710042; + Thu, 18 Sep 2014 09:30:06 +0200 (CEST) +X-Virus-Scanned: amavisd-new at mail.example.com +X-Spam-Flag: NO +X-Spam-Score: -1.897 +X-Spam-Level: +X-Spam-Status: No, score=-1.897 tagged_above=-10 required=6.6 + tests=[BAYES_00=-1.9, FSL_HELO_NON_FQDN_1=0.001, HELO_NO_DOMAIN=0.001, + TO_NO_BRKTS_PCNT=0.001] autolearn=ham +Received: from mail.example.com ([127.0.0.1]) + by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id AtfOMc9Eru0V; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from mail2.mail.example.com (perls.mail.example.com [195.30.107.84]) + by mail.example.com (Postfix) with ESMTP id 4DE3C471003F; + Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: from IG0-1-DB01 (static-62-50-37-197.irtnet.net [62.50.37.197]) + by mail2.mail.example.com (Postfix) with ESMTP + id 43854316E9; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +Received: by IG0-1-DB01 (Postfix, from userid 1000) + id 1F4D8383B7; Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +To: support@example.com +Subject: Regelsets im Test-Status gefunden: 1 +Message-Id: <20140918073001.1F4D8383B7@IG0-1-DB01> +Date: Thu, 18 Sep 2014 09:30:01 +0200 (CEST) +From: oracle@IG0-1-DB01.example.com + +begin 644 rulesets-report.csv +M4E5,15-%5%])1#M.04U%.T%#5$E6.U)53E]-3T1%.T%51$E47TU/1$E&65]$ +M051%"C,X-SM$4"!$2$P@2D])3B`M($5.(#H@16EN;&%D=6YG(&5!0SM4.U-- +*.S$W+C`Y+C$T"@`` +` +end diff --git a/test/unit/email_parser_test.rb b/test/unit/email_parser_test.rb index b6e164a0d..28f27e327 100644 --- a/test/unit/email_parser_test.rb +++ b/test/unit/email_parser_test.rb @@ -492,6 +492,45 @@ Freemont and pulling out several minutes. :to => 'undisclosed-recipients: ;', }, }, + { + :data => IO.read('test/fixtures/mail24.box'), + :body_md5 => 'd41d8cd98f00b204e9800998ecf8427e', + :params => { + :from => 'oracle@IG0-1-DB01.example.com', + :from_email => 'oracle@IG0-1-DB01.example.com', + :from_display_name => '', + :subject => 'Regelsets im Test-Status gefunden: 1', + :to => 'support@example.com', + :body => '', + }, + :attachments => [ + { + :data => 'RULESET_ID;NAME;ACTIV;RUN_MODE;AUDIT_MODIFY_DATE +387;DP DHL JOIN - EN : Einladung eAC;T;SM;1.09.14 +', + :md5 => 'a61c76479fdc2f107fe2697ac5ad60ae', + :filename => 'rulesets-report.csv', + }, + ], + }, + { + :data => IO.read('test/fixtures/mail25.box'), + :body_md5 => '436f71d8d8a4ffbd3f18fc9de7d7f767', + :params => { + :from => 'oracle@IG0-1-DB01.example.com', + :from_email => 'oracle@IG0-1-DB01.example.com', + :from_display_name => '', + :subject => 'Regelsets im Test-Status gefunden: 1', + :to => 'support@example.com', + :body => "begin 644 rulesets-report.csv +M4E5,15-%5%])1#M.04U%.T%#5$E6.U)53E]-3T1%.T%51$E47TU/1$E&65]$ +M051%\"C,X-SM$4\"!$2$P@2D])3B`M($5.(#H@16EN;&%D=6YG(&5!0SM4.U-- +*.S$W+C`Y+C$T\"@`` +` +end +", + }, + }, ] files.each { |file| @@ -524,7 +563,7 @@ Freemont and pulling out several minutes. data[:attachments].each { |attachment_parser| next if found file_md5 = Digest::MD5.hexdigest( attachment_parser[:data] ) -# puts 'Attachment:' + attachment_parser.inspect + '-' + file_md5 + #puts 'Attachment:' + attachment_parser.inspect + '-' + file_md5 if attachment[:md5] == file_md5 found = true assert_equal( attachment[:filename], attachment_parser[:filename] ) From 8accda251e98bdbb90d7571b31c869aae5c80980 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Sun, 12 Oct 2014 14:45:14 +0200 Subject: [PATCH 3/8] Improved comments and formatting. --- config/environments/production.rb | 18 +++++++++--------- config/environments/test.rb | 11 ++++++++--- config/environments/test_mysql.rb | 11 ++++++++--- 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index e57a56520..a07e81ebd 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,8 +20,8 @@ Zammad::Application.configure do # Compress JavaScripts and CSS config.assets.compress = true - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + # Set uglifier as JS and sass as CSS compressor + config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Don't fallback to assets pipeline if a precompiled asset is missed @@ -30,17 +30,17 @@ Zammad::Application.configure do # Generate digests for assets URLs config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. + # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' # Specifies the header that your server uses for sending files - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache + # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies # config.force_ssl = true - # See everything in the log (default is :info) + # Define the log level (default is :info, to see all use :debug) # config.log_level = :debug config.log_level = :info @@ -69,12 +69,12 @@ Zammad::Application.configure do # Send deprecation notices to registered listeners config.active_support.deprecation = :notify - # Disable automatic flushing of the log to improve performance. + # Disable automatic flushing of the log to improve performance # config.autoflush_log = false - # autoload on + # Enable autoload config.dependency_loading = true - # Use default logging formatter so that PID and timestamp are not suppressed. + # Use default logging formatter so that PID and timestamp are not suppressed config.log_formatter = ::Logger::Formatter.new end diff --git a/config/environments/test.rb b/config/environments/test.rb index 970488c3b..8c8d17be4 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -13,11 +13,16 @@ Zammad::Application.configure do config.eager_load = false # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" + # Disable assert compression for relyable error code lines config.assets.compress = false + + # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = true + + # Generate digests for assets URLs config.assets.digest = true # Show full error reports and disable caching @@ -36,9 +41,9 @@ Zammad::Application.configure do config.active_support.deprecation = :stderr # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false - # autoload on + # Enable autoload config.dependency_loading = true end diff --git a/config/environments/test_mysql.rb b/config/environments/test_mysql.rb index 37bab79d2..b3ae7c547 100644 --- a/config/environments/test_mysql.rb +++ b/config/environments/test_mysql.rb @@ -8,11 +8,16 @@ Zammad::Application.configure do config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance - config.serve_static_assets = true + config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" + # Disable assert compression for relyable error code lines config.assets.compress = false + + # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = true + + # Generate digests for assets URLs config.assets.digest = true # Show full error reports and disable caching @@ -31,9 +36,9 @@ Zammad::Application.configure do config.active_support.deprecation = :stderr # Disable request forgery protection in test environment - config.action_controller.allow_forgery_protection = false + config.action_controller.allow_forgery_protection = false - # autoload on + # Enable autoload config.dependency_loading = true end From 731186840497673dfa5c911e9710de655e066d26 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Fri, 17 Oct 2014 14:15:54 +0200 Subject: [PATCH 4/8] Fixed rails 'reload' + 'include'/'extend' + 'require' issue with using 'load' instead. --- app/models/history.rb | 2 +- app/models/organization.rb | 2 +- app/models/ticket.rb | 8 ++++---- app/models/ticket/article.rb | 6 +++--- app/models/user.rb | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/models/history.rb b/app/models/history.rb index 578f1c457..aa16b9857 100644 --- a/app/models/history.rb +++ b/app/models/history.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class History < ApplicationModel - require 'history/assets' + load 'history/assets.rb' include History::Assets self.table_name = 'histories' diff --git a/app/models/organization.rb b/app/models/organization.rb index b15d33540..dcf58eb6e 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,7 +1,7 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Organization < ApplicationModel - require 'organization/assets' + load 'organization/assets.rb' include Organization::Assets extend Organization::Search include Organization::SearchIndex diff --git a/app/models/ticket.rb b/app/models/ticket.rb index 58178f0df..01bbdc853 100644 --- a/app/models/ticket.rb +++ b/app/models/ticket.rb @@ -4,13 +4,13 @@ class Ticket < ApplicationModel include Ticket::Escalation include Ticket::Subject include Ticket::Permission - require 'ticket/assets' + load 'ticket/assets.rb' include Ticket::Assets - require 'ticket/history_log' + load 'ticket/history_log.rb' include Ticket::HistoryLog - require 'ticket/activity_stream_log' + load 'ticket/activity_stream_log.rb' include Ticket::ActivityStreamLog - require 'ticket/search_index' + load 'ticket/search_index.rb' include Ticket::SearchIndex extend Ticket::Search diff --git a/app/models/ticket/article.rb b/app/models/ticket/article.rb index 83180c460..ee55a33d6 100644 --- a/app/models/ticket/article.rb +++ b/app/models/ticket/article.rb @@ -1,11 +1,11 @@ # Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/ class Ticket::Article < ApplicationModel - require 'ticket/article/assets' + load 'ticket/article/assets.rb' include Ticket::Article::Assets - require 'ticket/article/history_log' + load 'ticket/article/history_log.rb' include Ticket::Article::HistoryLog - require 'ticket/article/activity_stream_log' + load 'ticket/article/activity_stream_log.rb' include Ticket::Article::ActivityStreamLog belongs_to :ticket diff --git a/app/models/user.rb b/app/models/user.rb index 2fe4086f8..ce89b4782 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -3,7 +3,7 @@ require 'digest/md5' class User < ApplicationModel - require 'user/assets' + load 'user/assets.rb' include User::Assets extend User::Search include User::SearchIndex From 567267fc1b8df6fdc74b794c30b2ffd787bcb88e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 18 Oct 2014 09:10:31 +0200 Subject: [PATCH 5/8] Added pdf lib. --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 6e8f2cf78..482c6ee20 100644 --- a/Gemfile +++ b/Gemfile @@ -91,5 +91,7 @@ end # to generate doc gem 'kramdown' +gem 'prawn' +gem 'prawn-table' gem 'puma' From cb35c946ebae933b3416ce2a38a3f1dbfdc4d8a5 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 18 Oct 2014 09:59:19 +0200 Subject: [PATCH 6/8] Added es read me. --- README_elasticsearch.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 README_elasticsearch.md diff --git a/README_elasticsearch.md b/README_elasticsearch.md new file mode 100644 index 000000000..32a1951b1 --- /dev/null +++ b/README_elasticsearch.md @@ -0,0 +1,18 @@ +# Setup a elastic search + +* Install elastic search + +* Install attachment plugin + cd /usr/share/elasticsearch + bin/plugin -install elasticsearch/elasticsearch-mapper-attachments/2.0.0 + +* Configure elastic search + + * rails r "Setting.set('es_url', 'http://172.0.0.1:9200')" + * rails r "Setting.set('es_user', 'elasticsearch')" # optional + * rails r "Setting.set('es_password', 'zammad')" # optional + * rails r "Setting.set('es_index', Socket.gethostname + '_zammad')" # optional + +* Create elastic search indexes + * rake searchindex:rebuild # drop/create/reload + From b3639e67b0bf7c5b7c1928dc471a63626d157171 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 18 Oct 2014 15:34:25 +0200 Subject: [PATCH 7/8] Moved to lower key for os. --- app/assets/javascripts/app/lib/app_post/browser.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/app/lib/app_post/browser.coffee b/app/assets/javascripts/app/lib/app_post/browser.coffee index 6b5559ed1..dcf1ed14d 100644 --- a/app/assets/javascripts/app/lib/app_post/browser.coffee +++ b/app/assets/javascripts/app/lib/app_post/browser.coffee @@ -3,7 +3,7 @@ class App.Browser data = browser: @searchString(@dataBrowser) or "An unknown browser" version: @searchVersion(navigator.userAgent) or @searchVersion(navigator.appVersion) or "an unknown version" - OS: @searchString(@dataOS) or "an unknown OS" + os: @searchString(@dataOS) or "an unknown os" @check: -> data = @detection() From 12938c77a7aeafc830be2806b0551f5c930d0dab Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sat, 18 Oct 2014 16:02:46 +0200 Subject: [PATCH 8/8] Moved to new ui log format. --- .../app/lib/app_init/track.js.coffee | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_init/track.js.coffee b/app/assets/javascripts/app/lib/app_init/track.js.coffee index 8a4f6994a..d38594b59 100644 --- a/app/assets/javascripts/app/lib/app_init/track.js.coffee +++ b/app/assets/javascripts/app/lib/app_init/track.js.coffee @@ -24,7 +24,8 @@ class _trackSingleton @trackId = 'track-' + new Date().getTime() + '-' + Math.floor( Math.random() * 99999 ) @browser = App.Browser.detection() @data = [] - @url = 'https://portal.znuny.com/api/ui' +# @url = 'https://log.znuny.com/api/ui' + @url = 'https://portal.znuny.com/api/v1/ui' # @url = 'api/ui' @log( 'start', 'notice', {} ) @@ -89,14 +90,14 @@ class _trackSingleton return ) - log: ( area, level, args ) -> + log: ( facility, level, args ) -> return if !App.Config.get('ui_send_client_stats') info = time: Math.round( new Date().getTime() / 1000 ) - area: area + facility: facility level: level - location: window.location.href - data: args + location: window.location.pathname + window.location.hash + message: args @data.push info send: (async = true) => @@ -110,9 +111,6 @@ class _trackSingleton itemNew = _.clone( item ) JSON.stringify(item) - # add browser info - for item, value of @browser - itemNew[item] = value newDataNew.push itemNew catch e # nothing @@ -122,8 +120,12 @@ class _trackSingleton url: @url async: async data: JSON.stringify( - track_id: @trackId - log: newDataNew + meta: + track_id: @trackId + host: window.location.host + protocol: window.location.protocol + browser: @browser + log: newDataNew ) crossDomain: true # success: (data, status, xhr) =>