Subject: | [PATCH] A fix for delete_message()? |
Date: | Mon, 30 Jul 2007 16:47:46 +0100 |
To: | bug-www-myspace [...] rt.cpan.org |
From: | Steven Chamberlain <steven [...] pyro.eu.org> |
Hi,
Firstly, excellent work on making WWW::Myspace.
It's a shame delete_message does not work, because messages just
accumulate and inbox() becomes slower. Myspace would have me click
'select all' then 'trash selected' some 59 or more times if I wanted to
purge the folder.
However! Despite lack of experience with Perl I had a go at fixing it.
It took me a while to get to the solution, but the fix was extremely
simple. The 'POST' action is the same URL used to read a message (the
Javascript on the form sets .action to a NULL string, which in the HTML
spec. means 'submit to the same URL that served the form' -- I don't
know if submit_form() method exhibits the same behaviour). The key, I
think, is no_click=0, otherwise Myspace doesn't realise you clicked the
delete button, and just shows you the message instead.
I haven't yet run this through the test suite, but I've tested it with a
script that selectively deletes messages from a certain sender and it
has definitely worked.
Please see attached patch.
ps. calling delete_message() with an invalid message ID causes a bit of
a problem currently; Myspace redirects back to the inbox and so
delete_message retries several times before giving up. It would be nice
if it regarded the 'inbox' page as meaning 'message ID is invalid' and
the function fail straight away. I'm not sure how to do this yet...
Regards,
--
Steven Chamberlain
steven@pyro.eu.org
Index: lib/WWW/Myspace.pm
===================================================================
--- lib/WWW/Myspace.pm (revision 450)
+++ lib/WWW/Myspace.pm (working copy)
@@ -3958,8 +3963,6 @@
my ( $form, $tree, $f, $res, $id );
my $pass=1;
- warn "delete_message disabled because Myspace's Delete button doesn't work\n";
- return 0;
$self->_die_unless_logged_in( 'delete_message' );
foreach my $message ( @message_ids ) {
@@ -3971,8 +3974,7 @@
'&type=inbox&messageID='.$message.'&fed=True',
form_name => 'aspnetForm',
button => 'ctl00$ctl00$Main$Main$ReadMessage1$DeleteButton',
-# no_click => 1,
-# action => '',
+ no_click => 0,
re1 => 'Mail\s+Center.*?Read\s+Mail'
} ) or $pass = 0;