sabuhish / fastapi-mail

Fastapi mail system sending mails(individual, bulk) attachments(individual, bulk)
https://sabuhish.github.io/fastapi-mail/
MIT License
680 stars 82 forks source link

Decentralise Connection #122

Closed maestro-1 closed 2 years ago

maestro-1 commented 2 years ago

This PR consists of a number of changes

sabuhish commented 2 years ago

Hi, @maestro-1 thank you for your PR. First of all sorry for being late, I could take up my head from projects. I finally got some time and wanted to take a look. Please accept my apologize.

I have reviewed the code, I have some comments that I would like to discuss. As I see you split the connection into three parts. After carefully reading, there are some issues that I realized while reading it, wanted to list them:

Please next time let's open a discussion if we would like to bring new changes, in order to be on the same page and add new features. By this way, we can follow up with each other and know what changes are coming, and what we are realizing. Thanks again.

maestro-1 commented 2 years ago

Hi, @maestro-1 thank you for your PR. First of all sorry for being late, I could take up my head from projects. I finally got some time and wanted to take a look. Please accept my apologize.

I have reviewed the code, I have some comments that I would like to discuss. As I see you split the connection into three parts. After carefully reading, there are some issues that I realized while reading it, wanted to list them:

* InvalidConnectionObject was written but it was not imported in the fastapimail.py, have you had a chance to test it. This would cause problems while running.

* On line 85 of the connection.py login established without self keyword

* In the **init**.py inside none of the new connection classes are imported which module relies on this file classes or functions to be imported

* Plus setting MAIL_DEBUG automatically starts connecting to debug server, which might not be required at all, maybe user wants to debug messages to see in their prod environment

* In the TestConnection class settings not used at all, why do we keep this argument then?

* I see connection classes check is made more than one time, once the class initialized second inside send_message method. If we have already defined it once, I think worth to use it through the class attribute

* _guess_connection is a bit seems to be tricky one,  again I am repeating we cannot relay on the given arguments and decide by ourself.

* Lastly, does it really worth having many connection classes and having checks, because they almost doing the same work with only a few changes it has.

Please next time let's open a discussion if we would like to bring new changes, in order to be on the same page and add new features. By this way, we can follow up with each other and know what changes are coming, and what we are realizing. Thanks again.

Thanks, @sabuhish for the review.

There seem to be some changes I made and forgot to push, which I will do shortly, including the updates I made to ensure the connection object isn't checked multiple time. I will be sure to make a discussion next time I plan on implementing such large changes. Note that these changes are very much compatible and do not break the way fastapi-mail currently works

maestro-1 commented 2 years ago

@sabuhish Do not know if you have gotten a chance to go through my reply. I have just gotten time to send in updates for some of the concerns you raise which I agreed with: the missing self and redundancy of the multiple checks for connection in the fastapi-mail class. I also took the liberty of adding the test case for testing login in the TestConnection class(the justification for why I added settings as a parameter to that class in the first place). As for your concerns with the MAIL_DEBUG parameter in the settings, I am certain this is not a problem, this is the use of having it in the documentation. I plan to update the documentation with all the new features as soon as this PR gets approved I also addressed your concerns about importations. Now, for the most part, I don't expect anyone to want to use those classes outside of the fastapi-mail class as it is meant to work under the hood. However, I decided that nothing will be lost in by adding it to the init file.