<commit_before>module Diaspora

  module Webhooks
    def self.included(klass)
      klass.class_eval do
        before_save :notify_friends

        @@queue = MessageHandler.new
        
        def notify_friends
          xml = Post.build_xml_for(self)
          @@queue.add_post_request( friends_with_permissions, xml )
          @@queue.process
        end
        
        def prep_webhook  
          self.to_xml.to_s
        end
 
        def prep_many  
          "<post>#{self.prep_webhook}</post>"
        end

        def friends_with_permissions
           Friend.only(:url).map{|x| x = x.url + "/receive/"}
        end

        def self.build_xml_for(posts)
          xml = "<posts>"
          posts.each {|x| xml << x.prep_many}
          xml = xml + "</posts>"
        end
      end
    end
  end
end
<commit_msg>DG MS; fixed infinate loop<commit_after>module Diaspora

  module Webhooks
    def self.included(klass)
      klass.class_eval do
        before_save :notify_friends

        @@queue = MessageHandler.new
        
        def notify_friends
         if self.owner == User.first.email
            xml = Post.build_xml_for(self)
            @@queue.add_post_request( friends_with_permissions, xml )
            @@queue.process
          end
        end
        
        def prep_webhook  
          self.to_xml.to_s
        end
 
        def prep_many  
          "<post>#{self.prep_webhook}</post>"
        end

        def friends_with_permissions
           Friend.only(:url).map{|x| x = x.url + "/receive/"}
        end

        def self.build_xml_for(posts)
          xml = "<posts>"
          posts.each {|x| xml << x.prep_many}
          xml = xml + "</posts>"
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.0922722029988466, 'fraction_numerical': 0.0, 'mean_word_length': 1.566568047337278, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 18}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5672954', 'n_tokens_mistral': 552, 'n_tokens_neox': 525, 'n_words': 112}