Skip to content
Extraits de code Groupes Projets
requests_helper.rb 1,22 ko
Newer Older
  • Learn to ignore specific revisions
  • 
      def subscription_mode(profile)
        if diaspora?(profile)
          :friend
        elsif ostatus?(profile)
          :subscribe
        else
    
         :subscribe
    
    maxwell's avatar
    maxwell a validé
        end
    
      end
    
      def diaspora?(profile)
        profile_contains(profile, 'http://joindiaspora.com/seed_location')
      end
    
      def ostatus?(profile)
        profile_contains(profile, 'http://ostatus.org/schema/1.0/subscribe') 
    
    maxwell's avatar
    maxwell a validé
      end
    
    
      def profile_contains(profile, rel)
        profile.links.each{|x|  return true if x.rel == rel}
        false
      end
    
      def subscription_url(action, profile)
        if action == :subscribe
          profile.links.select{|x| x.rel == 'http://schemas.google.com/g/2010#updates-from'}.first.href
        elsif action == :friend
          profile.links.select{|x| x.rel == 'http://joindiaspora.com/seed_location'}.first.href
        else
    
    maxwell's avatar
    maxwell a validé
        if identifier.include?('.atom')
          return {:subscribe => identifier}
        end
        
    
        unless identifier.include?( '@' )
    
          return {:friend => identifier}
    
        Rails.logger.info("The webfinger to #{identifier} returned #{f}")
    
        action = subscription_mode(f)
        url = subscription_url(action, f)