This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Fix follow notification servers

  • Loading branch information...
titanous committed Sep 18, 2012
1 parent 9771924 commit b2be554c733b942b987bc06dfc10a6bda54bcc03
@@ -39,6 +39,14 @@ def auth_details
attributes.slice(:mac_key_id, :mac_key, :mac_algorithm)
end
+ def notification_servers
+ nil
+ end
+
+ def notification_path
+ notification_url
+ end
+
def self.public_attributes
[:post_types, :profile_info_types, :scopes, :notification_url]
end
@@ -79,8 +79,8 @@ def core_profile
API::CoreProfileData.new(profile)
end
- def notification_url
- notification_path
+ def notification_servers
+ core_profile.servers
end
def auth_details
@@ -47,10 +47,14 @@ def core_profile
API::CoreProfileData.new(profile)
end
- def notification_url
+ def notification_path
'posts'
end
+ def notification_servers
+ core_profile.servers
+ end
+
def auth_details
attributes.slice(:mac_key_id, :mac_key, :mac_algorithm)
end
@@ -32,9 +32,8 @@ def self.notify_entity(entity, post_id, view='full')
return if post.entity == entity
if follow = post.user.followers.first(:entity => entity) || post.user.followings.first(:entity => entity)
return unless post.can_notify?(follow)
- server_urls = API::CoreProfileData.new(follow.profile).servers
- client = TentClient.new(server_urls, follow.auth_details)
- path = follow.notification_url
+ client = TentClient.new(follow.notification_servers, follow.auth_details)
+ path = follow.notification_path
else
return unless post.public
client = TentClient.new
@@ -48,9 +47,9 @@ def self.notify_entity(entity, post_id, view='full')
def notify_about(post_id, view='full')
post = Post.first(:id => post_id)
- client = TentClient.new(nil, subject.auth_details)
+ client = TentClient.new(subject.notification_servers, subject.auth_details)
permissions = subject.respond_to?(:scopes) && subject.scopes.include?(:read_permissions)
- client.post.create(post.as_json(:app => !!app_authorization, :permissions => permissions, :view => view), :url => subject.notification_url)
+ client.post.create(post.as_json(:app => !!app_authorization, :permissions => permissions, :view => view), :url => subject.notification_path)
rescue Faraday::Error::ConnectionFailed
end
end

0 comments on commit b2be554

Please sign in to comment.