Permalink
Browse files

Add original_post flag to mentions

  • Loading branch information...
1 parent 476ac9b commit ce64102b68981024e31c4bc80db2ce90c48c7dd2 Jesse Stuart committed Oct 6, 2012
Showing with 3 additions and 2 deletions.
  1. +1 −0 lib/tentd/model/mention.rb
  2. +2 −2 lib/tentd/model/post.rb
View
1 lib/tentd/model/mention.rb
@@ -7,6 +7,7 @@ class Mention
property :id, Serial
property :entity, Text, :lazy => false, :required => true
+ property :original_post, Boolean, :default => false
property :mentioned_post_id, String
belongs_to :post, 'TentD::Model::Post', :required => false
View
4 lib/tentd/model/post.rb
@@ -61,7 +61,7 @@ def update(data)
Mention.all(:post_id => self.id).update(:post_id => nil, :post_version_id => last_version.id)
mentions.each do |mention|
next unless mention[:entity]
- self.mentions.create(:entity => mention[:entity], :mentioned_post_id => mention[:post], :post_version_id => current_version.id)
+ self.mentions.create(:entity => mention[:entity], :mentioned_post_id => mention[:post], :original_post => self.original, :post_version_id => current_version.id)
end
end
@@ -75,7 +75,7 @@ def self.create(data)
mentions.to_a.each do |mention|
next unless mention[:entity]
- post.mentions.create(:entity => mention[:entity], :mentioned_post_id => mention[:post], :post_version_id => post.latest_version(:fields => [:id]).id)
+ post.mentions.create(:entity => mention[:entity], :mentioned_post_id => mention[:post], :original_post => post.original, :post_version_id => post.latest_version(:fields => [:id]).id)
end
if post.mentions.to_a.any? && post.original

0 comments on commit ce64102

Please sign in to comment.