Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CNB] [MU] Mailrepository: filter content #5336

Open
chibenwa opened this issue Nov 20, 2024 · 16 comments
Open

[CNB] [MU] Mailrepository: filter content #5336

chibenwa opened this issue Nov 20, 2024 · 16 comments

Comments

@chibenwa
Copy link
Member

https://issues.apache.org/jira/browse/JAMES-4092

@hungphan227
Copy link

It seems MailRepository interface does not support listing mails by specific conditions

@chibenwa
Copy link
Member Author

No need to change this. Just do this onto the presentation layer (webadmin).

No need to be optional, I just want to easily filter this...

@hungphan227
Copy link

No need to change this. Just do this onto the presentation layer (webadmin).

No need to be optional, I just want to easily filter this...

Does this mean we have to fetch all mails from storage and do filter in memory?

@chibenwa
Copy link
Member Author

Does this mean we have to fetch all mails from storage and do filter in memory?

This is what it means. Though filtering is only done on metadata. Loading all mail content is not acceptable.

Maybe the current MailRepository API would not allow for filtering wwithout retrieving the mail content, we might need to provide methods for this in MailRepository...

So IMO:

  • Provide a defaultmethod in MailRepository listing the mails and doing 100% in memory filtering
  • Provide a smarter implementation reading only Cassandra metadata

API suggestion:

public interface MailRepository {
   interface MailReposory.Condition extends Predicate<Mail> {} 
   class UpdatedBefore implements MailReposory.Condition {
       private final ZOnedDateTime date;
       // ...
   }
   class UpdatedAfter implements MailReposory.Condition {
       private final ZOnedDateTime date;
       // ...
   }
   // ... 

    Iterator<MailKey> list(MailReposory.Condition condition) throws MessagingException;
}

Let's do it only for listing. Lets not do it for reprocessing nor deletes as it will be super verbose!

@hungphan227 hungphan227 self-assigned this Jan 13, 2025
@hungphan227
Copy link

As an administrator I want:
    To list emails in a repository in matching sender pattern
    To list emails in a repository in matching recipient pattern

Anything in regular expression could be used?

@chibenwa
Copy link
Member Author

Anything in regular expression could be used?

Let's not go with REGEXP

Let allow extact match: [email protected]

Prefix match: *@linagora.com

@hungphan227
Copy link

curl -XGET /mailRepositories/var%2Fmail%2Ferror%2F/mails?updatedBefore=2d
curl -XGET /mailRepositories/var%2Fmail%2Ferror%2F/mails?updatedAfter=2d

what does 2d mean?

@chibenwa
Copy link
Member Author

It's pretty explicit: it means the mail had been updated in the last 2 day, so the update date is more recent than this.

@hungphan227
Copy link

It's pretty explicit: it means the mail had been updated in the last 2 day, so the update date is more recent than this.

Ah ok got it:

updatedBefore=2d means updatedDate < currentDate - 2d
updatedAfter=2d means updatedDate > currentDate - 2d

Only 'd' is accepted or any other units (h,m,...) ?

@chibenwa
Copy link
Member Author

Only 'd' is accepted or any other units (h,m,...) ?

Of course other units of DurationParser are accepted.

@hungphan227
Copy link

PR for listing mails: https://github.com/apache/james-project/pull/2600/files

@hungphan227
Copy link

hungphan227 commented Jan 16, 2025

Apply it also for DELETE:

curl -XDELETE /mailRepositories/var%2Fmail%2Ferror%2F/mails?remoteHost=mx.domain.tld

And for Reprocess All (PATCH):

curl -XPATCH 127.0.0.1:8000/mailRepositories/var%2Fmail%2Ferror%2F/mails?action=reprocess&processor=transport&remoteHost=mx.domain.tld

Similar to listing api, we will apply all query paras (updatedBefore, updatedAfter, sender, ...) to delete and reprocess api, right?

@chibenwa
Copy link
Member Author

Yes but the big issue is carrying that through the task API. I really fear the upcoming boiler plate here....

Have a look if you want but in a separate PR please.

@hungphan227
Copy link

Yes but the big issue is carrying that through the task API. I really fear the upcoming boiler plate here....

Have a look if you want but in a separate PR please.

I see that boiler plate as well but of course it can still be done. Do you still want to implement those api? Are they neccessary?

@chibenwa
Copy link
Member Author

Let's keep it for later

@hungphan227
Copy link

Done: get api
Remaining tasks: delete and reprocessing api

@hungphan227 hungphan227 removed their assignment Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants