fix: don't mark contents read

fix: crash if config is not a valid json
This commit is contained in:
ZavaruKitsu 2023-12-17 22:52:00 +03:00
parent d940dc193e
commit f06747f2a1
2 changed files with 23 additions and 8 deletions

View file

@ -1318,6 +1318,11 @@ void ApiWrap::migrateFail(not_null<PeerData*> peer, const QString &error) {
void ApiWrap::markContentsRead(
const base::flat_set<not_null<HistoryItem*>> &items) {
const auto settings = &AyuSettings::getInstance();
if (!settings->sendReadMessages) {
return;
}
auto markedIds = QVector<MTPint>();
auto channelMarkedIds = base::flat_map<
not_null<ChannelData*>,
@ -1352,6 +1357,12 @@ void ApiWrap::markContentsRead(not_null<HistoryItem*> item) {
if (!item->markContentsRead(true) || !item->isRegular()) {
return;
}
const auto settings = &AyuSettings::getInstance();
if (!settings->sendReadMessages) {
return;
}
const auto ids = MTP_vector<MTPint>(1, MTP_int(item->id));
if (const auto channel = item->history()->peer->asChannel()) {
request(MTPchannels_ReadMessageContents(

View file

@ -139,15 +139,19 @@ void load()
initialize();
json p;
file >> p;
file.close();
try {
settings = p.get<AyuGramSettings>();
}
catch (...) {
LOG(("AyuGramSettings: failed to parse settings file"));
json p;
file >> p;
file.close();
try {
settings = p.get<AyuGramSettings>();
}
catch (...) {
LOG(("AyuGramSettings: failed to parse settings file"));
}
} catch (...) {
LOG(("AyuGramSettings: failed to read settings file (not json-like)"));
}
postinitialize();
}