[Codestriker-commits] CVS update: codestriker/lib/Codestriker/TopicListeners Email.pm
Brought to you by:
sits
|
From: <si...@us...> - 2006-01-16 10:38:05
|
Created Codestriker topic at: http://codestriker.sourceforge.net/cgi-bin/codestriker.pl?topic=5581589&action=view User: sits Date: 06/01/16 02:37:46 Modified: . CHANGELOG lib/Codestriker/Action SubmitNewComment.pm lib/Codestriker/TopicListeners Email.pm Log: * If there is a problem when a comment is created, the error message will correctly display in the AJAX'ed window. An example here is if $mailhost is incorrectly configured. Index: CHANGELOG =================================================================== RCS file: /cvsroot/codestriker/codestriker/CHANGELOG,v retrieving revision 1.180 retrieving revision 1.181 diff -u -r1.180 -r1.181 --- CHANGELOG 16 Jan 2006 09:51:11 -0000 1.180 +++ CHANGELOG 16 Jan 2006 10:37:45 -0000 1.181 @@ -16,6 +16,10 @@ has now been fixed. Submitted by Edwin Fine <edw...@ve...>. +* If there is a problem when a comment is created, the error message + will correctly display in the AJAX'ed window. An example here is if + $mailhost is incorrectly configured. + * Fixed problem with Subversion repositories on Win32, where Codestriker was unable to launch the svn program. Index: SubmitNewComment.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/Action/SubmitNewComment.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- SubmitNewComment.pm 15 Jan 2006 21:20:05 -0000 1.9 +++ SubmitNewComment.pm 16 Jan 2006 10:37:45 -0000 1.10 @@ -11,6 +11,7 @@ use strict; +use HTML::Entities (); use Codestriker::Model::Comment; use Codestriker::Model::File; use Codestriker::Model::Topic; @@ -72,17 +73,18 @@ # Tell the listener classes that a comment has just been created. my $listener_response = Codestriker::TopicListeners::Manager::comment_create($topic, $comment); - if ( $listener_response ne '') { - $http_response->error($listener_response); - } if (defined $format && $format eq "xml") { + my $response = $listener_response ne '' ? $listener_response : 'OK'; + print $query->header(-content_type=>'text/xml'); print "<?xml version=\"1.0\" encoding=\"UTF-8\" " . "standalone=\"yes\"?>\n"; print "<response><method>submitnewcomment</method>" . - "<result>OK</result></response>\n"; + "<result>" . HTML::Entities::encode($response) . + "</result></response>\n"; } else { + $http_response->error($listener_response) if $listener_response ne ''; # Display a simple screen indicating that the comment has been # registered. Clicking the Close button simply dismisses the # edit popup. Leaving it # up will ensure the next editing Index: Email.pm =================================================================== RCS file: /cvsroot/codestriker/codestriker/lib/Codestriker/TopicListeners/Email.pm,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- Email.pm 15 Jan 2006 21:20:06 -0000 1.15 +++ Email.pm 16 Jan 2006 10:37:46 -0000 1.16 @@ -73,10 +73,8 @@ "The topic was created with the following files:\n\n" . join("\n",@filenames); - $self->_send_topic_email($topic, 1, "Created", 1, $from, $to, $cc, $bcc, - $notes); - - return ''; + return $self->_send_topic_email($topic, 1, "Created", 1, $from, $to, $cc, + $bcc, $notes); } sub topic_changed($$$$) { @@ -157,9 +155,9 @@ my @to_list = keys( %handled_addresses ); if ( @to_list ) { - $self->send_topic_changed_email($user_that_made_the_change, - $topic_orig, $topic,@to_list); - } + return $self->send_topic_changed_email($user_that_made_the_change, + $topic_orig, $topic,@to_list); + } return ''; } @@ -396,11 +394,9 @@ if ( $Codestriker::email_send_options->{comments_sent_to_topic_author} || $comment->{cc} ne "") { - if (!$self->doit(0, $comment->{topicid}, $from, $to, - join(', ',@cc_recipients), $bcc, - $subject, $body)) { - return "Failed to send topic creation email"; - } + return $self->doit(0, $comment->{topicid}, $from, $to, + join(', ',@cc_recipients), $bcc, + $subject, $body); } return ''; @@ -432,18 +428,18 @@ $self->doit($new, $topic->{topicid}, $from, $to, $cc, $bcc, $subject, $body); } -# Send an email with the specified data. Return false if the mail can't be -# successfully delivered, true otherwise. +# Send an email with the specified data. Return a non-empty message if the +# mail can't be successfully delivered, empty string otherwise. sub doit($$$$$$$$$) { my ($type, $new, $topicid, $from, $to, $cc, $bcc, $subject, $body) = @_; - return 1 if ($DEVNULL_EMAIL); + return '' if ($DEVNULL_EMAIL); my $smtp = Net::SMTP->new($Codestriker::mailhost); - defined $smtp || die "Unable to connect to mail server: $!"; + defined $smtp || return "Unable to connect to mail server: $!"; $smtp->mail($from); - $smtp->ok() || die "Couldn't set sender to \"$from\" $!, " . + $smtp->ok() || return "Couldn't set sender to \"$from\" $!, " . $smtp->message(); # $to has to be defined. @@ -454,7 +450,7 @@ for (my $i = 0; $i <= $#receiver; $i++) { if ($receiver[$i] ne "") { $smtp->recipient($receiver[$i]); - $smtp->ok() || die "Couldn't send email to \"$receiver[$i]\" $!, " . + $smtp->ok() || return "Couldn't send email to \"$receiver[$i]\" $!, " . $smtp->message(); } else { # Can't track down why, but sometimes an empty email address @@ -486,12 +482,12 @@ $smtp->datasend("\n"); $smtp->datasend($body); $smtp->dataend(); - $smtp->ok() || die "Couldn't send email $!, " . smtp->message(); + $smtp->ok() || return "Couldn't send email $!, " . smtp->message(); $smtp->quit(); - $smtp->ok() || die "Couldn't send email $!, " . smtp->message(); + $smtp->ok() || return "Couldn't send email $!, " . smtp->message(); - return 1; + return ''; } 1; |