workaround for ejabberd history fetching

This commit is contained in:
Blue 2019-07-01 09:31:38 +03:00
parent eba33bea8a
commit 9834fc33e8
4 changed files with 24 additions and 20 deletions

View file

@ -156,12 +156,14 @@ void Core::Contact::performRequest(int count, const QString& before)
emit needHistory(before, "");
break;
case chunk:
case beginning:
case beginning: {
if (count != -1) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
}
emit needHistory("", archive->newestId());
Shared::Message msg = archive->newest();
emit needHistory("", msg.getId(), msg.getTime());
}
break;
case end:
if (count != -1) {
@ -180,6 +182,10 @@ void Core::Contact::performRequest(int count, const QString& before)
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(archive->oldestId(), "");
} catch (Archive::Empty e) {
requestCache.emplace_back(requestedCount, before);
requestedCount = -1;
emit needHistory(archive->oldestId(), "");
}
if (found) {
@ -204,6 +210,8 @@ void Core::Contact::performRequest(int count, const QString& before)
responseCache.insert(responseCache.begin(), arc.begin(), arc.end());
} catch (Archive::NotFound e) {
qDebug("requesting id hasn't been found in archive, skipping");
} catch (Archive::Empty e) {
qDebug("requesting id hasn't been found in archive, skipping");
}
nextRequest();
break;
@ -301,6 +309,8 @@ void Core::Contact::flushMessagesToArchive(bool finished, const QString& firstId
found = true;
} catch (Archive::NotFound e) {
} catch (Archive::Empty e) {
}
if (!found || requestedCount > responseCache.size()) {
if (archiveState == complete) {