sketch for two stage workflow
authorDavid Bremner <bremner@unb.ca>
Mon, 11 Aug 2008 01:59:56 +0000 (22:59 -0300)
committerDavid Bremner <bremner@unb.ca>
Mon, 11 Aug 2008 12:18:36 +0000 (09:18 -0300)
filters/postal-deliver.pl [moved from filters/postal-filer.pl with 94% similarity]
filters/postal-queue.pl [new file with mode: 0644]

similarity index 94%
rename from filters/postal-filer.pl
rename to filters/postal-deliver.pl
index 60fdec6ee66f273ab1f5506ac23cf9c396474e82..eb696c2b3b27f5f4093509e71cdedd6352f7456c 100644 (file)
@@ -34,7 +34,7 @@ if ($to =~ m/$prefix($Convert::YText::valid_rex)/){
     my @path=split(qr{/},$key);
     map { $_=encode_ytext($_); s/\./@/g } @path;
     
-    my $mailbox=$maildir . "/.".join(".",@path)."/" ;
+    my $mailbox=$maildir . ".".join(".",@path)."/" ;
     
     $mail->accept($mailbox);
 
diff --git a/filters/postal-queue.pl b/filters/postal-queue.pl
new file mode 100644 (file)
index 0000000..44d3b77
--- /dev/null
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+
+use Email::Folder;
+use Convert::YText qw(decode_ytext encode_ytext);
+
+# we need at least version 2.54 of IkiWiki for the new config api
+BEGIN { require IkiWiki; die unless ($IkiWiki::version >= 2.54) }
+
+use IkiWiki::Setup;
+use Getopt::Long;
+use Carp;
+
+my $config_file=undef;
+
+GetOptions('config=s'=>\$config_file);
+
+die "configuration file is mandatory" unless ($config_file);
+
+my %config=IkiWiki::Setup::load($config_file);
+
+my $queue=$config{queue} || croak("missing queue location");
+
+my $folder=Email::Folder->new($path,reader=>'Email::Folder::maildir') 
+    || croak("mailbox could not be opened");
+
+for my $messages  ($folder->messages){
+
+    my $to=$message->to;
+    if ($to =~ m/$prefix($Convert::YText::valid_rex)/){
+       my $page=decode_ytext($1);
+       
+       # sanity check the page path
+       
+       # check if comments folder exists, create if needed
+
+       # write the message to the folder
+
+       $msg_file= $comment_folder->write($message);
+
+       # update vcs
+    
+       IkiWIki::rcs_add($msg_file);
+       
+       # tag for deletion
+       
+       push (@must_die, $message->message-id);
+       
+       $folder->delete($message);
+           
+    }
+    # make regex for message-id
+
+    # called delete_message from Email::Delete
+}
+