Skip to content

Commit

Permalink
Merge pull request hotsh#422 from caleywoods/master
Browse files Browse the repository at this point in the history
Cleaned up feed and user models
  • Loading branch information
steveklabnik committed Dec 1, 2011
2 parents f803f12 + c83d9df commit 491f7f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/models/feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Feed

after_create :default_hubs

def populate xrd = nil
def populate(xrd = nil)
# TODO: More entropy would be nice
self.verify_token = Digest::MD5.hexdigest(rand.to_s)
self.secret = Digest::MD5.hexdigest(rand.to_s)
Expand Down
22 changes: 11 additions & 11 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,19 @@ def get_authorization(auth)
many :followers, :in => :followers_ids, :class_name => 'Feed'

# A particular feed follows this user
def followed_by! f
def followed_by!(f)
followers << f
save
end

# A particular feed unfollows this user
def unfollowed_by! f
def unfollowed_by!(f)
followers_ids.delete(f.id)
save
end

# Follow a particular feed
def follow! f
def follow!(f)
# can't follow yourself
if f == self.feed
return
Expand All @@ -154,7 +154,7 @@ def follow! f

# Send Salmon notification so that the remote user
# knows this user is following them
def send_follow_notification to_feed_id
def send_follow_notification(to_feed_id)
f = Feed.first :id => to_feed_id

salmon = OStatus::Salmon.from_follow(author.to_atom, f.author.to_atom)
Expand All @@ -168,7 +168,7 @@ def send_follow_notification to_feed_id
end

# unfollow takes a feed (since it is guaranteed to exist)
def unfollow! followed_feed
def unfollow!(followed_feed)
following_ids.delete(followed_feed.id)
save
if followed_feed.local?
Expand All @@ -182,7 +182,7 @@ def unfollow! followed_feed

# Send Salmon notification so that the remote user
# knows this user has stopped following them
def send_unfollow_notification to_feed_id
def send_unfollow_notification(to_feed_id)
f = Feed.first :id => to_feed_id

salmon = OStatus::Salmon.from_unfollow(author.to_atom, f.author.to_atom)
Expand All @@ -196,7 +196,7 @@ def send_unfollow_notification to_feed_id
end

# Send an update to a remote user as a Salmon notification
def send_mention_notification update_id, to_feed_id
def send_mention_notification(update_id, to_feed_id)
f = Feed.first :id => to_feed_id
u = Update.first :id => update_id

Expand All @@ -211,19 +211,19 @@ def send_mention_notification update_id, to_feed_id
res = http.post(uri.path, envelope, {"Content-Type" => "application/magic-envelope+xml"})
end

def followed_by? f
def followed_by?(f)
followers.include? f
end

def following_feed? f
def following_feed?(f)
following.include? f
end

def following_author? author
def following_author?(author)
following.include?(author.feed)
end

def following_url? feed_url
def following_url?(feed_url)
# Handle possibly created multiple feeds for the same remote_url
existing_feeds = Feed.all(:remote_url => feed_url)

Expand Down

0 comments on commit 491f7f9

Please sign in to comment.