summaryrefslogtreecommitdiff
path: root/lib/MaildirIndexer/Index.rakumod
diff options
context:
space:
mode:
Diffstat (limited to 'lib/MaildirIndexer/Index.rakumod')
-rw-r--r--lib/MaildirIndexer/Index.rakumod29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/MaildirIndexer/Index.rakumod b/lib/MaildirIndexer/Index.rakumod
index 2cb308a..8d7ad30 100644
--- a/lib/MaildirIndexer/Index.rakumod
+++ b/lib/MaildirIndexer/Index.rakumod
@@ -2,6 +2,35 @@ use v6.d;
unit role MaildirIndexer::Index;
use MaildirIndexer::Email;
+my class AddMail is export {
+ has MaildirIndexer::Email:D $.email is required;
+ has Str:D $.mailbox is required;
+}
+my class DelPath is export {
+ has IO:D $.path is required;
+ has Str:D $.mailbox is required;
+}
+my class MailboxForEmail is export {
+ has MaildirIndexer::Email:D $.email is required;
+ has Channel:D $.reply-to is required;
+}
+
+method receive(Channel:D $channel --> Nil) {
+ react {
+ whenever $channel -> $event {
+ when $event ~~ AddMail {
+ self.add-mail($event.email, $event.mailbox);
+ }
+ when $event ~~ DelPath {
+ self.del-path($event.path, $event.mailbox);
+ }
+ when $event ~~ MailboxForEmail {
+ $event.reply-to.send(self.mailbox-for-email($event.email));
+ }
+ }
+ }
+}
+
method add-mail(MaildirIndexer::Email:D $email, Str:D $mailbox --> Nil) { ... }
method del-path(IO:D $path, Str:D $mailbox --> Nil) { ... }
method mailbox-for-email(MaildirIndexer::Email:D $email --> Str) { ... }