enable mention for comments #2466

This commit is contained in:
r888888888
2015-11-30 16:51:07 -08:00
parent e24d6e49bc
commit 8a63fb0f7c
6 changed files with 61 additions and 3 deletions

View File

@@ -1,4 +1,6 @@
class Comment < ActiveRecord::Base
include Mentionable
validate :validate_creator_is_not_limited, :on => :create
validates_format_of :body, :with => /\S/, :message => 'has no content'
belongs_to :post
@@ -10,6 +12,12 @@ class Comment < ActiveRecord::Base
after_create :update_last_commented_at_on_create
after_destroy :update_last_commented_at_on_destroy
attr_accessible :body, :post_id, :do_not_bump_post, :is_deleted
mentionable(
:message_field => :body,
:user_field => :creator_id,
:title => "You were mentioned in a comment",
:body => lambda {|rec, user_name| "You were mentioned in a \"comment\":http://#{Danbooru.config.hostname}/posts/#{rec.post_id}#comment-#{rec.id}\n\n---\n\n[i]#{rec.creator.name} said:[/i]\n\n#{ActionController::Base.helpers.excerpt(rec.body, user_name)}"}
)
module SearchMethods
def recent

View File

@@ -22,7 +22,7 @@ class ForumPost < ActiveRecord::Base
:message_field => :body,
:user_field => :creator_id,
:title => "You were mentioned in a forum topic",
:body => lambda {|rec, user_name| "You were mentioned in the forum topic \"#{rec.topic.title}\":http://#{Danbooru.config.hostname}/forum_topics/#{rec.topic_id}?page=#{rec.forum_topic_page}\n\n---\n\n#{ActionController::Base.helpers.excerpt(rec.body, user_name)}"}
:body => lambda {|rec, user_name| "You were mentioned in the forum topic \"#{rec.topic.title}\":http://#{Danbooru.config.hostname}/forum_topics/#{rec.topic_id}?page=#{rec.forum_topic_page}\n\n---\n\n[i]#{rec.creator.name} said:[/i]\n\n#{ActionController::Base.helpers.excerpt(rec.body, user_name)}"}
)
module SearchMethods