Navigation Menu

Skip to content

Commit

Permalink
Another take on attachments deletion notification:
Browse files Browse the repository at this point in the history
in case of Issues attachments make it obey to 'issue_update' setting rather than 'file_added'
  • Loading branch information
Artem Vasiliev committed Jan 21, 2009
1 parent 0eb11b0 commit c8aab89
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions app/controllers/attachments_controller.rb
Expand Up @@ -49,9 +49,11 @@ def download
end

def to_notify?
notification_key = @attachment.container.notification_key if @attachment.container.respond_to?(:notification_key)
notification_key ||= NotificationKeys::FILE_ADDED
Setting.notified_events.include?(notification_key)
if @attachment.container.class.respond_to?(:notify?)
@attachment.container.class.notify?(:update)
else
Setting.notified_events.include?(NotificationKeys::FILE_ADDED)
end
end

def destroy
Expand Down
4 changes: 2 additions & 2 deletions app/models/document.rb
Expand Up @@ -35,7 +35,7 @@ def after_initialize
end
end

def notification_key
NotificationKeys::DOCUMENT_ADDED
def self.notify?(action)
Setting.notified_events.include?(NotificationKeys::DOCUMENT_ADDED)
end
end
4 changes: 4 additions & 0 deletions app/models/issue.rb
Expand Up @@ -283,6 +283,10 @@ def active_versions
project.active_versions(:for => self)
end

def self.notify?(action)
Setting.notified_events.include?(NotificationKeys.const_get('ISSUE_%sD' % action.to_s.upcase))
end

private

# Callback on attachment deletion
Expand Down
4 changes: 2 additions & 2 deletions app/models/wiki_page.rb
Expand Up @@ -126,8 +126,8 @@ def parent_title=(t)
self.parent = parent_page
end

def notification_key
NotificationKeys::WIKI_EDIT
def self.notify?(action)
Setting.notified_events.include?(NotificationKeys::WIKI_EDIT)
end

protected
Expand Down

0 comments on commit c8aab89

Please sign in to comment.