mirror of
https://github.com/fabianonline/telegram_backup.git
synced 2024-11-23 01:06:17 +00:00
We only need the most recent dialog in order to get the top message id.
This commit is contained in:
parent
3b01f47f38
commit
29b963ec25
@ -35,21 +35,15 @@ class DownloadManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void downloadMessages(Integer limit) throws RpcErrorException, IOException {
|
public void downloadMessages(Integer limit) throws RpcErrorException, IOException {
|
||||||
System.out.print("Downloading dialogs... ");
|
System.out.println("Downloading most recent dialog... ");
|
||||||
TLAbsDialogs dialogs = client.messagesGetDialogs(
|
int max_message_id = client.messagesGetDialogs(
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
new TLInputPeerEmpty(),
|
new TLInputPeerEmpty(),
|
||||||
100);
|
1).getDialogs().get(0).getTopMessage();
|
||||||
System.out.println("Got " + dialogs.getDialogs().size() + " dialogs.");
|
|
||||||
int max_message_id = -1;
|
|
||||||
for(TLAbsDialog dialog : dialogs.getDialogs()) {
|
|
||||||
max_message_id = Math.max(max_message_id, dialog.getTopMessage());
|
|
||||||
}
|
|
||||||
System.out.println("Top message ID is " + max_message_id);
|
System.out.println("Top message ID is " + max_message_id);
|
||||||
int max_database_id = db.getTopMessageID();
|
int max_database_id = db.getTopMessageID();
|
||||||
System.out.println("Top message ID in database is " + max_database_id);
|
System.out.println("Top message ID in database is " + max_database_id);
|
||||||
|
|
||||||
if (limit != null) {
|
if (limit != null) {
|
||||||
System.out.println("Limit is set to " + limit);
|
System.out.println("Limit is set to " + limit);
|
||||||
max_database_id = Math.max(max_database_id, max_message_id-limit);
|
max_database_id = Math.max(max_database_id, max_message_id-limit);
|
||||||
|
Loading…
Reference in New Issue
Block a user