forked from Silverfish/proton-bridge
feat(GODT-2295): notifications for IMAP login when signed out.
This commit is contained in:
@ -467,6 +467,7 @@ bool QMLBackend::isDoHEnabled() const {
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \return The value for the 'isAutomaticUpdateOn' property.
|
||||
//****************************************************************************************************************************************************
|
||||
@ -876,8 +877,9 @@ void QMLBackend::onUserBadEvent(QString const &userID, QString const &errorMessa
|
||||
HANDLE_EXCEPTION(
|
||||
Q_UNUSED(errorMessage);
|
||||
SPUser const user = users_->getUserWithID(userID);
|
||||
if (!user)
|
||||
if (!user) {
|
||||
app().log().error(QString("Received bad event for unknown user %1").arg(user->id()));
|
||||
}
|
||||
user->setState(UserState::SignedOut);
|
||||
emit userBadEvent(tr("%1 was logged out because of an internal error.").arg(user->primaryEmailOrUsername()));
|
||||
emit selectUser(userID);
|
||||
@ -886,6 +888,24 @@ void QMLBackend::onUserBadEvent(QString const &userID, QString const &errorMessa
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
/// \param[in] username The username (or primary email address)
|
||||
//****************************************************************************************************************************************************
|
||||
void QMLBackend::onIMAPLoginFailed(QString const &username) {
|
||||
HANDLE_EXCEPTION(
|
||||
SPUser const user = users_->getUserWithUsernameOrEmail(username);
|
||||
if ((!user) || (user->state() != UserState::SignedOut)) { // We want to pop-up only if a signed-out user has been detected
|
||||
return;
|
||||
}
|
||||
if (user->isInIMAPLoginFailureCooldown())
|
||||
return;
|
||||
user->startImapLoginFailureCooldown(60 * 60 * 1000); // 1 hour cooldown during which we will not display this notification to this user again.
|
||||
emit selectUser(user->id());
|
||||
emit imapLoginWhileSignedOut(username);
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************************************************************************************
|
||||
//
|
||||
//****************************************************************************************************************************************************
|
||||
@ -994,5 +1014,7 @@ void QMLBackend::connectGrpcEvents() {
|
||||
// user events
|
||||
connect(client, &GRPCClient::userDisconnected, this, &QMLBackend::userDisconnected);
|
||||
connect(client, &GRPCClient::userBadEvent, this, &QMLBackend::onUserBadEvent);
|
||||
connect(client, &GRPCClient::imapLoginFailed, this, &QMLBackend::onIMAPLoginFailed);
|
||||
|
||||
users_->connectGRPCEvents();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user