]> git.cworth.org Git - sup/blobdiff - lib/sup/modes/thread-view-mode.rb
added chronic support thanks to Marcus Williams
[sup] / lib / sup / modes / thread-view-mode.rb
index 5f3cd6f9e8315df5b904b3f4e00024d0626dfc66..88c512529f148bb9a2b9e5c4e3635cc587b997e1 100644 (file)
@@ -38,6 +38,8 @@ class ThreadViewMode < LineCursorMode
     k.add :compose, "Compose message to person", 'm'
     k.add :archive_and_kill, "Archive thread and kill buffer", 'a'
     k.add :delete_and_kill, "Delete thread and kill buffer", 'd'
+    k.add :subscribe_to_list, "Subscribe to/unsubscribe from mailing list", "("
+    k.add :unsubscribe_from_list, "Subscribe to/unsubscribe from mailing list", ")"
   end
 
   ## there are a couple important instance variables we hold to format
@@ -108,6 +110,24 @@ class ThreadViewMode < LineCursorMode
     BufferManager.spawn "Reply to #{m.subj}", mode
   end
 
+  def subscribe_to_list
+    m = @message_lines[curpos] or return
+    if m.list_subscribe && m.list_subscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+      spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+    else
+      BufferManager.flash "Can't find List-Subscribe header for this message."
+    end
+  end
+
+  def unsubscribe_from_list
+    m = @message_lines[curpos] or return
+    if m.list_unsubscribe && m.list_unsubscribe =~ /<mailto:(.*?)\?(subject=(.*?))>/
+      spawn_compose_mode :from => AccountManager.account_for(m.recipient_email), :to => [PersonManager.person_for($1)], :subj => $3
+    else
+      BufferManager.flash "Can't find List-Unsubscribe header for this message."
+    end
+  end
+
   def forward
     m = @message_lines[curpos] or return
     spawn_forward_mode m