-
Notifications
You must be signed in to change notification settings - Fork 9
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
feat(CO-727): allow Save To Files from a shared mailbox #255
Conversation
- add test to check shared mailbox is used to search for attachment - split messageId in UUID:messageId
- make test variables more idiomatic
- add map instead of flatMap to avoid nullpointer exception in case of null response from Files client - Cannot use latest mock server version because of jackson compatibility - Tests fail with missing com/fasterxml/jackson/databind/DeserializationFeature.FAIL_ON_TRAILING_TOKENS with latest version of mock server
- remove verify method call test since there is already a similar test - simplify implementation using vavr For - use vavr try withresources
- use should-when syntax
Using mockserver 5.13.0+ is not possible for jackson compatibility issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made few suggestions to improve code quality.
Please use recoverWith instead of mapFailure (as it adds additional overhead in some places where not required) in other places as well where possible. I just pointed out once instance, but saw usage in other places.
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
store/src/test/java/com/zimbra/cs/service/mail/CopyToFilesIT.java
Outdated
Show resolved
Hide resolved
* JUnit5 does not require methods to be public
* Use recoverWith to improve readability * use mapFailure when needed (multiple cases) * Add ServiceException "internal error" * Add more tests on possible failures of CopyToFiles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
I don't recommend the current exception propagation approach used in this codebase because it makes it difficult to track them in the calling function. I think it can be suitable in certain scenarios where the exceptions are not critical and can be disregarded.
Additionally, I suggest avoiding excessive use of functional chaining as it makes the code appear messy and unorganized.
I see this class as a Controller, that's why I decided to map the failure on each validation step (check token, check body, check messageId, check file exists, etc.). Then all is chained in the handle method |
- Fixup check of exception message
Sorry, but I'm completely opposite to this statement. Please do use more functional chaining as it makes the code more maintainable by making it declarative Functional seems scary at the beginning, but once it enters in your mind and you understand how it works it is a breeze to your programming experience. |
I dont have issues with employing funtional apparoach to write the code. The issue I was trying to point out is "excessive use of functional chaining" that we can see in this code. That is making the code hard to debug and read.
I mean
|
TBH it's just the "For" that makes the code messy, but the rest is quite straightforward |
@keshav I can do the following (introducing a method to get the cookie):
Edit: there also other ways, I can change a bit some of the private methods. Initially they were different, I can use the try with resources in private methods for example. I understand your point, the handle method should be as clean as possible so to understand the flow. |
- Refactor CopyToFiles to make handle method more readable - Log error instead of debug when API fails
Made changes about flow and added Log with ERROR when API fails. Check again |
The problem is not the functional approach, is that there are a lot of objects to unwrap. This is kinda a bad design for whom implemented it in the past, little we can do with such a codebase other than trying our best. |
store/src/main/java/com/zimbra/cs/service/mail/CopyToFiles.java
Outdated
Show resolved
Hide resolved
Also I saw that you edited stuff related to certbot in |
Check again, there are no changes on ProxyConfGen! |
- Use Guava not(instanceOf) instead of !( -> instanceOf)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This PR expands the Save-To-Files by enabling the feature from a shared mailbox.
Changes: