Skip to content

Commit

Permalink
implemented check for edit time
Browse files Browse the repository at this point in the history
so that we don't send warning to users for too old edits
  • Loading branch information
benapetr committed Jun 14, 2018
1 parent e06d8f8 commit d9dc452
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/huggle_core/userconfiguration.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down
6 changes: 6 additions & 0 deletions src/huggle_core/userconfiguration.hpp
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions src/huggle_core/warnings.cpp
Expand Up @@ -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();

Expand Down

0 comments on commit d9dc452

Please sign in to comment.