Add some TODO's

This commit is contained in:
Stephan Kaag
2013-07-22 22:39:20 +02:00
parent ebd5fa76c5
commit b58da2fcf9
2 changed files with 6 additions and 7 deletions

View File

@ -292,6 +292,7 @@ class Post < ActiveRecord::Base
end end
# TODO: move to post-analyzer?
# Determine what posts are quoted by this post # Determine what posts are quoted by this post
def extract_quoted_post_numbers def extract_quoted_post_numbers
temp_collector = [] temp_collector = []

View File

@ -96,20 +96,18 @@ class PostAlertObserver < ActiveRecord::Observer
display_username: opts[:display_username] || post.user.username }.to_json) display_username: opts[:display_username] || post.user.username }.to_json)
end end
# TODO: Move to post-analyzer?
# Returns a list users who have been mentioned # Returns a list users who have been mentioned
def extract_mentioned_users(post) def extract_mentioned_users(post)
User.where(username_lower: post.raw_mentions).where("id <> ?", post.user_id) User.where(username_lower: post.raw_mentions).where("id <> ?", post.user_id)
end end
# TODO: Move to post-analyzer?
# Returns a list of users who were quoted in the post # Returns a list of users who were quoted in the post
def extract_quoted_users(post) def extract_quoted_users(post)
result = [] post.raw.scan(/\[quote=\"([^,]+),.+\"\]/).uniq.map do |m|
post.raw.scan(/\[quote=\"([^,]+),.+\"\]/).uniq.each do |m| User.where("username_lower = :username and id != :id", username: m.first.strip.downcase, id: post.user_id).first
username = m.first.strip.downcase end.compact
user = User.where("username_lower = :username and id != :id", username: username, id: post.user_id).first
result << user if user.present?
end
result
end end
# Notify a bunch of users # Notify a bunch of users