Add get_restriction_reason helper function.
This commit is contained in:
parent
4fbe7741dc
commit
4101db16a7
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
string get_restriction_reason_description(const vector<RestrictionReason> &restriction_reasons) {
|
const RestrictionReason *get_restriction_reason(const vector<RestrictionReason> &restriction_reasons) {
|
||||||
if (restriction_reasons.empty()) {
|
if (restriction_reasons.empty()) {
|
||||||
return string();
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ignored_restriction_reasons = full_split(G()->get_option_string("ignored_restriction_reasons"), ',');
|
auto ignored_restriction_reasons = full_split(G()->get_option_string("ignored_restriction_reasons"), ',');
|
||||||
@ -45,7 +45,7 @@ string get_restriction_reason_description(const vector<RestrictionReason> &restr
|
|||||||
for (auto &restriction_reason : restriction_reasons) {
|
for (auto &restriction_reason : restriction_reasons) {
|
||||||
if (restriction_reason.platform_ == platform &&
|
if (restriction_reason.platform_ == platform &&
|
||||||
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
||||||
return restriction_reason.description_;
|
return &restriction_reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ string get_restriction_reason_description(const vector<RestrictionReason> &restr
|
|||||||
for (auto &restriction_reason : restriction_reasons) {
|
for (auto &restriction_reason : restriction_reasons) {
|
||||||
if (td::contains(restriction_add_platforms, restriction_reason.platform_) &&
|
if (td::contains(restriction_add_platforms, restriction_reason.platform_) &&
|
||||||
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
||||||
return restriction_reason.description_;
|
return &restriction_reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,11 +64,19 @@ string get_restriction_reason_description(const vector<RestrictionReason> &restr
|
|||||||
for (auto &restriction_reason : restriction_reasons) {
|
for (auto &restriction_reason : restriction_reasons) {
|
||||||
if (restriction_reason.platform_ == "all" &&
|
if (restriction_reason.platform_ == "all" &&
|
||||||
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
!td::contains(ignored_restriction_reasons, restriction_reason.reason_)) {
|
||||||
return restriction_reason.description_;
|
return &restriction_reason;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return string();
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
string get_restriction_reason_description(const vector<RestrictionReason> &restriction_reasons) {
|
||||||
|
const auto *restriction_reason = get_restriction_reason(restriction_reasons);
|
||||||
|
if (restriction_reason == nullptr) {
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
return restriction_reason->description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<RestrictionReason> get_restriction_reasons(Slice legacy_restriction_reason) {
|
vector<RestrictionReason> get_restriction_reasons(Slice legacy_restriction_reason) {
|
||||||
|
@ -29,6 +29,8 @@ class RestrictionReason {
|
|||||||
return lhs.platform_ == rhs.platform_ && lhs.reason_ == rhs.reason_ && lhs.description_ == rhs.description_;
|
return lhs.platform_ == rhs.platform_ && lhs.reason_ == rhs.reason_ && lhs.description_ == rhs.description_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
friend const RestrictionReason *get_restriction_reason(const vector<RestrictionReason> &restriction_reasons);
|
||||||
|
|
||||||
friend string get_restriction_reason_description(const vector<RestrictionReason> &restriction_reasons);
|
friend string get_restriction_reason_description(const vector<RestrictionReason> &restriction_reasons);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user