Skip to content

Commit

Permalink
Replaced mail_handler hacky hook by issues "before_save" hook
Browse files Browse the repository at this point in the history
  • Loading branch information
xaionaro committed Apr 6, 2015
1 parent 01c4673 commit e78ab04
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 49 deletions.
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'redmine'

require_dependency 'mail_handler_model_patch'
require_dependency 'issue_model_patch'
require_dependency 'auto_watch_hook'

Redmine::Plugin.register :redmine_auto_watch do
Expand Down
25 changes: 25 additions & 0 deletions lib/issue_model_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module AutoWatch
module IssuePatch
def self.included(base)
base.class_eval do
unloadable

def autowatch_add_watcher(watcher)
return if watcher.nil? || !watcher.is_a?(User) || watcher.anonymous? || !watcher.active?
self.add_watcher(watcher) unless self.watched_by?(watcher)
end

def autowatch_beforesave_hook
Rails.logger.info(self.to_yaml)
autowatch_add_watcher(self.author)
autowatch_add_watcher(self.assigned_to)
end

around_save :autowatch_beforesave_hook
end
end
end
end

Issue.send(:include, AutoWatch::IssuePatch)

48 changes: 0 additions & 48 deletions lib/mail_handler_model_patch.rb

This file was deleted.

0 comments on commit e78ab04

Please sign in to comment.