logic: Added weekday condition to news API
This commit is contained in:
@@ -54,6 +54,7 @@ syntax:
|
||||
"os": ["windows", "macOS", "linux"],
|
||||
"min_version": "2017.2.0",
|
||||
"max_version": "2018.4.2",
|
||||
"weekday": ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
|
||||
}
|
||||
|
||||
// optional
|
||||
@@ -205,6 +206,20 @@ bool QtNewsWidget::checkConditions(const QJsonObject& conditions) const
|
||||
}
|
||||
}
|
||||
|
||||
// weekday
|
||||
{
|
||||
QJsonArray weekdayStrings = conditions.value("weekday").toArray();
|
||||
if (!weekdayStrings.isEmpty())
|
||||
{
|
||||
QString weekdayString = QString::fromStdString(TimeStamp::now().dayOfWeekShort());
|
||||
if (!weekdayStrings.contains(QJsonValue(weekdayString)))
|
||||
{
|
||||
LOG_INFO_STREAM(<< "Failed condition weekday.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user