Small hooks for Queued Post version of discourse-akismet

This commit is contained in:
Robin Ward 2015-04-27 11:56:07 -04:00
parent 44e5179743
commit 19a89bb501
2 changed files with 14 additions and 2 deletions

View File

@ -0,0 +1,9 @@
import RestAdapter from 'discourse/adapters/rest';
export default function buildPluginAdapter(pluginName) {
return RestAdapter.extend({
pathFor(store, type) {
return "/admin/plugins/" + pluginName + this._super(store, type);
}
});
}

View File

@ -29,11 +29,11 @@ class QueuedPost < ActiveRecord::Base
end end
def self.new_posts def self.new_posts
visible.where(state: states[:new]) where(state: states[:new])
end end
def self.new_count def self.new_count
new_posts.count new_posts.visible.count
end end
def visible? def visible?
@ -47,6 +47,7 @@ class QueuedPost < ActiveRecord::Base
def reject!(rejected_by) def reject!(rejected_by)
change_to!(:rejected, rejected_by) change_to!(:rejected, rejected_by)
DiscourseEvent.trigger(:rejected_post, self)
end end
def create_options def create_options
@ -66,6 +67,8 @@ class QueuedPost < ActiveRecord::Base
creator = PostCreator.new(user, create_options.merge(skip_validations: true)) creator = PostCreator.new(user, create_options.merge(skip_validations: true))
created_post = creator.create created_post = creator.create
end end
DiscourseEvent.trigger(:approved_post, self)
created_post created_post
end end