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

Add button for sending test email #20488

Merged
merged 1 commit into from
Mar 8, 2024
Merged

Conversation

Chocobo1
Copy link
Member

@Chocobo1 Chocobo1 commented Mar 2, 2024

This is re-submission of PR #20194 due to the author of #20194 wasn't responsive.

  • The "Support translation of WebUI error message" commit was not needed anymore due to recent refactorings.
  • Added a new commit 'Enforce 'send test email' endpoint to be POST only'
  • This PR resolved merge conflicts and has been rebased on master.

This allows for easily testing whether the provided email configuration is correct. Testing otherwise requires downloading a torrent until completion.

Note that the email is sent using the values currently saved to the config file; NOT necessarily the information currently entered into the options dialog. I'm open to ideas on how to make this more apparent to the user.

@Chocobo1 Chocobo1 added WebUI WebUI-related issues/changes WebAPI WebAPI-related issues/changes labels Mar 2, 2024
@Chocobo1 Chocobo1 added this to the 5.0 milestone Mar 2, 2024
@Chocobo1 Chocobo1 requested a review from a team March 2, 2024 08:57
@glassez
Copy link
Member

glassez commented Mar 2, 2024

  • Added a new commit 'Enforce 'send test email' endpoint to be POST only'

What's the point? It has no parameters and it isn't supposed to change the state of the application.

@glassez
Copy link
Member

glassez commented Mar 2, 2024

Note that the email is sent using the values currently saved to the config file; NOT necessarily the information currently entered into the options dialog. I'm open to ideas on how to make this more apparent to the user.

Make sendTestEmail() a free helper function independent from anything except its parameters and use it with currently entered settings as parameters.

@glassez
Copy link
Member

glassez commented Mar 2, 2024

BTW, it looks like a really good idea to be able to send a test email with the currently entered settings without requiring them to be applied. Otherwise, the user may be confused.

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 2, 2024

What's the point? It has no parameters and it isn't supposed to change the state of the application.

It is submitting a request to do something, not just fetching some data/resources.

@glassez
Copy link
Member

glassez commented Mar 2, 2024

It is submitting a request to do something, not just fetching some data/resources.

Ok.

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 2, 2024

Note that the email is sent using the values currently saved to the config file; NOT necessarily the information currently entered into the options dialog. I'm open to ideas on how to make this more apparent to the user.

Make sendTestEmail() a free helper function independent from anything except its parameters and use it with currently entered settings as parameters.

That paragraph was copied from the original PR. I consider it a good idea too but I would not like to do it in this PR due to the last PR was already approved in this state.

BTW, it looks like a really good idea to be able to send a test email with the currently entered settings without requiring them to be applied. Otherwise, the user may be confused.

I don't mind but I hope I can leave it for others to handle it.

@glassez
Copy link
Member

glassez commented Mar 2, 2024

That paragraph was copied from the original PR. I consider it a good idea too but I would not like to do it in this PR due to the last PR was already approved in this state.

I thought it was initially introduced in this PR. Apparently, I overlooked it in the original PR. So OK, let's leave it for another day.

@Piccirello
Copy link
Member

Hmm, I would much prefer to merge my original PR than to have my contribution attributed to someone else. Is this now standard procedure in this repo?

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 2, 2024

Hmm, I would much prefer to merge my original PR than to have my contribution attributed to someone else.

You are still the author: 0fd7fce
screenshot

If you insist I'll reopen yours and close mine. But do mind there are unresolved comments (and merge conflicts) in the original PR.

Is this now standard procedure in this repo?

We sometimes 'help'/adopt other PRs in case the original author is not responsive or the required changes is too much.

@glassez
Copy link
Member

glassez commented Mar 2, 2024

Hmm, I would much prefer to merge my original PR than to have my contribution attributed to someone else.

Why do you think that "my contribution attributed to someone else"? It still contains the commit that is authored by you. And it is you who will be mentioned in the changelog.

@Piccirello
Copy link
Member

My mistake, I didn't realize the commit was still attributed to me.

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 5, 2024

@glassez
PR updated, squashed commits manually. If using github 'squash and merge', Piccirello will not be the sole author.

@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 6, 2024

@glassez @sledgehammer999
The merge situation seems strange for this PR so I tested it in another repo. I found out that 'squash and merge' will make me the commit author and therefore it can't be used here. 'Merge commit' and 'rebase and merge' both will retain Piccirello as the author.
So which merge strategy to use?

@glassez
Copy link
Member

glassez commented Mar 6, 2024

The merge situation seems strange for this PR so I tested it in another repo. I found out that 'squash and merge' will make me the commit author and therefore it can't be used here.

IIRC, GitHub assigns the PR author as the author of the squashed commit (so there are no problems with "squash and merge" original PRs).

@glassez
Copy link
Member

glassez commented Mar 6, 2024

So which merge strategy to use?

I don't mind using 'rebase and merge' in this case if you first insert PR #20488. into the commit message.

This allows for easily testing whether the provided email configuration is correct.

PR qbittorrent#20488.
@Chocobo1
Copy link
Member Author

Chocobo1 commented Mar 7, 2024

I don't mind using 'rebase and merge' in this case if you first insert PR #20488. into the commit message.

Done.

@Chocobo1 Chocobo1 merged commit c06817f into qbittorrent:master Mar 8, 2024
13 checks passed
@Chocobo1 Chocobo1 deleted the pr_20194 branch March 8, 2024 13:51
+ tr("Thank you for using qBittorrent.") + u'\n';

// Send the notification email
auto *smtp = new Net::Smtp();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not passing a parent to the constructor, so this is going to leak.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind - Smtp is set to call deleteLater when its socket disconnects.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're not passing a parent to the constructor, so this is going to leak.

(clarification: the code was from #20194) You are probably right. It will happen when the procedure is still running and user exited qbt. Also Smtp destructor seems to be missing closing the socket.
Do you mind submitting a patch?

Also note this:

connect(m_socket, &QAbstractSocket::disconnected, this, &QObject::deleteLater);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will happen when the procedure is still running and user exited qbt.

What will happen?

Also Smtp destructor seems to be missing closing the socket.

Socket is closed in its destructor which is called by Smtp destructor.

Copy link
Member

@glassez glassez Mar 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I still find it a confusing design when an explicitly created object destroys itself "without the knowledge of its creator/owner".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebAPI WebAPI-related issues/changes WebUI WebUI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants