feat(GODT-2444): added queue system for UserBadEvent from different accounts.
This commit is contained in:
@ -350,4 +350,21 @@ void UsersTab::configureUserAppleMail(QString const &userID, QString const &addr
|
|||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
void UsersTab::processBadEventUserFeedback(QString const &userID, bool doResync) {
|
void UsersTab::processBadEventUserFeedback(QString const &userID, bool doResync) {
|
||||||
app().log().info(QString("Feedback received for bad event: doResync = %1, userID = %2").arg(doResync ? "true" : "false", userID));
|
app().log().info(QString("Feedback received for bad event: doResync = %1, userID = %2").arg(doResync ? "true" : "false", userID));
|
||||||
|
if (doResync) {
|
||||||
|
return; // we do not do any form of emulation for resync.
|
||||||
|
}
|
||||||
|
|
||||||
|
SPUser user = users_.userWithID(userID);
|
||||||
|
if (!user) {
|
||||||
|
app().log().error(QString("%1(): could not find user with id %1.").arg(__func__, userID));
|
||||||
|
}
|
||||||
|
|
||||||
|
user->setState(UserState::SignedOut);
|
||||||
|
users_.touch(userID);
|
||||||
|
GRPCService &grpc = app().grpc();
|
||||||
|
if (grpc.isStreaming()) {
|
||||||
|
grpc.sendEvent(newUserChangedEvent(userID));
|
||||||
|
}
|
||||||
|
|
||||||
|
this->updateGUIState();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -186,6 +186,14 @@ void UserTable::touch(qint32 index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \param[in] userID The userID.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
void UserTable::touch(QString const &userID) {
|
||||||
|
this->touch(this->indexOfUser(userID));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] index The index of the user in the list.
|
/// \param[in] index The index of the user in the list.
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
|
|||||||
@ -43,6 +43,7 @@ public: // member functions.
|
|||||||
bridgepp::SPUser userWithUsername(QString const &username); ///< Return the user with a given username.
|
bridgepp::SPUser userWithUsername(QString const &username); ///< Return the user with a given username.
|
||||||
qint32 indexOfUser(QString const &userID); ///< Return the index of a given User.
|
qint32 indexOfUser(QString const &userID); ///< Return the index of a given User.
|
||||||
void touch(qint32 index); ///< touch the user at a given index (indicates it has been modified).
|
void touch(qint32 index); ///< touch the user at a given index (indicates it has been modified).
|
||||||
|
void touch(QString const& userID); ///< touch the user with the given userID (indicates it has been modified).
|
||||||
void remove(qint32 index); ///< Remove the user at a given index.
|
void remove(qint32 index); ///< Remove the user at a given index.
|
||||||
QList<bridgepp::SPUser> users() const; ///< Return a copy of the user list.
|
QList<bridgepp::SPUser> users() const; ///< Return a copy of the user list.
|
||||||
|
|
||||||
|
|||||||
@ -822,6 +822,15 @@ void QMLBackend::setMailServerSettings(int imapPort, int smtpPort, bool useSSLFo
|
|||||||
void QMLBackend::sendBadEventUserFeedback(QString const &userID, bool doResync) {
|
void QMLBackend::sendBadEventUserFeedback(QString const &userID, bool doResync) {
|
||||||
HANDLE_EXCEPTION(
|
HANDLE_EXCEPTION(
|
||||||
app().grpc().sendBadEventUserFeedback(userID, doResync);
|
app().grpc().sendBadEventUserFeedback(userID, doResync);
|
||||||
|
|
||||||
|
// Notification dialog has just been dismissed, we remove the userID from the queue, and if there are other events in the queue, we show
|
||||||
|
// the dialog again.
|
||||||
|
badEventDisplayQueue_.removeOne(userID);
|
||||||
|
if (!badEventDisplayQueue_.isEmpty()) {
|
||||||
|
// we introduce a small delay here, so that the user notices the dialog disappear and pops up again.
|
||||||
|
QTimer::singleShot(500, [&]() { this->displayBadEventDialog(badEventDisplayQueue_.front()); });
|
||||||
|
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -879,19 +888,23 @@ void QMLBackend::onLoginAlreadyLoggedIn(QString const &userID) {
|
|||||||
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
/// \param[in] userID The userID.
|
/// \param[in] userID The userID.
|
||||||
/// \param[in] errorMessage. Unused
|
|
||||||
//****************************************************************************************************************************************************
|
//****************************************************************************************************************************************************
|
||||||
void QMLBackend::onUserBadEvent(QString const &userID, QString const &errorMessage) {
|
void QMLBackend::onUserBadEvent(QString const &userID, QString const& ) {
|
||||||
HANDLE_EXCEPTION(
|
HANDLE_EXCEPTION(
|
||||||
|
if (badEventDisplayQueue_.contains(userID)) {
|
||||||
|
app().log().error("Received 'bad event' for a user that is already in the queue.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SPUser const user = users_->getUserWithID(userID);
|
SPUser const user = users_->getUserWithID(userID);
|
||||||
if (!user)
|
if (!user) {
|
||||||
app().log().error(QString("Received bad event for unknown user %1: %2").arg(user->id(), errorMessage));
|
app().log().error(QString("Received bad event for unknown user %1."));
|
||||||
// user->setState(UserState::SignedOut);
|
}
|
||||||
emit userBadEvent(userID,
|
|
||||||
tr("Bridge ran into an internal error and it is not able to proceed with the account %1. Synchronize your local database now or logout"
|
badEventDisplayQueue_.append(userID);
|
||||||
" to do it later. Synchronization time depends on the size of your mailbox.").arg(user->primaryEmailOrUsername()));
|
if (badEventDisplayQueue_.size() == 1) { // there was no other item is the queue, we can display the dialog immediately.
|
||||||
emit selectUser(userID);
|
this->displayBadEventDialog(userID);
|
||||||
emit showMainWindow();
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1006,3 +1019,22 @@ void QMLBackend::connectGrpcEvents() {
|
|||||||
connect(client, &GRPCClient::userBadEvent, this, &QMLBackend::onUserBadEvent);
|
connect(client, &GRPCClient::userBadEvent, this, &QMLBackend::onUserBadEvent);
|
||||||
users_->connectGRPCEvents();
|
users_->connectGRPCEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
/// \param[in] userID The userID.
|
||||||
|
//****************************************************************************************************************************************************
|
||||||
|
void QMLBackend::displayBadEventDialog(QString const &userID) {
|
||||||
|
HANDLE_EXCEPTION(
|
||||||
|
SPUser const user = users_->getUserWithID(userID);
|
||||||
|
if (!user) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit userBadEvent(userID,
|
||||||
|
tr("Bridge ran into an internal error and it is not able to proceed with the account %1. Synchronize your local database now or logout"
|
||||||
|
" to do it later. Synchronization time depends on the size of your mailbox.").arg(user->primaryEmailOrUsername()));
|
||||||
|
emit selectUser(userID);
|
||||||
|
emit showMainWindow();
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@ -241,6 +241,7 @@ signals: // Signals received from the Go backend, to be forwarded to QML
|
|||||||
private: // member functions
|
private: // member functions
|
||||||
void retrieveUserList(); ///< Retrieve the list of users via gRPC.
|
void retrieveUserList(); ///< Retrieve the list of users via gRPC.
|
||||||
void connectGrpcEvents(); ///< Connect gRPC that need to be forwarded to QML via backend signals
|
void connectGrpcEvents(); ///< Connect gRPC that need to be forwarded to QML via backend signals
|
||||||
|
void displayBadEventDialog(QString const& userID); ///< Displays the bad event dialog for a user.
|
||||||
|
|
||||||
private: // data members
|
private: // data members
|
||||||
UserList *users_ { nullptr }; ///< The user list. Owned by backend.
|
UserList *users_ { nullptr }; ///< The user list. Owned by backend.
|
||||||
@ -253,6 +254,7 @@ private: // data members
|
|||||||
int smtpPort_ { 0 }; ///< The cached value for the SMTP port.
|
int smtpPort_ { 0 }; ///< The cached value for the SMTP port.
|
||||||
bool useSSLForIMAP_ { false }; ///< The cached value for useSSLForIMAP.
|
bool useSSLForIMAP_ { false }; ///< The cached value for useSSLForIMAP.
|
||||||
bool useSSLForSMTP_ { false }; ///< The cached value for useSSLForSMTP.
|
bool useSSLForSMTP_ { false }; ///< The cached value for useSSLForSMTP.
|
||||||
|
QList<QString> badEventDisplayQueue_; ///< THe queue for displaying 'bad event feedback request dialog'.
|
||||||
|
|
||||||
friend class AppController;
|
friend class AppController;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1126,8 +1126,8 @@ QtObject {
|
|||||||
text: qsTr("Synchronize")
|
text: qsTr("Synchronize")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Backend.sendBadEventUserFeedback(root.userBadEvent.userID, true)
|
|
||||||
root.userBadEvent.active = false
|
root.userBadEvent.active = false
|
||||||
|
Backend.sendBadEventUserFeedback(root.userBadEvent.userID, true)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1135,8 +1135,8 @@ QtObject {
|
|||||||
text: qsTr("Logout")
|
text: qsTr("Logout")
|
||||||
|
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
Backend.sendBadEventUserFeedback(root.userBadEvent.userID, false)
|
|
||||||
root.userBadEvent.active = false
|
root.userBadEvent.active = false
|
||||||
|
Backend.sendBadEventUserFeedback(root.userBadEvent.userID, false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user