diff --git a/src/huggle_core/userconfiguration.cpp b/src/huggle_core/userconfiguration.cpp index 92d5f9dea..3e7bfe594 100644 --- a/src/huggle_core/userconfiguration.cpp +++ b/src/huggle_core/userconfiguration.cpp @@ -254,6 +254,8 @@ QString UserConfiguration::MakeLocalUserConfig(ProjectConfiguration *Project) AppendConf(&configuration, "show-warning-if-not-on-last-revision", this->ShowWarningIfNotOnLastRevision); AppendConf(&configuration, "number-dropdown-menu-items", this->NumberDropdownMenuItems); AppendConf(&configuration, "insert-edits-of-rolled-user-to-queue", this->InsertEditsOfRolledUserToQueue); + AppendConf(&configuration, "confirm-on-recent-warning", this->ConfirmOnRecentWarning); + AppendConf(&configuration, "confirm-warning-on-very-old-edits", this->ConfirmWarningOnVeryOldEdits); // shortcuts QStringList shortcuts = Configuration::HuggleConfiguration->Shortcuts.keys(); // we need to do this otherwise huggle may sort the items differently every time and spam wiki @@ -605,6 +607,8 @@ bool UserConfiguration::ParseYAML(QString config, ProjectConfiguration *ProjectC this->ShortcutHash = YAML2String("shortcut-hash", yaml, "null"); this->ShowWarningIfNotOnLastRevision = YAML2Bool("show-warning-if-not-on-last-revision", yaml, this->ShowWarningIfNotOnLastRevision); this->InsertEditsOfRolledUserToQueue = YAML2Bool("insert-edits-of-rolled-user-to-queue", yaml, this->InsertEditsOfRolledUserToQueue); + this->ConfirmOnRecentWarning = YAML2Bool("confirm-on-recent-warning", yaml, this->ConfirmOnRecentWarning); + this->ConfirmWarningOnVeryOldEdits = YAML2Bool("confirm-warning-on-very-old-edits", yaml, this->ConfirmWarningOnVeryOldEdits); // for now we do this only for home wiki but later we need to make it for every wiki if (IsHome) { diff --git a/src/huggle_core/userconfiguration.hpp b/src/huggle_core/userconfiguration.hpp index d54be3172..9d3d52fa8 100644 --- a/src/huggle_core/userconfiguration.hpp +++ b/src/huggle_core/userconfiguration.hpp @@ -92,6 +92,12 @@ namespace Huggle bool AutomaticallyResolveConflicts = true; bool AutomaticRefresh = true; bool AutomaticallyWatchlistWarnedUsers = false; + //! When user you want to send a warning to received another warning recently, ask if you really want to send it + bool ConfirmOnRecentWarning = true; + //! When old edit is reverted, ask if you really want to send a warning for it + bool ConfirmWarningOnVeryOldEdits = true; + //! In case edit is old or user recently got a warning, just write this into logs and don't ask user anything + bool SkipWarningOnConfirm = true; //! default-summary inherited from project config so there is no default here QString DefaultSummary; QString RollbackSummary; diff --git a/src/huggle_core/warnings.cpp b/src/huggle_core/warnings.cpp index e0cd9c4ae..ad98b782f 100644 --- a/src/huggle_core/warnings.cpp +++ b/src/huggle_core/warnings.cpp @@ -67,6 +67,27 @@ PendingWarning *Warnings::WarnUser(QString warning_type, RevertQuery *dependency return nullptr; } + if (hcfg->UserConfig->ConfirmWarningOnVeryOldEdits || hcfg->UserConfig->SkipWarningOnConfirm) + { + // User doesn't want to send warnings for edits that are too old check if this edit is not too old + if (edit->Time.addDays(1) < QDateTime::currentDateTime()) + { + // The edit is older than 1 day, so let's either ignore the request to send warning or ask user if they really want to send it + if (hcfg->UserConfig->SkipWarningOnConfirm) + { + HUGGLE_LOG("Not sending warning to " + edit->User->Username + " for their edit to " + edit->Page->PageName + " on " + edit->GetSite()->Name + + " because it's older than 1 day"); + return nullptr; + } else + { + // Ask user if they really want to send a warning here + if (!Hooks::ShowYesNoQuestion("Really send a warning?", "Edit to " + edit->Page->PageName + " on " + edit->GetSite()->Name + " by " + + edit->User->Username + " was is older than 1 day, do you really want to send them a warning message?", false)) + return nullptr; + } + } + } + // check if user wasn't changed and if was, let's update the info edit->User->Resync();