[Rt-commit] r5198 - in RT-Extension-CommandByEmail: . lib lib/RT
lib/RT/Extension lib/RT/Interface
lib/RT/Interface/Email/Filter t t/data
jesse at bestpractical.com
jesse at bestpractical.com
Wed May 10 22:05:37 EDT 2006
Author: jesse
Date: Wed May 10 22:05:36 2006
New Revision: 5198
Added:
RT-Extension-CommandByEmail/.cvsignore
RT-Extension-CommandByEmail/Changes
RT-Extension-CommandByEmail/MANIFEST
RT-Extension-CommandByEmail/Makefile.PL
RT-Extension-CommandByEmail/README
RT-Extension-CommandByEmail/lib/
RT-Extension-CommandByEmail/lib/RT/
RT-Extension-CommandByEmail/lib/RT/Extension/
RT-Extension-CommandByEmail/lib/RT/Extension/CommandByMail.pm
RT-Extension-CommandByEmail/lib/RT/Interface/
RT-Extension-CommandByEmail/lib/RT/Interface/Email/
RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/
RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
RT-Extension-CommandByEmail/t/
RT-Extension-CommandByEmail/t/00.load.t
RT-Extension-CommandByEmail/t/data/
RT-Extension-CommandByEmail/t/data/allfields (contents, props changed)
RT-Extension-CommandByEmail/t/pod-coverage.t
RT-Extension-CommandByEmail/t/pod.t
Log:
Initial import NOT SAFE
Added: RT-Extension-CommandByEmail/.cvsignore
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/.cvsignore Wed May 10 22:05:36 2006
@@ -0,0 +1,10 @@
+blib*
+Makefile
+Makefile.old
+Build
+_build*
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+RT-Extension-CommandByMail-*
+cover_db
Added: RT-Extension-CommandByEmail/Changes
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/Changes Wed May 10 22:05:36 2006
@@ -0,0 +1,5 @@
+Revision history for RT-Extension-CommandByMail
+
+0.0.1 Mon May 8 13:42:24 2006
+ Initial release.
+
Added: RT-Extension-CommandByEmail/MANIFEST
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/MANIFEST Wed May 10 22:05:36 2006
@@ -0,0 +1,9 @@
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/RT/Extension/CommandByMail.pm
+t/00.load.t
+t/pod-coverage.t
+t/pod.t
Added: RT-Extension-CommandByEmail/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/Makefile.PL Wed May 10 22:05:36 2006
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+die "This RT Extension will kill your pets and steal your valuables. DO NOT USE IT YET";
+name ('RT-Extension-CommandByMail');
+author ('Jesse Vincent <jesse at bestpractical.com>');
+version_from ('lib/RT/Extension/CommandByMail.pm');
+abstract_from('lib/RT/Extension/CommandByMail.pm');
+license('perl');
+requires('Test::More');
+
+&WriteAll;
Added: RT-Extension-CommandByEmail/README
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/README Wed May 10 22:05:36 2006
@@ -0,0 +1,40 @@
+RT-Extension-CommandByMail version 0.0.1
+
+[ REPLACE THIS...
+
+ The README is used to introduce the module and provide instructions on
+ how to install the module, any machine dependencies it may have (for
+ example C compilers and installed libraries) and any other information
+ that should be understood before the module is installed.
+
+ A README file is required for CPAN modules since CPAN extracts the
+ README file from a module distribution so that people browsing the
+ archive can use it get an idea of the modules uses. It is usually a
+ good idea to provide version information here so that people can
+ decide whether fixes for the module are worth downloading.
+]
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+ perl Makefile.PL
+ make
+ make test
+ make install
+
+
+
+DEPENDENCIES
+
+None.
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2006, Best Practical Solutions LLC.
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
Added: RT-Extension-CommandByEmail/lib/RT/Extension/CommandByMail.pm
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/lib/RT/Extension/CommandByMail.pm Wed May 10 22:05:36 2006
@@ -0,0 +1,156 @@
+package RT::Extension::CommandByMail;
+
+our $VERSION = '0.001';
+
+use warnings;
+use strict;
+use Carp;
+
+# Module implementation here
+
+
+1; # Magic true value required at end of module
+__END__
+
+=head1 NAME
+
+RT::Extension::CommandByMail - [One line description of module's purpose here]
+
+
+=head1 SYNOPSIS
+
+ use RT::Extension::CommandByMail;
+
+=for author to fill in:
+ Brief code example(s) here showing commonest usage(s).
+ This section will be as far as many users bother reading
+ so make it as educational and exeplary as possible.
+
+
+=head1 DESCRIPTION
+
+=for author to fill in:
+ Write a full description of the module and its features here.
+ Use subsections (=head2, =head3) as appropriate.
+
+
+=head1 INTERFACE
+
+=for author to fill in:
+ Write a separate section listing the public components of the modules
+ interface. These normally consist of either subroutines that may be
+ exported, or methods that may be called on objects belonging to the
+ classes provided by the module.
+
+
+=head1 DIAGNOSTICS
+
+=for author to fill in:
+ List every single error and warning message that the module can
+ generate (even the ones that will "never happen"), with a full
+ explanation of each problem, one or more likely causes, and any
+ suggested remedies.
+
+=over
+
+=item C<< Error message here, perhaps with %s placeholders >>
+
+[Description of error here]
+
+=item C<< Another error message here >>
+
+[Description of error here]
+
+[Et cetera, et cetera]
+
+=back
+
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+=for author to fill in:
+ A full explanation of any configuration system(s) used by the
+ module, including the names and locations of any configuration
+ files, and the meaning of any environment variables or properties
+ that can be set. These descriptions must also include details of any
+ configuration language used.
+
+RT::Extension::CommandByMail requires no configuration files or environment variables.
+
+
+=head1 DEPENDENCIES
+
+=for author to fill in:
+ A list of all the other modules that this module relies upon,
+ including any restrictions on versions, and an indication whether
+ the module is part of the standard Perl distribution, part of the
+ module's distribution, or must be installed separately. ]
+
+None.
+
+
+=head1 INCOMPATIBILITIES
+
+=for author to fill in:
+ A list of any modules that this module cannot be used in conjunction
+ with. This may be due to name conflicts in the interface, or
+ competition for system or program resources, or due to internal
+ limitations of Perl (for example, many modules that use source code
+ filters are mutually incompatible).
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+=for author to fill in:
+ A list of known problems with the module, together with some
+ indication Whether they are likely to be fixed in an upcoming
+ release. Also a list of restrictions on the features the module
+ does provide: data types that cannot be handled, performance issues
+ and the circumstances in which they may arise, practical
+ limitations on the size of data sets, special cases that are not
+ (yet) handled, etc.
+
+No bugs have been reported.
+
+Please report any bugs or feature requests to
+C<bug-rt-extension-commandbymail at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org>.
+
+
+=head1 AUTHOR
+
+Jesse Vincent C<< <jesse at bestpractical.com> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2006, Best Practical Solutions, LLC. All rights reserved.
+
+This module is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself. See L<perlartistic>.
+
+
+=head1 DISCLAIMER OF WARRANTY
+
+BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
+OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
+THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
Added: RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/lib/RT/Interface/Email/Filter/TakeAction.pm Wed May 10 22:05:36 2006
@@ -0,0 +1,231 @@
+package RT::Interface::Email::Filter::TakeAction;
+
+use warnings;
+use strict;
+
+=head2 my commands
+
+Queue: <name> Set new queue for the ticket
+Status: <status> Set new status, one of new, open, stalled,
+resolved, rejected or deleted
+Owner: <username> Set new owner using the given username
+FinalPriority: <#> Set new final priority to the given value (1-99)
+Priority: <#> Set new priority to the given value (1-99)
+Subject: <string> Set new subject to the given string
+Due: <new timestamp> Set new due date/timestamp, or 0 to disable.
++AddCc: <address> Add new Cc watcher using the email address
++DelCc: <address> Remove email address as Cc watcher
++AddAdminCc: <address> Add new AdminCc watcher using the email address
++DelAdminCc: <address> Remove email address as AdminCc watcher
++AddRequestor: <address> Add new requestor using the email address
++DelRequestor: <address> Remove email address as requestor
+Starts: <new timestamp>
+Started: <new timestamp>
+TimeWorked: <minutes> Replace the tickets 'timeworked' value.
+TimeEstimated: <minutes>
+TimeLeft: <minutes>
+DependsOn:
+DependedOnBy:
+RefersTo:
+ReferredToBy:
+HasMember:
+MemberOf:
+CustomField-C<CFName>:
+CF-C<CFName>:
+
+=cut
+
+sub GetCurrentUser {
+ my %args = (
+ Message => undef,
+ RawMessageRef => undef,
+ CurrentUser => undef,
+ AuthLevel => undef,
+ Action => undef,
+ Ticket => undef,
+ Queue => undef,
+ @_
+ );
+
+ warn "We're in it";
+
+ # If the user isn't asking for a comment or a correspond,
+ # bail out
+ if ( $args{'Action'} !~ /^(?:comment|correspond)$/i ) {
+ warn "bad action";
+ return ( $args{'CurrentUser'}, $args{'AuthLevel'} );
+ }
+
+ my @content;
+ warn "after the action";
+ my @parts = $args{'Message'}->parts_DFS;
+ foreach my $part (@parts) {
+
+ #if it looks like it has pseudoheaders, that's our content
+ if ( $part->stringify_body =~ /^(?:\S+):/m ) {
+ warn "Got it";
+ @content = $part->bodyhandle->as_lines();
+
+ last;
+ }
+
+ }
+ use YAML;
+ warn YAML::Dump( \@content );
+ warn "walking lines";
+ my @items;
+ foreach my $line (@content) {
+ warn "My line is $line";
+ last if ( $line !~ /^(?:(\S+)\s*?:\s*?(.*)\s*?|)$/ );
+ push( @items, $1 => $2 );
+ }
+ my %cmds;
+ while ( my $key = lc shift @items ) {
+ my $value = shift @items;
+ if ( $key =~ /^(?:Add|Del)/i ) {
+ push @{ $cmds{$key} }, $val;
+ } else {
+ $cmds{$key} = $val;
+
+ }
+ }
+
+ use YAML;
+ warn YAML::Dump( \@items );
+ my %results;
+
+ my $ticket_as_user = RT::Ticket->new( $args{'CurrentUser'} );
+
+ if ( $args{'Ticket'}->id ) {
+ $ticket_as_user->Load( $args{'Ticket'}->id );
+
+ foreach my $attribute (
+ qw(Queue Status Priority FinalPriority
+ TimeWorked TimeLeft TimeEstimated Subject )
+ ) {
+ next
+ unless ( defined $cmds{ lc $attribute }
+ and
+ ( $ticket_as_user->$attribute() ne $cmds{ lc $attribute } ) );
+
+ _SetAttribute(
+ $ticket_as_user, $attribute,
+ $cmds{ lc $attribute }, \%results
+ );
+ }
+
+ foreach my $attribute (qw(Due Starts Started Resolved Told)) {
+ next unless ( $cmds{ lc $attribute } );
+ my $date = RT::Date->new( $args{'CurrentUser'} );
+ $date->Set(
+ Format => 'unknown',
+ value => $cmds{ lc $attribute }
+ );
+ _SetAttribute( $ticket_as_user, $attribute, $date->ISO,
+ \%results );
+ $results{ lc $attribute }->{value} = $cmds{ lc $attribute };
+ }
+
+ foreach my $base_attribute (qw(Requestor Cc AdminCc)) {
+ foreach my $attribute ( $base_attribute, $base_attribute . "s" ) {
+ if ( my $delete = $cmds{ lc "del" . $attribute } ) {
+ foreach my $email (@$delete) {
+ _SetWatcherAttribute( $ticket_as_user, "DelWatcher",
+ "del" . $attribute,
+ $base_attribute, $email );
+ }
+ if ( my $add = $cmds{ lc "add" . $attribute } ) {
+ foreach my $email (@$add) {
+ _SetWatcherAttribute( $ticket_as_user,
+ "AddWatcher", "add" . $attribute,
+ $base_attribute, $email );
+ }
+ }
+ }
+ }
+ }
+ for (
+ qw(MemberOf Parents Members Children
+ HasMember RefersTo ReferredToBy
+ DependsOn DependedOnBy)
+ ) {
+
+ }
+
+ my $queue = RT::Queue->new( $args{'CurrentUser'} );
+ if ( $cmds{'queue'} ) {
+ $queue->Load( $cmds{'queue'} );
+ }
+
+ if ( !$queue->id ) {
+ $queue->Load( $args{'Queue'}->id );
+ }
+
+ my $custom_fields = $queue->TicketCustomFields;
+
+ while ( my $cf = $custom_fields->Next ) {
+ next unless ( defined $cmds{ lc $cf->Name } );
+ my ( $val, $msg ) = $ticket_as_user->AddCustomFieldValue(
+ Field => $cf->id,
+ Value => $cmds{ lc $cf->Name }
+ );
+ $results{ $cf->Name } = {
+ value => $cmds{ lc $cf->Name },
+ result => $val,
+ message => $msg
+ };
+ }
+
+ } else {
+
+ my %create_args = ();
+
+ # Canonicalize links
+ # Canonicalize custom fields
+ # Canonicalize watchers
+
+ $ticket_as_user->Create(%create_args);
+
+ # If we don't already have a ticket, we're going to create a new
+ # ticket
+
+ }
+ warn YAML::Dump(\%results);
+ return ( $args{'CurrentUser'}, $args{'AuthLevel'} );
+}
+
+sub _SetAttribute {
+ my $ticket = shift;
+ my $attribute = shift;
+ my $value = shift;
+ my $results = shift;
+ my $setter = "Set$attribute";
+ my ( $val, $msg ) = $ticket->$setter($value);
+ $results->{$attribute} = {
+ value => $value,
+ result => $val,
+ message => $msg
+ };
+
+}
+1;
+
+sub _SetWatcherAttribute {
+ my $ticket = shift;
+ my $method = shift;
+ my $attribute = shift;
+ my $type = shift;
+ my $email = shift;
+ my $results = shift;
+ my ( $val, $msg ) = $ticket->DelWatcher(
+ Type => $type,
+ Email => $email
+ );
+
+ $results->{$attribute} = {
+ value => $value,
+ result => $val,
+ message => $msg
+ };
+
+}
Added: RT-Extension-CommandByEmail/t/00.load.t
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/t/00.load.t Wed May 10 22:05:36 2006
@@ -0,0 +1,7 @@
+use Test::More tests => 1;
+
+BEGIN {
+use_ok( 'RT::Extension::CommandByMail' );
+}
+
+diag( "Testing RT::Extension::CommandByMail $RT::Extension::CommandByMail::VERSION" );
Added: RT-Extension-CommandByEmail/t/data/allfields
==============================================================================
Binary file. No diff available.
Added: RT-Extension-CommandByEmail/t/pod-coverage.t
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/t/pod-coverage.t Wed May 10 22:05:36 2006
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
Added: RT-Extension-CommandByEmail/t/pod.t
==============================================================================
--- (empty file)
+++ RT-Extension-CommandByEmail/t/pod.t Wed May 10 22:05:36 2006
@@ -0,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();
More information about the Rt-commit
mailing list