Thanks Adrian I'll give that a try.
There actually is a delete duplicates function already!!
It controls the deleting of duplicate emails from within the folders section on the users side.
This just needs to loop through the unique user id's and folder ids and should work... but I'm not sure how to do it (my perl is crap).
Not sure if that would be a quick one to figure out?
Regan
sub delete_folder_duplicates {
# -------------------------------------------------------------------
# Takes the folder ID from folders_fid as cgi input and delete any
# messages that are duplicates. The folder ID can also be passed in
# as the first argument. If it is it will ignore CGI input.
#
my ($self, $fid) = @_;
$fid ||= $IN->param('folders_fid');
$fid or return $self->error('FOLDERR_NOID', 'WARN');
$fid =~ /^\d+$/ or return $self->error('FOLDERR_ID', 'WARN', $fid);
my $sth = $DB->table('msgs', 'msgtrack')->select(
'msgs_checksum', 'msgtrack_id',
{
msgtrack_userid => $USER->{userid},
msgtrack_fid => $fid,
}
);
my (%cache, @delete);
while (my ($checksum, $id) = $sth->fetchrow()) {
if (exists($cache{$checksum})) {
push @delete, $id;
}
else {
$cache{$checksum} = 1;
}
}
my $cnt = $PLG->dispatch('GMail::Messages::delete', sub { $self->delete(@_) }, $fid, @delete);
return { message => 'MSG_DEL' }, $cnt;
}
END_OF_SUB
There actually is a delete duplicates function already!!
It controls the deleting of duplicate emails from within the folders section on the users side.
This just needs to loop through the unique user id's and folder ids and should work... but I'm not sure how to do it (my perl is crap).
Not sure if that would be a quick one to figure out?
Regan
Code:
$COMPILE{delete_folder_duplicates} = __LINE__ . <<'END_OF_SUB'; sub delete_folder_duplicates {
# -------------------------------------------------------------------
# Takes the folder ID from folders_fid as cgi input and delete any
# messages that are duplicates. The folder ID can also be passed in
# as the first argument. If it is it will ignore CGI input.
#
my ($self, $fid) = @_;
$fid ||= $IN->param('folders_fid');
$fid or return $self->error('FOLDERR_NOID', 'WARN');
$fid =~ /^\d+$/ or return $self->error('FOLDERR_ID', 'WARN', $fid);
my $sth = $DB->table('msgs', 'msgtrack')->select(
'msgs_checksum', 'msgtrack_id',
{
msgtrack_userid => $USER->{userid},
msgtrack_fid => $fid,
}
);
my (%cache, @delete);
while (my ($checksum, $id) = $sth->fetchrow()) {
if (exists($cache{$checksum})) {
push @delete, $id;
}
else {
$cache{$checksum} = 1;
}
}
my $cnt = $PLG->dispatch('GMail::Messages::delete', sub { $self->delete(@_) }, $fid, @delete);
return { message => 'MSG_DEL' }, $cnt;
}
END_OF_SUB