summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fml/lib/FML/Ticket/Model/toymodel.pm4
-rw-r--r--fml/lib/MailingList/Messages.pm74
2 files changed, 76 insertions, 2 deletions
diff --git a/fml/lib/FML/Ticket/Model/toymodel.pm b/fml/lib/FML/Ticket/Model/toymodel.pm
index 02f1686d..7bee0bf9 100644
--- a/fml/lib/FML/Ticket/Model/toymodel.pm
+++ b/fml/lib/FML/Ticket/Model/toymodel.pm
@@ -82,9 +82,9 @@ sub update_status
{
my ($self, $curproc, $args) = @_;
my $rbody = $curproc->{ article }->{ body };
- my $content = $rbody->get_content_reference();
+ my $content = $rbody->get_first_plaintext_message();
- if ($$content =~ /close/) {
+ if ($content =~ /close/) {
$self->{ _status } = "close";
}
else {
diff --git a/fml/lib/MailingList/Messages.pm b/fml/lib/MailingList/Messages.pm
index 2a5e8c81..630b5cd9 100644
--- a/fml/lib/MailingList/Messages.pm
+++ b/fml/lib/MailingList/Messages.pm
@@ -543,6 +543,10 @@ return the message size.
return this message has empty content or not.
+=head2 C<set_log_function()>
+
+internal use. set CODE REFERENCE to the log function
+
=cut
sub size
@@ -576,6 +580,76 @@ sub set_log_function
}
+sub get_content_type
+{
+ my ($self) = @_;
+ $self->{ content_type };
+}
+
+
+=head2 C<get_content_header($size)>
+
+get header in the content, which is whole mail or a part of multipart.
+
+=head2 C<get_content_body($size)>
+
+get body part in the content.
+
+=head2 C<get_first_plaintext_message($args)>
+
+ $args->{ size }
+
+=cut
+
+
+sub get_content_header
+{
+ my ($self, $size) = @_;
+ my $content = $self->{ content };
+ my $pos = index($$content, "\n\n", $self->{ offset_begin });
+ my $len = $pos - $self->{ offset_begin };
+
+ substr($$content, $self->{ offset_begin }, $len);
+}
+
+
+sub get_content_body
+{
+ my ($self, $size) = @_;
+ my $content = $self->{ content };
+ my $pos = index($$content, "\n\n", $self->{ offset_begin });
+ my $pos_begin = $pos + 2;
+ my $msglen = $self->{ offset_end } - $pos_begin;
+
+ $size ||= 512;
+ if ($msglen < $size) { $size = $msglen;}
+ return substr($$content, $pos_begin, $size);
+}
+
+
+sub get_first_plaintext_message
+{
+ my ($self, $args) = @_;
+
+ $size = $args->{ size } || 512;
+
+ # use Data::Dumper; print STDERR Dumper( $self ), "\n";
+
+ my $mp;
+ for ($mp = $self;
+ defined $mp->{ content } || defined $mp->{ next };
+ $mp = $mp->{ next }) {
+ my $type = $mp->get_content_type;
+
+ if ($type eq 'text/plain') {
+ return $mp->get_content_body($size);
+ }
+ }
+
+ return undef;
+}
+
+
sub AUTOLOAD
{
my ($self, $args) = @_;