mirror of
https://github.com/NekoX-Dev/NekoX.git
synced 2024-12-13 14:10:20 +01:00
Improve deleteUserChannelHistoryWithSearch
This commit is contained in:
parent
1f3a23f728
commit
e136782697
@ -1,21 +1,20 @@
|
|||||||
package tw.nekomimi.nekogram;
|
package tw.nekomimi.nekogram;
|
||||||
|
|
||||||
import org.telegram.messenger.AndroidUtilities;
|
import org.telegram.messenger.AndroidUtilities;
|
||||||
import org.telegram.messenger.MessagesController;
|
import org.telegram.messenger.BaseController;
|
||||||
import org.telegram.messenger.UserConfig;
|
import org.telegram.messenger.UserConfig;
|
||||||
import org.telegram.tgnet.ConnectionsManager;
|
import org.telegram.tgnet.ConnectionsManager;
|
||||||
import org.telegram.tgnet.TLRPC;
|
import org.telegram.tgnet.TLRPC;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MessageHelper {
|
public class MessageHelper extends BaseController {
|
||||||
|
|
||||||
private static volatile MessageHelper[] Instance = new MessageHelper[UserConfig.MAX_ACCOUNT_COUNT];
|
private static volatile MessageHelper[] Instance = new MessageHelper[UserConfig.MAX_ACCOUNT_COUNT];
|
||||||
private int currentAccount;
|
|
||||||
private int lastReqId;
|
private int lastReqId;
|
||||||
|
|
||||||
public MessageHelper(int num) {
|
public MessageHelper(int num) {
|
||||||
currentAccount = num;
|
super(num);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MessageHelper getInstance(int num) {
|
public static MessageHelper getInstance(int num) {
|
||||||
@ -37,7 +36,7 @@ public class MessageHelper {
|
|||||||
|
|
||||||
public void deleteUserChannelHistoryWithSearch(final long dialog_id, final TLRPC.User user, final int offset_id) {
|
public void deleteUserChannelHistoryWithSearch(final long dialog_id, final TLRPC.User user, final int offset_id) {
|
||||||
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
|
final TLRPC.TL_messages_search req = new TLRPC.TL_messages_search();
|
||||||
req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) dialog_id);
|
req.peer = getMessagesController().getInputPeer((int) dialog_id);
|
||||||
if (req.peer == null) {
|
if (req.peer == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,12 +44,13 @@ public class MessageHelper {
|
|||||||
req.q = "";
|
req.q = "";
|
||||||
req.offset_id = offset_id;
|
req.offset_id = offset_id;
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
req.from_id = MessagesController.getInstance(currentAccount).getInputUser(user);
|
req.from_id = getMessagesController().getInputUser(user);
|
||||||
req.flags |= 1;
|
req.flags |= 1;
|
||||||
}
|
}
|
||||||
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
req.filter = new TLRPC.TL_inputMessagesFilterEmpty();
|
||||||
final int currentReqId = ++lastReqId;
|
final int currentReqId = ++lastReqId;
|
||||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
|
||||||
|
if (error == null) {
|
||||||
int lastMessageId = offset_id;
|
int lastMessageId = offset_id;
|
||||||
if (currentReqId == lastReqId) {
|
if (currentReqId == lastReqId) {
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
@ -71,10 +71,11 @@ public class MessageHelper {
|
|||||||
channelId = message.to_id.channel_id;
|
channelId = message.to_id.channel_id;
|
||||||
lastMessageId = message.id;
|
lastMessageId = message.id;
|
||||||
}
|
}
|
||||||
MessagesController.getInstance(currentAccount).deleteMessages(ids, random_ids, null, dialog_id, channelId, true, false);
|
getMessagesController().deleteMessages(ids, random_ids, null, dialog_id, channelId, true, false);
|
||||||
deleteUserChannelHistoryWithSearch(dialog_id, user, lastMessageId);
|
deleteUserChannelHistoryWithSearch(dialog_id, user, lastMessageId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
}), ConnectionsManager.RequestFlagFailOnServerErrors);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user