Skip to content

Instantly share code, notes, and snippets.

@rjbs
Created Apr 1, 2021
Embed
What would you like to do?
my $client = Fastmail::Client->....;
my $mbox_res = $client->request([
[ 'Mailbox/get', { accountId => ... } ],
]);
# Get all the mailbox objects:
my @boxes = $mbox_res->single_sentence('Mailbox/get')->arguments->{list}->@*;
my ($newsletter) = grep {; $_->{name} eq 'Newsletters' } @boxes;
die "WTF?!" unless $newsletter;
# NOTE: this will only find *direct* children; finding deep ancestors is left
# as an exercise for the reader (or, like, don't do that)
my @boxes_of_interest = grep {; $_->{parentId} eq $newsletter->{id} } @boxes;
exit unless @boxes_of_interest; # I guess we don't have any...
my $mail_res = $client->request([
[
'Email/query',
{
filter => {
createdAfter => '30 days ago',
also => {
operator => 'or',
conditions => [
map {; { mailboxId => $_->{id} } } @boxes_of_interest
],
}
}
},
'a',
],
[
'Email/get',
{
properties => [ ??? ],
'#ids' => {
resultOf => 'a',
name => 'Email/query',
path => '/ids',
}
},
],
]);
my @mail = $mail_res->sentence_named('Email/get')->arguments->{list}->@*;
# NEXT:
# group mail into groups by the mailboxes they're in
# sort them into rev. chron order or something
# build the XML::Feed objects
# write them out
# done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment