[vhffs-dev] [2195] added listengine function to get the message body of a mail in the moderation queue , thanks for mik0 for this patch (I don't know if it works, looks like it may)

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2195
Author:   gradator
Date:     2012-06-15 23:59:01 +0200 (Fri, 15 Jun 2012)
Log Message:
-----------
added listengine function to get the message body of a mail in the moderation queue, thanks for mik0 for this patch (I don't know if it works, looks like it may)

Modified Paths:
--------------
    trunk/vhffs-listengine/src/listengine.pl

Modified: trunk/vhffs-listengine/src/listengine.pl
===================================================================
--- trunk/vhffs-listengine/src/listengine.pl	2012-06-12 20:22:25 UTC (rev 2194)
+++ trunk/vhffs-listengine/src/listengine.pl	2012-06-15 21:59:01 UTC (rev 2195)
@@ -803,13 +803,40 @@
 
 }
 
+################
+# Get body of a message waiting for moderation in order to check content
+#
+# This function handle request letmecheck hash sent to list-request@xxxxxxxxxx
+#################################
+sub letmecheck_message{
+	my $list = shift;
+	my $hash = shift;
+	my $path = get_moderation_dir( $list ).'/'.$hash;
+	my @result;
+	unless( -f $path ) {
+		push( @result, gettext('No message found or it was already moderated by someone else') );
+		push( @result, "\n" );
+	} else {
+		my $mail = fetch_mail_from_file( $path );
+	
+		push( @result, 'This is the message you requested to check');
+		push( @result, 'From: ' . $mail->get('From:') );
+		push( @result, 'Subject: ' . $mail->get('Subject:') );
+		push( @result, 'Listengine ID: ' . $hash );
+		push( @result, 'Body:'."\n" . $mail->body );
+		push( @result, "\n\n".'---------------------------------------------------------------------'."\n\n" );
+		push( @result, 'To accept this message send : moderate accept'.$hash.' in subject to '.$list->get_listrequestname );
+		push( @result, 'To refuse this message send : moderate refuse'.$hash.' in subject to '.$list->get_listrequestname );
+		push( @result, "\n\n");
+	}
+	return( \@result );
+}
 
 
 #################
 # Treat a mail that seems ok
 #
 # This function treat request, sended to list-request@xxxxxxxxxx
-# It does not treat posts on list, sended to list@xxxxxxxxxx
 #################################
 sub treat_request
 {
@@ -1021,6 +1048,33 @@
 		}
 
     }
+	elsif( ( $temp ) = $subject =~ /[.\s]*letmecheck\s([a-zA-Z0-9\s]+)$/i ) {
+		#To see message body to moderate, users must be at least ADMIN
+		#So, we check this NOW
+		if( $members->{$from}{perm} != Vhffs::Constants::ML_RIGHT_ADMIN ) {
+			$email = Mail::Internet->new( [ <> ],
+				Body => Vhffs::Listengine::mail_not_allowed( $list , $from )
+				);
+			$email->replace('From' , $LISTMASTER );
+			$email->replace('To' , $from );
+			$email->replace('Subject' , gettext('listengine result command') );
+			$email->replace('Date' , datetime_rfc2822() );
+			sendmail( $email , $from );
+		} 
+		elsif( ( $hash ) = $temp =~ /letmecheck\s([a-zA-Z0-9]+)$/i ) {
+			#Ent\xEAte du mail from to sujet
+			$header = new Mail::Header( );
+			$header->replace( 'From' , $LISTMASTER );
+			$header->replace( 'To' , $from );
+			$header->replace( 'Subject' , 'letmecheck response for message '.$hash );
+			$header->replace( 'Reply-To' , $list->get_listrequestname ); 
+			$email = Mail::Internet->new( [ <> ],
+				Header => $header,
+				Body => letmecheck_message( $list , $hash )
+				);
+			sendmail( $email, $from );
+		}
+	}    
     else
     {
 		$mail = Mail::Internet->new( [ <> ],


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/