Index: app/models/content.rb
===================================================================
--- app/models/content.rb	(revision 1219)
+++ app/models/content.rb	(working copy)
@@ -38,7 +38,6 @@
     result = nil if result.is_a?(Array) && result.first == nil
   end
   
-  
   attr_protected :moderation_status
     
   # A convenience method to tell us whether this content is attached to 
@@ -122,7 +121,65 @@
     unless status.nil?
       self.moderation_status = status if user.can_set_moderation_status_to?(status, self)
     end
+
+    send_this_to_subscribers
   end
+
+  # this is what subscriptions look like
+  #create table subscriptions ( destination_address varchar, feed text )
+#
+#  SELECT * FROM subscriptions WHERE feed IN (feeds_i_belong_to)
+
+  def send_this_to_subscribers
+    Subscriptions.find(:all, {:feed => feeds_i_belong_to}).each do |subscription|
+      deliverer.send(:to => subscription.to, :content => self.to_atom)
+    end
+  end
+
+  def feeds_i_belong_to
+    ["/all_content.atom"]
+  end
+
+  def feeds_i_belong_to
+    base = ["/all_posts.atom", super]
+    tags = self.tags.map { |tag|
+      "http://london.indymedia.org.uk/tags/#{tag.tag}.atom" }
+    base + tags
+  end
+
+  ===== notes
+
+  GET / HTTP/1.1
+  Host: facebook.com
+  <html>...
+  <link rel="address-mapper" href="http://facebook.com/$1" />
+  ...</html>
+
+  GET / HTTP/1.1
+  Host: flickr.com
+  <html>...
+  <link rel="address-mapper" href="xmpp:$1@flickr.com" />
+  ...</html>
+
+  grandmother@facebook.com -> me@flickr.com
+
+  <me sits at computer, sees request from grandmother@facebook.com> <click "YES">
+
+
+
+
+
+
+  <iq type="set" to="london.indymedia.org.uk" from="me@ihatecops.com" id="nnasdf">
+    <pubsub>
+      <subscribe node="http://london.indymedia.org.uk/tags/pigs.atom" jid="me@ihatecops.com"/>
+      <subscribe node="http://london.indymedia.org.uk/tags/cops.atom" jid="me@ihatecops.com"/>
+      <subscribe node="http://london.indymedia.org.uk/tags/police.atom" jid="me@ihatecops.com"/>
+      <subscribe node="http://london.indymedia.org.uk/sensitive_data_on_london_cops.atom" jid="me@ihatecops.com"/>
+    </pubsub>
+  </iq>
+
+  ==== notes ===
   
   protected
   
@@ -135,4 +192,4 @@
     end
   end
     
-end
\ No newline at end of file
+end
Index: lib/global_replication.rb
===================================================================
--- lib/global_replication.rb	(revision 0)
+++ lib/global_replication.rb	(revision 0)
@@ -0,0 +1,11 @@
+TRUSTED_REPLICATORS=['london1@london1.indymedia.org.uk', 'london2@london2.indymedia.org.uk']
+
+class ActiveRecord::Base
+  after_save :send_to_trusted_replicators
+
+  def send_to_trusted_replicators
+    MiddleMan.new_worker(:class => :replicator_worker,
+                         :job_key => "replication_#{self.class}_#{self.object_id.to_s}",
+                         :args => { :object => self }) unless RAILS_ENV == 'test'
+  end
+end
Index: lib/workers/replicator_worker.rb
===================================================================
--- lib/workers/replicator_worker.rb	(revision 0)
+++ lib/workers/replicator_worker.rb	(revision 0)
@@ -0,0 +1,25 @@
+class ReplicatorWorker < BackgrounDRb::Rails
+
+  # This method is called in it's own new thread when you
+  # call new worker. args is set to :args  
+  def do_work(args)
+    TRUSTED_REPLICATORS.each do |replicant|
+      jabber_client.send(replicant, Marshal.dump(args[:object]))
+    end
+  end
+
+  def jabber_client
+    return @jabber_client if @jabber_client
+
+    @jabber_client ||= Jabber::Simple.new('london1@london1.indymedia.org.uk', JABBER_PASSWORD)
+    @reception_thread = Thread.new {
+      @jabber_client.received_messages do |message|
+        next unless TRUSTED_REPLICATORS.include?(message.from)
+
+        new_record = Marshal.load(message.body)
+        new_record.save
+      end
+    }
+  end
+  
+end

