<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -9,6 +9,19 @@ namespace :maintenance do
       end
     end
     
+    desc &quot;Fix attachments for spawned messages&quot;
+    task :fix_attachments_in_spawned_messages =&gt; :environment do
+      spawned_convos = Conversation.find(:all, :conditions =&gt; 'parent_message_id IS NOT NULL')
+      spawned_convos.each do |c|
+        parent_message = c.parent_message
+        spawned_message = c.messages.first
+        if parent_message.has_attachment?          
+          spawned_message.message_html = spawned_message.message_html + attachment_markup(parent_message)
+          spawned_message.save(false)
+        end
+      end
+    end
+    
     desc &quot;Save attachment height in the database&quot;
     task :save_attachment_height =&gt; :environment do
       Message.with_image.find_in_batches(:batch_size =&gt; 100 ) do |messages|
@@ -26,5 +39,15 @@ namespace :maintenance do
       end
     end
     
+    def attachment_markup(message)
+      if message.has_image?
+        %Q( &lt;div class=&quot;img_attachment&quot;&gt;&lt;a href=&quot;#{message.attachment.url}&quot; style=&quot;display:block;height:#{message.attachment_height+40}px;&quot;&gt;&lt;img src=&quot;#{message.attachment.url(:big)}&quot; alt=&quot;#{message.message}&quot; height=&quot;#{message.attachment_height}&quot; /&gt;&lt;/a&gt;&lt;/div&gt; )
+      elsif message.has_pdf?
+        %Q( &lt;div class=&quot;file_attachment&quot;&gt;&lt;a href=&quot;#{message.attachment.url}&quot; style=&quot;display:block;height:100px;&quot;&gt;&lt;img src=&quot;/images/icons/pdf_large.jpg&quot; alt=&quot;PDF Document&quot; height=&quot;100&quot; /&gt;&lt;/a&gt;&lt;/div&gt; )
+      elsif message.has_zip?
+        %Q( &lt;div class=&quot;file_attachment&quot;&gt;&lt;a href=&quot;#{message.attachment.url}&quot; style=&quot;display:block;height:99px;&quot;&gt;&lt;img src=&quot;/images/icons/zip_large.jpg&quot; alt=&quot;ZIP File&quot; height=&quot;99&quot; /&gt;&lt;/a&gt;&lt;/div&gt; )
+      end
+    end
+    
   end
 end
\ No newline at end of file</diff>
      <filename>lib/tasks/maintenance.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6bad495e1dccc885e4018b6c8ef88eb2b26706d7</id>
    </parent>
  </parents>
  <author>
    <name>Claudio Perez Gamayo</name>
    <email>crossblaim@gmail.com</email>
  </author>
  <url>http://github.com/crossblaim/echowaves/commit/0dfcc4936b32db48b15c13e7291ceee3ea0550a4</url>
  <id>0dfcc4936b32db48b15c13e7291ceee3ea0550a4</id>
  <committed-date>2009-07-01T08:48:27-07:00</committed-date>
  <authored-date>2009-07-01T08:48:27-07:00</authored-date>
  <message>Add a task for add attachment markup to spawned messages if the parent message had an attachment</message>
  <tree>0d3b8dc06044b9f4f65a5a6d2d5841b50824dad7</tree>
  <committer>
    <name>Claudio Perez Gamayo</name>
    <email>crossblaim@gmail.com</email>
  </committer>
</commit>
