Ruiyuanjb v2.7.0版本的 MD5 值为:45f663f003665a0ca2d09dcbec30071a
以下内容为反编译后的 MessagesController.java 源代码,内容仅作参考
package im.mvtqiwsorf.messenger;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.LongSparseArray;
import android.util.SparseArray;
import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import androidx.core.app.NotificationManagerCompat;
import androidx.recyclerview.widget.ItemTouchHelper;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.UIMsg;
import com.bjz.comm.net.utils.AppPreferenceUtil;
import com.blankj.utilcode.constant.CacheConstants;
import com.google.android.exoplayer2.DefaultRenderersFactory;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy;
import com.king.zxing.util.CodeUtils;
import com.king.zxing.util.LogUtils;
import im.mvtqiwsorf.javaBean.fc.FollowedFcListBean;
import im.mvtqiwsorf.javaBean.fc.HomeFcListBean;
import im.mvtqiwsorf.javaBean.fc.RecommendFcListBean;
import im.mvtqiwsorf.messenger.MessagesStorage;
import im.mvtqiwsorf.messenger.NotificationCenter;
import im.mvtqiwsorf.messenger.support.SparseLongArray;
import im.mvtqiwsorf.messenger.voip.VoIPService;
import im.mvtqiwsorf.sqlite.SQLiteCursor;
import im.mvtqiwsorf.tgnet.ConnectionsManager;
import im.mvtqiwsorf.tgnet.NativeByteBuffer;
import im.mvtqiwsorf.tgnet.RequestDelegate;
import im.mvtqiwsorf.tgnet.TLObject;
import im.mvtqiwsorf.tgnet.TLRPC;
import im.mvtqiwsorf.tgnet.TLRPCCall;
import im.mvtqiwsorf.tgnet.TLRPCChats;
import im.mvtqiwsorf.tgnet.TLRPCContacts;
import im.mvtqiwsorf.ui.ChatActivity;
import im.mvtqiwsorf.ui.DialogsActivity;
import im.mvtqiwsorf.ui.ProfileActivity;
import im.mvtqiwsorf.ui.actionbar.AlertDialog;
import im.mvtqiwsorf.ui.actionbar.BaseFragment;
import im.mvtqiwsorf.ui.actionbar.Theme;
import im.mvtqiwsorf.ui.components.AlertsCreator;
import im.mvtqiwsorf.ui.components.toast.ToastUtils;
import im.mvtqiwsorf.ui.hui.chats.NewProfileActivity;
import im.mvtqiwsorf.ui.hui.contacts.AddContactsInfoActivity;
import im.mvtqiwsorf.ui.hui.friendscircle_v1.helper.FcDBHelper;
import im.mvtqiwsorf.ui.hviews.helper.MryDeviceHelper;
import java.io.File;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
public class MessagesController extends BaseController implements NotificationCenter.NotificationCenterDelegate {
private static volatile MessagesController[] Instance = new MessagesController[3];
public static final int UPDATE_MASK_ALL = 1535;
public static final int UPDATE_MASK_AVATAR = 2;
public static final int UPDATE_MASK_CHAT = 8192;
public static final int UPDATE_MASK_CHAT_AVATAR = 8;
public static final int UPDATE_MASK_CHAT_MEMBERS = 32;
public static final int UPDATE_MASK_CHAT_NAME = 16;
public static final int UPDATE_MASK_CHECK = 65536;
public static final int UPDATE_MASK_MESSAGE_TEXT = 32768;
public static final int UPDATE_MASK_NAME = 1;
public static final int UPDATE_MASK_NEW_MESSAGE = 2048;
public static final int UPDATE_MASK_PHONE = 1024;
public static final int UPDATE_MASK_READ_DIALOG_MESSAGE = 256;
public static final int UPDATE_MASK_REORDER = 131072;
public static final int UPDATE_MASK_SELECT_DIALOG = 512;
public static final int UPDATE_MASK_SEND_STATE = 4096;
public static final int UPDATE_MASK_STATUS = 4;
public static final int UPDATE_MASK_USER_PHONE = 128;
public static final int UPDATE_MASK_USER_PRINT = 64;
private static volatile long lastPasswordCheckTime;
private static volatile long lastThemeCheckTime;
private int DIALOGS_LOAD_TYPE_CACHE;
private int DIALOGS_LOAD_TYPE_CHANNEL;
private int DIALOGS_LOAD_TYPE_UNKNOWN;
protected ArrayList<TLRPC.Dialog> allDialogs;
public float animatedEmojisZoom;
public int availableMapProviders;
public boolean blockedCountry;
public boolean blockedEndReached;
public SparseIntArray blockedUsers;
public int callConnectTimeout;
public int callPacketTimeout;
public int callReceiveTimeout;
public int callRingTimeout;
public boolean canRevokePmInbox;
private SparseArray<SparseArray<String>> channelAdmins;
private SparseArray<ArrayList<Integer>> channelViewsToSend;
private SparseIntArray channelsPts;
private ConcurrentHashMap<Integer, TLRPC.Chat> chats;
private SparseBooleanArray checkingLastMessagesDialogs;
private boolean checkingProxyInfo;
private int checkingProxyInfoRequestId;
private boolean checkingTosUpdate;
private LongSparseArray<TLRPC.Dialog> clearingHistoryDialogs;
private boolean contactsGetDiff;
private ArrayList<Long> createdDialogIds;
private ArrayList<Long> createdDialogMainThreadIds;
private ArrayList<Long> createdScheduledDialogIds;
private Runnable currentDeleteTaskRunnable;
private int currentDeletingTaskChannelId;
private ArrayList<Integer> currentDeletingTaskMids;
private int currentDeletingTaskTime;
public String dcDomainName;
public boolean defaultP2pContacts;
public LongSparseArray<Integer> deletedHistory;
private LongSparseArray<TLRPC.Dialog> deletingDialogs;
private final Comparator<TLRPC.Dialog> dialogComparator;
public LongSparseArray<MessageObject> dialogMessage;
public SparseArray<MessageObject> dialogMessagesByIds;
public LongSparseArray<MessageObject> dialogMessagesByRandomIds;
private SparseArray<ArrayList<TLRPC.Dialog>> dialogsByFolder;
public ArrayList<TLRPC.Dialog> dialogsCanAddUsers;
public ArrayList<TLRPC.Dialog> dialogsChannelsOnly;
private SparseBooleanArray dialogsEndReached;
public ArrayList<TLRPC.Dialog> dialogsForward;
public ArrayList<TLRPC.Dialog> dialogsGroupsOnly;
private boolean dialogsInTransaction;
public boolean dialogsLoaded;
public ArrayList<TLRPC.Dialog> dialogsServerOnly;
public ArrayList<TLRPC.Dialog> dialogsUnreadOnly;
public ArrayList<TLRPC.Dialog> dialogsUsersOnly;
public LongSparseArray<TLRPC.Dialog> dialogs_dict;
public ConcurrentHashMap<Long, Integer> dialogs_read_inbox_max;
public ConcurrentHashMap<Long, Integer> dialogs_read_outbox_max;
private SharedPreferences emojiPreferences;
public boolean enableDigitCoin;
public boolean enableHub;
public boolean enableJoined;
public boolean enableWallet;
private ConcurrentHashMap<Integer, TLRPC.EncryptedChat> encryptedChats;
private SparseArray<TLRPC.ExportedChatInvite> exportedChats;
public boolean firstGettingTask;
private SparseArray<TLRPC.ChatFull> fullChats;
private SparseArray<TLRPC.UserFull> fullUsers;
private boolean getDifferenceFirstSync;
public boolean gettingDifference;
private SparseBooleanArray gettingDifferenceChannels;
private boolean gettingNewDeleteTask;
private SparseBooleanArray gettingUnknownChannels;
private LongSparseArray<Boolean> gettingUnknownDialogs;
public String gifSearchBot;
public ArrayList<TLRPC.RecentMeUrl> hintDialogs;
public String imageSearchBot;
private String installReferer;
private boolean isLeftProxyChannel;
private ArrayList<Integer> joiningToChannels;
private int lastCheckProxyId;
private int lastPrintingStringCount;
private long lastPushRegisterSendTime;
private LongSparseArray<Long> lastScheduledServerQueryTime;
private long lastStatusUpdateTime;
private long lastViewsCheckTime;
public String linkPrefix;
private ArrayList<Integer> loadedFullChats;
private ArrayList<Integer> loadedFullParticipants;
private ArrayList<Integer> loadedFullUsers;
private boolean loadingAppConfig;
public boolean loadingBlockedUsers;
private SparseIntArray loadingChannelAdmins;
private SparseBooleanArray loadingDialogs;
private ArrayList<Integer> loadingFullChats;
private ArrayList<Integer> loadingFullParticipants;
private ArrayList<Integer> loadingFullUsers;
private int loadingNotificationSettings;
private boolean loadingNotificationSignUpSettings;
private LongSparseArray<Boolean> loadingPeerSettings;
private SparseIntArray loadingPinnedDialogs;
private boolean loadingUnreadDialogs;
private SharedPreferences mainPreferences;
public String mapKey;
public int mapProvider;
public int maxBroadcastCount;
public int maxCaptionLength;
public int maxEditTime;
public int maxFaveStickersCount;
public int maxFolderPinnedDialogsCount;
public int maxGroupCount;
public int maxMegagroupCount;
public int maxMessageLength;
public int maxPinnedDialogsCount;
public int maxRecentGifsCount;
public int maxRecentStickersCount;
private SparseIntArray migratedChats;
private boolean migratingDialogs;
public int minGroupConvertSize;
private SparseIntArray needShortPollChannels;
private SparseIntArray needShortPollOnlines;
private SparseIntArray nextDialogsCacheOffset;
private int nextProxyInfoCheckTime;
private int nextTosCheckTime;
private SharedPreferences notificationsPreferences;
private ConcurrentHashMap<String, TLObject> objectsByUsernames;
private boolean offlineSent;
public ConcurrentHashMap<Integer, Integer> onlinePrivacy;
private Runnable passwordCheckRunnable;
private LongSparseArray<SparseArray<MessageObject>> pollsToCheck;
private int pollsToCheckSize;
public boolean preloadFeaturedStickers;
public LongSparseArray<CharSequence> printingStrings;
public LongSparseArray<Integer> printingStringsTypes;
public ConcurrentHashMap<Long, ArrayList<PrintingUser>> printingUsers;
private TLRPC.Dialog proxyDialog;
private String proxyDialogAddress;
private long proxyDialogId;
public int ratingDecay;
private ArrayList<ReadTask> readTasks;
private LongSparseArray<ReadTask> readTasksMap;
public boolean registeringForPush;
private LongSparseArray<ArrayList<Integer>> reloadingMessages;
private HashMap<String, ArrayList<MessageObject>> reloadingScheduledWebpages;
private LongSparseArray<ArrayList<MessageObject>> reloadingScheduledWebpagesPending;
private HashMap<String, ArrayList<MessageObject>> reloadingWebpages;
private LongSparseArray<ArrayList<MessageObject>> reloadingWebpagesPending;
private TLRPC.messages_Dialogs resetDialogsAll;
private TLRPC.TL_messages_peerDialogs resetDialogsPinned;
private boolean resetingDialogs;
public int revokeTimeLimit;
public int revokeTimePmLimit;
public int secretWebpagePreview;
public SparseArray<LongSparseArray<Boolean>> sendingTypings;
private SparseBooleanArray serverDialogsEndReached;
public String sharePrefix;
private SparseIntArray shortPollChannels;
private SparseIntArray shortPollOnlines;
private int statusRequest;
private int statusSettingState;
public boolean suggestContacts;
public String suggestedLangCode;
private Runnable themeCheckRunnable;
public int totalBlockedCount;
public int unreadUnmutedDialogs;
private final Comparator<TLRPC.Update> updatesComparator;
private SparseArray<ArrayList<TLRPC.Updates>> updatesQueueChannels;
private ArrayList<TLRPC.Updates> updatesQueuePts;
private ArrayList<TLRPC.Updates> updatesQueueQts;
private ArrayList<TLRPC.Updates> updatesQueueSeq;
private SparseLongArray updatesStartWaitTimeChannels;
private long updatesStartWaitTimePts;
private long updatesStartWaitTimeQts;
private long updatesStartWaitTimeSeq;
public boolean updatingState;
private String uploadingAvatar;
private HashMap<String, Theme.ThemeInfo> uploadingThemes;
private String uploadingWallpaper;
private boolean uploadingWallpaperBlurred;
private boolean uploadingWallpaperMotion;
private ConcurrentHashMap<Integer, TLRPC.User> users;
public String venueSearchBot;
private ArrayList<Long> visibleDialogMainThreadIds;
private ArrayList<Long> visibleScheduledDialogMainThreadIds;
public int webFileDatacenterId;
public static class PrintingUser {
public TLRPC.SendMessageAction action;
public long lastTime;
public int userId;
}
public static void lambda$blockUser$49(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$completeReadTask$164(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$deleteUserPhoto$70(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$hidePeerSettingsBar$35(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$installTheme$73(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$installTheme$74(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$markMentionMessageAsRead$159(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$markMentionsAsRead$166(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$markMessageContentAsRead$157(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$processUpdates$263(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$reportSpam$36(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$reportSpam$37(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$saveTheme$72(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$unblockUser$65(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public static void lambda$unregistedPush$207(TLObject tLObject, TLRPC.TL_error tL_error) {
}
public void lambda$new$0$MessagesController() {
getUserConfig().checkSavedPassword();
}
public static class UserActionUpdatesSeq extends TLRPC.Updates {
private UserActionUpdatesSeq() {
}
UserActionUpdatesSeq(AnonymousClass1 anonymousClass1) {
this();
}
}
public static class UserActionUpdatesPts extends TLRPC.Updates {
private UserActionUpdatesPts() {
}
UserActionUpdatesPts(AnonymousClass1 anonymousClass1) {
this();
}
}
public class ReadTask {
public long dialogId;
public int maxDate;
public int maxId;
public long sendRequestTime;
private ReadTask() {
}
ReadTask(MessagesController messagesController, AnonymousClass1 anonymousClass1) {
this();
}
}
public int lambda$new$1$MessagesController(TLRPC.Dialog dialog, TLRPC.Dialog dialog2) {
boolean z = dialog instanceof TLRPC.TL_dialogFolder;
if (z && !(dialog2 instanceof TLRPC.TL_dialogFolder)) {
return -1;
}
if (!z && (dialog2 instanceof TLRPC.TL_dialogFolder)) {
return 1;
}
if (!dialog.pinned && dialog2.pinned) {
return 1;
}
if (dialog.pinned && !dialog2.pinned) {
return -1;
}
if (dialog.pinned && dialog2.pinned) {
if (dialog.pinnedNum < dialog2.pinnedNum) {
return 1;
}
return dialog.pinnedNum > dialog2.pinnedNum ? -1 : 0;
}
TLRPC.DraftMessage draft = getMediaDataController().getDraft(dialog.id);
int i = (draft == null || draft.date < dialog.last_message_date) ? dialog.last_message_date : draft.date;
TLRPC.DraftMessage draft2 = getMediaDataController().getDraft(dialog2.id);
int i2 = (draft2 == null || draft2.date < dialog2.last_message_date) ? dialog2.last_message_date : draft2.date;
if (i < i2) {
return 1;
}
return i > i2 ? -1 : 0;
}
public int lambda$new$2$MessagesController(TLRPC.Update update, TLRPC.Update update2) {
int updateType = getUpdateType(update);
int updateType2 = getUpdateType(update2);
if (updateType != updateType2) {
return AndroidUtilities.compare(updateType, updateType2);
}
if (updateType == 0) {
return AndroidUtilities.compare(getUpdatePts(update), getUpdatePts(update2));
}
if (updateType == 1) {
return AndroidUtilities.compare(getUpdateQts(update), getUpdateQts(update2));
}
if (updateType != 2) {
return 0;
}
int updateChannelId = getUpdateChannelId(update);
int updateChannelId2 = getUpdateChannelId(update2);
if (updateChannelId == updateChannelId2) {
return AndroidUtilities.compare(getUpdatePts(update), getUpdatePts(update2));
}
return AndroidUtilities.compare(updateChannelId, updateChannelId2);
}
public static MessagesController getInstance(int i) {
MessagesController messagesController = Instance[i];
if (messagesController == null) {
synchronized (MessagesController.class) {
messagesController = Instance[i];
if (messagesController == null) {
MessagesController[] messagesControllerArr = Instance;
MessagesController messagesController2 = new MessagesController(i);
messagesControllerArr[i] = messagesController2;
messagesController = messagesController2;
}
}
}
return messagesController;
}
public static SharedPreferences getNotificationsSettings(int i) {
return getInstance(i).notificationsPreferences;
}
public static SharedPreferences getGlobalNotificationsSettings() {
return getInstance(0).notificationsPreferences;
}
public static SharedPreferences getMainSettings(int i) {
return getInstance(i).mainPreferences;
}
public static SharedPreferences getGlobalMainSettings() {
return getInstance(0).mainPreferences;
}
public static SharedPreferences getEmojiSettings(int i) {
return getInstance(i).emojiPreferences;
}
public static SharedPreferences getGlobalEmojiSettings() {
return getInstance(0).emojiPreferences;
}
public MessagesController(int i) {
super(i);
this.chats = new ConcurrentHashMap<>(100, 1.0f, 2);
this.encryptedChats = new ConcurrentHashMap<>(10, 1.0f, 2);
this.users = new ConcurrentHashMap<>(100, 1.0f, 2);
this.objectsByUsernames = new ConcurrentHashMap<>(100, 1.0f, 2);
this.joiningToChannels = new ArrayList<>();
this.exportedChats = new SparseArray<>();
this.hintDialogs = new ArrayList<>();
this.dialogsByFolder = new SparseArray<>();
this.allDialogs = new ArrayList<>();
this.dialogsForward = new ArrayList<>();
this.dialogsServerOnly = new ArrayList<>();
this.dialogsCanAddUsers = new ArrayList<>();
this.dialogsChannelsOnly = new ArrayList<>();
this.dialogsUsersOnly = new ArrayList<>();
this.dialogsGroupsOnly = new ArrayList<>();
this.dialogsUnreadOnly = new ArrayList<>();
this.dialogs_read_inbox_max = new ConcurrentHashMap<>(100, 1.0f, 2);
this.dialogs_read_outbox_max = new ConcurrentHashMap<>(100, 1.0f, 2);
this.dialogs_dict = new LongSparseArray<>();
this.dialogMessage = new LongSparseArray<>();
this.dialogMessagesByRandomIds = new LongSparseArray<>();
this.deletedHistory = new LongSparseArray<>();
this.dialogMessagesByIds = new SparseArray<>();
this.printingUsers = new ConcurrentHashMap<>(20, 1.0f, 2);
this.printingStrings = new LongSparseArray<>();
this.printingStringsTypes = new LongSparseArray<>();
this.sendingTypings = new SparseArray<>();
this.onlinePrivacy = new ConcurrentHashMap<>(20, 1.0f, 2);
this.loadingPeerSettings = new LongSparseArray<>();
this.createdDialogIds = new ArrayList<>();
this.createdScheduledDialogIds = new ArrayList<>();
this.createdDialogMainThreadIds = new ArrayList<>();
this.visibleDialogMainThreadIds = new ArrayList<>();
this.visibleScheduledDialogMainThreadIds = new ArrayList<>();
this.shortPollChannels = new SparseIntArray();
this.needShortPollChannels = new SparseIntArray();
this.shortPollOnlines = new SparseIntArray();
this.needShortPollOnlines = new SparseIntArray();
this.deletingDialogs = new LongSparseArray<>();
this.clearingHistoryDialogs = new LongSparseArray<>();
this.loadingBlockedUsers = false;
this.blockedUsers = new SparseIntArray();
this.totalBlockedCount = -1;
this.channelViewsToSend = new SparseArray<>();
this.pollsToCheck = new LongSparseArray<>();
this.updatesQueueChannels = new SparseArray<>();
this.updatesStartWaitTimeChannels = new SparseLongArray();
this.channelsPts = new SparseIntArray();
this.gettingDifferenceChannels = new SparseBooleanArray();
this.gettingUnknownChannels = new SparseBooleanArray();
this.gettingUnknownDialogs = new LongSparseArray<>();
this.checkingLastMessagesDialogs = new SparseBooleanArray();
this.updatesQueueSeq = new ArrayList<>();
this.updatesQueuePts = new ArrayList<>();
this.updatesQueueQts = new ArrayList<>();
this.fullUsers = new SparseArray<>();
this.fullChats = new SparseArray<>();
this.loadingFullUsers = new ArrayList<>();
this.loadedFullUsers = new ArrayList<>();
this.loadingFullChats = new ArrayList<>();
this.loadingFullParticipants = new ArrayList<>();
this.loadedFullParticipants = new ArrayList<>();
this.loadedFullChats = new ArrayList<>();
this.channelAdmins = new SparseArray<>();
this.loadingChannelAdmins = new SparseIntArray();
this.migratedChats = new SparseIntArray();
this.reloadingWebpages = new HashMap<>();
this.reloadingWebpagesPending = new LongSparseArray<>();
this.reloadingScheduledWebpages = new HashMap<>();
this.reloadingScheduledWebpagesPending = new LongSparseArray<>();
this.lastScheduledServerQueryTime = new LongSparseArray<>();
this.reloadingMessages = new LongSparseArray<>();
this.readTasks = new ArrayList<>();
this.readTasksMap = new LongSparseArray<>();
this.nextDialogsCacheOffset = new SparseIntArray();
this.loadingDialogs = new SparseBooleanArray();
this.dialogsEndReached = new SparseBooleanArray();
this.serverDialogsEndReached = new SparseBooleanArray();
this.getDifferenceFirstSync = true;
this.loadingPinnedDialogs = new SparseIntArray();
this.suggestContacts = true;
this.themeCheckRunnable = new Runnable() {
@Override
public final void run() {
Theme.checkAutoNightThemeConditions();
}
};
this.passwordCheckRunnable = new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$new$0$MessagesController();
}
};
this.uploadingThemes = new HashMap<>();
this.maxBroadcastCount = 100;
this.minGroupConvertSize = ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION;
this.dialogComparator = new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessagesController.this.lambda$new$1$MessagesController((TLRPC.Dialog) obj, (TLRPC.Dialog) obj2);
}
};
this.updatesComparator = new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessagesController.this.lambda$new$2$MessagesController((TLRPC.Update) obj, (TLRPC.Update) obj2);
}
};
this.DIALOGS_LOAD_TYPE_CACHE = 1;
this.DIALOGS_LOAD_TYPE_CHANNEL = 2;
this.DIALOGS_LOAD_TYPE_UNKNOWN = 3;
this.contactsGetDiff = false;
this.currentAccount = i;
ImageLoader.getInstance();
getMessagesStorage();
getLocationController();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$new$3$MessagesController();
}
});
addSupportUser();
if (this.currentAccount == 0) {
this.notificationsPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", 0);
this.mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", 0);
this.emojiPreferences = ApplicationLoader.applicationContext.getSharedPreferences("emoji", 0);
} else {
this.notificationsPreferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications" + this.currentAccount, 0);
this.mainPreferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig" + this.currentAccount, 0);
this.emojiPreferences = ApplicationLoader.applicationContext.getSharedPreferences("emoji" + this.currentAccount, 0);
}
this.enableJoined = this.notificationsPreferences.getBoolean("EnableContactJoined", true);
this.secretWebpagePreview = this.mainPreferences.getInt("secretWebpage2", 2);
this.maxGroupCount = this.mainPreferences.getInt("maxGroupCount", ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
this.maxMegagroupCount = this.mainPreferences.getInt("maxMegagroupCount", 10000);
this.maxRecentGifsCount = this.mainPreferences.getInt("maxRecentGifsCount", ItemTouchHelper.Callback.DEFAULT_DRAG_ANIMATION_DURATION);
this.maxRecentStickersCount = this.mainPreferences.getInt("maxRecentStickersCount", 30);
this.maxFaveStickersCount = this.mainPreferences.getInt("maxFaveStickersCount", 5);
this.maxEditTime = this.mainPreferences.getInt("maxEditTime", CacheConstants.HOUR);
this.ratingDecay = this.mainPreferences.getInt("ratingDecay", 2419200);
this.linkPrefix = "m12345.cc";
this.sharePrefix = this.mainPreferences.getString("sharePrefix", BuildVars.RELEASE_VERSION ? "https://m12345.cc/install.html?appkey=7HDA8K35WHGPO4" : "http://www.shareinstall.com.cn/js-test.html?appkey=7HDA8K35WHGPO4");
this.callReceiveTimeout = this.mainPreferences.getInt("callReceiveTimeout", 20000);
this.callRingTimeout = this.mainPreferences.getInt("callRingTimeout", 90000);
this.callConnectTimeout = this.mainPreferences.getInt("callConnectTimeout", UIMsg.m_AppUI.MSG_RADAR_SEARCH_RETURN_RESULT);
this.callPacketTimeout = this.mainPreferences.getInt("callPacketTimeout", 10000);
this.maxPinnedDialogsCount = this.mainPreferences.getInt("maxPinnedDialogsCount", 5);
this.maxFolderPinnedDialogsCount = this.mainPreferences.getInt("maxFolderPinnedDialogsCount", 100);
this.maxMessageLength = this.mainPreferences.getInt("maxMessageLength", 4096);
this.maxCaptionLength = this.mainPreferences.getInt("maxCaptionLength", 1024);
this.mapProvider = this.mainPreferences.getInt("mapProvider", 0);
this.availableMapProviders = this.mainPreferences.getInt("availableMapProviders", 3);
this.mapKey = this.mainPreferences.getString("pk", null);
this.installReferer = this.mainPreferences.getString("installReferer", null);
this.defaultP2pContacts = this.mainPreferences.getBoolean("defaultP2pContacts", false);
this.revokeTimeLimit = this.mainPreferences.getInt("revokeTimeLimit", this.revokeTimeLimit);
this.revokeTimePmLimit = this.mainPreferences.getInt("revokeTimePmLimit", this.revokeTimePmLimit);
this.canRevokePmInbox = this.mainPreferences.getBoolean("canRevokePmInbox", this.canRevokePmInbox);
this.preloadFeaturedStickers = this.mainPreferences.getBoolean("preloadFeaturedStickers", false);
this.proxyDialogId = this.mainPreferences.getLong("proxy_dialog", 0L);
this.proxyDialogAddress = this.mainPreferences.getString("proxyDialogAddress", null);
this.nextTosCheckTime = this.notificationsPreferences.getInt("nextTosCheckTime", 0);
this.venueSearchBot = this.mainPreferences.getString("venueSearchBot", "foursquare");
this.gifSearchBot = this.mainPreferences.getString("gifSearchBot", "gif");
this.imageSearchBot = this.mainPreferences.getString("imageSearchBot", "pic");
this.blockedCountry = this.mainPreferences.getBoolean("blockedCountry", false);
this.dcDomainName = this.mainPreferences.getString("dcDomainName2", ConnectionsManager.native_isTestBackend(this.currentAccount) != 0 ? "tapv3.stel.com" : "apv3.stel.com");
this.webFileDatacenterId = this.mainPreferences.getInt("webFileDatacenterId", ConnectionsManager.native_isTestBackend(this.currentAccount) == 0 ? 4 : 2);
this.suggestedLangCode = this.mainPreferences.getString("suggestedLangCode", "en");
this.animatedEmojisZoom = this.mainPreferences.getFloat("animatedEmojisZoom", 0.625f);
this.enableHub = this.mainPreferences.getBoolean("enable_hub", false);
this.enableWallet = this.mainPreferences.getBoolean("enable_wallet", false);
this.enableDigitCoin = this.mainPreferences.getBoolean("enable_digit_coin", false);
}
public void lambda$new$3$MessagesController() {
MessagesController messagesController = getMessagesController();
getNotificationCenter().addObserver(messagesController, NotificationCenter.FileDidUpload);
getNotificationCenter().addObserver(messagesController, NotificationCenter.FileDidFailUpload);
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileDidLoad);
getNotificationCenter().addObserver(messagesController, NotificationCenter.fileDidFailToLoad);
getNotificationCenter().addObserver(messagesController, NotificationCenter.messageReceivedByServer);
getNotificationCenter().addObserver(messagesController, NotificationCenter.updateMessageMedia);
}
private void loadAppConfig() {
if (this.loadingAppConfig) {
return;
}
this.loadingAppConfig = true;
getConnectionsManager().sendRequest(new TLRPC.TL_help_getAppConfig(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadAppConfig$5$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$loadAppConfig$5$MessagesController(final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$4$MessagesController(tLObject);
}
});
}
public void lambda$null$4$MessagesController(TLObject tLObject) {
if (tLObject instanceof TLRPC.TL_jsonObject) {
SharedPreferences.Editor edit = this.mainPreferences.edit();
TLRPC.TL_jsonObject tL_jsonObject = (TLRPC.TL_jsonObject) tLObject;
int size = tL_jsonObject.value.size();
boolean z = false;
for (int i = 0; i < size; i++) {
TLRPC.TL_jsonObjectValue tL_jsonObjectValue = tL_jsonObject.value.get(i);
if ("emojies_animated_zoom".equals(tL_jsonObjectValue.key) && (tL_jsonObjectValue.value instanceof TLRPC.TL_jsonNumber)) {
TLRPC.TL_jsonNumber tL_jsonNumber = (TLRPC.TL_jsonNumber) tL_jsonObjectValue.value;
if (this.animatedEmojisZoom != tL_jsonNumber.value) {
float f = (float) tL_jsonNumber.value;
this.animatedEmojisZoom = f;
edit.putFloat("animatedEmojisZoom", f);
z = true;
}
}
}
if (z) {
edit.commit();
}
}
this.loadingAppConfig = false;
}
public void updateConfig(final TLRPC.TL_config tL_config) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$updateConfig$6$MessagesController(tL_config);
}
});
}
public void lambda$updateConfig$6$MessagesController(TLRPC.TL_config tL_config) {
String str;
getDownloadController().loadAutoDownloadConfig(false);
loadAppConfig();
this.maxMegagroupCount = tL_config.megagroup_size_max;
this.maxGroupCount = tL_config.chat_size_max;
this.maxEditTime = tL_config.edit_time_limit;
this.ratingDecay = tL_config.rating_e_decay;
this.maxRecentGifsCount = tL_config.saved_gifs_limit;
this.maxRecentStickersCount = tL_config.stickers_recent_limit;
this.maxFaveStickersCount = tL_config.stickers_faved_limit;
this.revokeTimeLimit = tL_config.revoke_time_limit;
this.revokeTimePmLimit = tL_config.revoke_pm_time_limit;
this.canRevokePmInbox = tL_config.revoke_pm_inbox;
this.linkPrefix = "m12345.cc";
if ("m12345.cc".endsWith("/")) {
String str2 = this.linkPrefix;
this.linkPrefix = str2.substring(0, str2.length() - 1);
}
if (this.linkPrefix.startsWith("https://")) {
this.linkPrefix = this.linkPrefix.substring(8);
} else if (this.linkPrefix.startsWith("http://")) {
this.linkPrefix = this.linkPrefix.substring(7);
}
this.linkPrefix = "m12345.cc";
this.sharePrefix = tL_config.me_url_prefix;
this.callReceiveTimeout = tL_config.call_receive_timeout_ms;
this.callRingTimeout = tL_config.call_ring_timeout_ms;
this.callConnectTimeout = tL_config.call_connect_timeout_ms;
this.callPacketTimeout = tL_config.call_packet_timeout_ms;
this.maxPinnedDialogsCount = tL_config.pinned_dialogs_count_max;
this.maxFolderPinnedDialogsCount = tL_config.pinned_infolder_count_max;
this.maxMessageLength = tL_config.message_length_max;
this.maxCaptionLength = tL_config.caption_length_max;
this.defaultP2pContacts = tL_config.default_p2p_contacts;
this.preloadFeaturedStickers = tL_config.preload_featured_stickers;
this.enableHub = ((tL_config.flags >> 19) & 1) != 0;
this.enableWallet = ((tL_config.flags >> 20) & 1) != 0;
this.enableDigitCoin = ((tL_config.flags >> 21) & 1) != 0;
if (tL_config.venue_search_username != null) {
this.venueSearchBot = tL_config.venue_search_username;
}
if (tL_config.gif_search_username != null) {
this.gifSearchBot = tL_config.gif_search_username;
}
if (this.imageSearchBot != null) {
this.imageSearchBot = tL_config.img_search_username;
}
this.blockedCountry = tL_config.blocked_mode;
this.dcDomainName = tL_config.dc_txt_domain_name;
this.webFileDatacenterId = tL_config.webfile_dc_id;
if (tL_config.suggested_lang_code != null && ((str = this.suggestedLangCode) == null || !str.equals(tL_config.suggested_lang_code))) {
this.suggestedLangCode = tL_config.suggested_lang_code;
LocaleController.getInstance().loadRemoteLanguages(this.currentAccount);
}
Theme.loadRemoteThemes(this.currentAccount, false);
Theme.checkCurrentRemoteTheme(false);
if (tL_config.static_maps_provider == null) {
tL_config.static_maps_provider = "google";
}
this.mapKey = null;
this.mapProvider = 2;
this.availableMapProviders = 0;
String[] split = tL_config.static_maps_provider.split(",");
for (int i = 0; i < split.length; i++) {
String[] split2 = split[i].split("\\+");
if (split2.length > 0) {
String[] split3 = split2[0].split(LogUtils.COLON);
if (split3.length > 0) {
if ("yandex".equals(split3[0])) {
if (i == 0) {
if (split2.length > 1) {
this.mapProvider = 3;
} else {
this.mapProvider = 1;
}
}
this.availableMapProviders |= 4;
} else if ("google".equals(split3[0])) {
if (i == 0 && split2.length > 1) {
this.mapProvider = 4;
}
this.availableMapProviders |= 1;
} else if ("hchat".equals(split3[0])) {
if (i == 0) {
this.mapProvider = 2;
}
this.availableMapProviders |= 2;
}
if (split3.length > 1) {
this.mapKey = split3[1];
}
}
}
}
SharedPreferences.Editor edit = this.mainPreferences.edit();
edit.putInt("maxGroupCount", this.maxGroupCount);
edit.putInt("maxMegagroupCount", this.maxMegagroupCount);
edit.putInt("maxEditTime", this.maxEditTime);
edit.putInt("ratingDecay", this.ratingDecay);
edit.putInt("maxRecentGifsCount", this.maxRecentGifsCount);
edit.putInt("maxRecentStickersCount", this.maxRecentStickersCount);
edit.putInt("maxFaveStickersCount", this.maxFaveStickersCount);
edit.putInt("callReceiveTimeout", this.callReceiveTimeout);
edit.putInt("callRingTimeout", this.callRingTimeout);
edit.putInt("callConnectTimeout", this.callConnectTimeout);
edit.putInt("callPacketTimeout", this.callPacketTimeout);
edit.putString("linkPrefix", this.linkPrefix);
edit.putString("sharePrefix", this.sharePrefix);
edit.putInt("maxPinnedDialogsCount", this.maxPinnedDialogsCount);
edit.putInt("maxFolderPinnedDialogsCount", this.maxFolderPinnedDialogsCount);
edit.putInt("maxMessageLength", this.maxMessageLength);
edit.putInt("maxCaptionLength", this.maxCaptionLength);
edit.putBoolean("defaultP2pContacts", this.defaultP2pContacts);
edit.putBoolean("preloadFeaturedStickers", this.preloadFeaturedStickers);
edit.putInt("revokeTimeLimit", this.revokeTimeLimit);
edit.putInt("revokeTimePmLimit", this.revokeTimePmLimit);
edit.putInt("mapProvider", this.mapProvider);
String str3 = this.mapKey;
if (str3 != null) {
edit.putString("pk", str3);
} else {
edit.remove("pk");
}
edit.putBoolean("canRevokePmInbox", this.canRevokePmInbox);
edit.putBoolean("blockedCountry", this.blockedCountry);
edit.putString("venueSearchBot", this.venueSearchBot);
edit.putString("gifSearchBot", this.gifSearchBot);
edit.putString("imageSearchBot", this.imageSearchBot);
edit.putString("dcDomainName2", this.dcDomainName);
edit.putInt("webFileDatacenterId", this.webFileDatacenterId);
edit.putString("suggestedLangCode", this.suggestedLangCode);
edit.putBoolean("enable_hub", this.enableHub);
edit.putBoolean("enable_wallet", this.enableWallet);
edit.putBoolean("enable_digit_coin", this.enableDigitCoin);
edit.commit();
LocaleController.getInstance().checkUpdateForCurrentRemoteLocale(this.currentAccount, tL_config.lang_pack_version, tL_config.base_lang_pack_version);
getNotificationCenter().postNotificationName(NotificationCenter.configLoaded, new Object[0]);
}
public void addSupportUser() {
TLRPC.TL_userForeign_old2 tL_userForeign_old2 = new TLRPC.TL_userForeign_old2();
tL_userForeign_old2.phone = "333";
tL_userForeign_old2.id = 333000;
tL_userForeign_old2.first_name = "Hong";
tL_userForeign_old2.last_name = "";
tL_userForeign_old2.status = null;
tL_userForeign_old2.photo = new TLRPC.TL_userProfilePhotoEmpty();
putUser(tL_userForeign_old2, true);
TLRPC.TL_userForeign_old2 tL_userForeign_old22 = new TLRPC.TL_userForeign_old2();
tL_userForeign_old22.phone = "42777";
tL_userForeign_old22.id = 777000;
tL_userForeign_old22.verified = true;
tL_userForeign_old22.first_name = "Hong";
tL_userForeign_old22.last_name = "Notifications";
tL_userForeign_old22.status = null;
tL_userForeign_old22.photo = new TLRPC.TL_userProfilePhotoEmpty();
putUser(tL_userForeign_old22, true);
}
public TLRPC.InputUser getInputUser(TLRPC.User user) {
if (user == null) {
return new TLRPC.TL_inputUserEmpty();
}
if (user.id == getUserConfig().getClientUserId()) {
return new TLRPC.TL_inputUserSelf();
}
TLRPC.TL_inputUser tL_inputUser = new TLRPC.TL_inputUser();
tL_inputUser.user_id = user.id;
tL_inputUser.access_hash = user.access_hash;
return tL_inputUser;
}
public TLRPC.InputUser getInputUser(int i) {
return getInputUser(getInstance(UserConfig.selectedAccount).getUser(Integer.valueOf(i)));
}
public static TLRPC.InputChannel getInputChannel(TLRPC.Chat chat) {
if ((chat instanceof TLRPC.TL_channel) || (chat instanceof TLRPC.TL_channelForbidden)) {
TLRPC.TL_inputChannel tL_inputChannel = new TLRPC.TL_inputChannel();
tL_inputChannel.channel_id = chat.id;
tL_inputChannel.access_hash = chat.access_hash;
return tL_inputChannel;
}
return new TLRPC.TL_inputChannelEmpty();
}
public TLRPC.InputChannel getInputChannel(int i) {
return getInputChannel(getChat(Integer.valueOf(i)));
}
public TLRPC.InputPeer getInputPeer(int i) {
if (i < 0) {
int i2 = -i;
TLRPC.Chat chat = getChat(Integer.valueOf(i2));
if (ChatObject.isChannel(chat)) {
TLRPC.TL_inputPeerChannel tL_inputPeerChannel = new TLRPC.TL_inputPeerChannel();
tL_inputPeerChannel.channel_id = i2;
tL_inputPeerChannel.access_hash = chat.access_hash;
return tL_inputPeerChannel;
}
TLRPC.TL_inputPeerChat tL_inputPeerChat = new TLRPC.TL_inputPeerChat();
tL_inputPeerChat.chat_id = i2;
return tL_inputPeerChat;
}
TLRPC.User user = getUser(Integer.valueOf(i));
TLRPC.TL_inputPeerUser tL_inputPeerUser = new TLRPC.TL_inputPeerUser();
tL_inputPeerUser.user_id = i;
if (user == null) {
return tL_inputPeerUser;
}
tL_inputPeerUser.access_hash = user.access_hash;
return tL_inputPeerUser;
}
public TLRPC.Peer getPeer(int i) {
if (i < 0) {
int i2 = -i;
TLRPC.Chat chat = getChat(Integer.valueOf(i2));
if ((chat instanceof TLRPC.TL_channel) || (chat instanceof TLRPC.TL_channelForbidden)) {
TLRPC.TL_peerChannel tL_peerChannel = new TLRPC.TL_peerChannel();
tL_peerChannel.channel_id = i2;
return tL_peerChannel;
}
TLRPC.TL_peerChat tL_peerChat = new TLRPC.TL_peerChat();
tL_peerChat.chat_id = i2;
return tL_peerChat;
}
getUser(Integer.valueOf(i));
TLRPC.TL_peerUser tL_peerUser = new TLRPC.TL_peerUser();
tL_peerUser.user_id = i;
return tL_peerUser;
}
@Override
public void didReceivedNotification(int i, int i2, Object... objArr) {
if (i == NotificationCenter.FileDidUpload) {
String str = (String) objArr[0];
TLRPC.InputFile inputFile = (TLRPC.InputFile) objArr[1];
String str2 = this.uploadingAvatar;
if (str2 != null && str2.equals(str)) {
TLRPC.TL_photos_uploadProfilePhoto tL_photos_uploadProfilePhoto = new TLRPC.TL_photos_uploadProfilePhoto();
tL_photos_uploadProfilePhoto.file = inputFile;
getConnectionsManager().sendRequest(tL_photos_uploadProfilePhoto, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$didReceivedNotification$8$MessagesController(tLObject, tL_error);
}
});
return;
}
String str3 = this.uploadingWallpaper;
if (str3 != null && str3.equals(str)) {
TLRPC.TL_account_uploadWallPaper tL_account_uploadWallPaper = new TLRPC.TL_account_uploadWallPaper();
tL_account_uploadWallPaper.file = inputFile;
tL_account_uploadWallPaper.mime_type = "image/jpeg";
final TLRPC.TL_wallPaperSettings tL_wallPaperSettings = new TLRPC.TL_wallPaperSettings();
tL_wallPaperSettings.blur = this.uploadingWallpaperBlurred;
tL_wallPaperSettings.motion = this.uploadingWallpaperMotion;
tL_account_uploadWallPaper.settings = tL_wallPaperSettings;
getConnectionsManager().sendRequest(tL_account_uploadWallPaper, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$didReceivedNotification$10$MessagesController(tL_wallPaperSettings, tLObject, tL_error);
}
});
return;
}
final Theme.ThemeInfo themeInfo = this.uploadingThemes.get(str);
if (themeInfo != null) {
if (str.equals(themeInfo.uploadingThumb)) {
themeInfo.uploadedThumb = inputFile;
themeInfo.uploadingThumb = null;
} else if (str.equals(themeInfo.uploadingFile)) {
themeInfo.uploadedFile = inputFile;
themeInfo.uploadingFile = null;
}
if (themeInfo.uploadedFile != null && themeInfo.uploadedThumb != null) {
new File(str);
TLRPC.TL_account_uploadTheme tL_account_uploadTheme = new TLRPC.TL_account_uploadTheme();
tL_account_uploadTheme.mime_type = "application/x-tgtheme-android";
tL_account_uploadTheme.file_name = "theme.attheme";
tL_account_uploadTheme.file = themeInfo.uploadedFile;
tL_account_uploadTheme.file.name = "theme.attheme";
tL_account_uploadTheme.thumb = themeInfo.uploadedThumb;
tL_account_uploadTheme.thumb.name = "theme-preview.jpg";
tL_account_uploadTheme.flags = 1 | tL_account_uploadTheme.flags;
themeInfo.uploadedFile = null;
themeInfo.uploadedThumb = null;
getConnectionsManager().sendRequest(tL_account_uploadTheme, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$didReceivedNotification$16$MessagesController(themeInfo, tLObject, tL_error);
}
});
}
this.uploadingThemes.remove(str);
return;
}
return;
}
if (i == NotificationCenter.FileDidFailUpload) {
String str4 = (String) objArr[0];
String str5 = this.uploadingAvatar;
if (str5 != null && str5.equals(str4)) {
this.uploadingAvatar = null;
return;
}
String str6 = this.uploadingWallpaper;
if (str6 != null && str6.equals(str4)) {
this.uploadingWallpaper = null;
return;
}
Theme.ThemeInfo remove = this.uploadingThemes.remove(str4);
if (remove != null) {
remove.uploadedFile = null;
remove.uploadedThumb = null;
return;
}
return;
}
if (i == NotificationCenter.messageReceivedByServer) {
if (((Boolean) objArr[6]).booleanValue()) {
return;
}
Integer num = (Integer) objArr[0];
Integer num2 = (Integer) objArr[1];
Long l = (Long) objArr[3];
MessageObject messageObject = this.dialogMessage.get(l.longValue());
if (messageObject != null && (messageObject.getId() == num.intValue() || messageObject.messageOwner.local_id == num.intValue())) {
messageObject.messageOwner.id = num2.intValue();
messageObject.messageOwner.send_state = 0;
}
TLRPC.Dialog dialog = this.dialogs_dict.get(l.longValue());
if (dialog != null && dialog.top_message == num.intValue()) {
dialog.top_message = num2.intValue();
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
MessageObject messageObject2 = this.dialogMessagesByIds.get(num.intValue());
this.dialogMessagesByIds.remove(num.intValue());
if (messageObject2 != null) {
this.dialogMessagesByIds.put(num2.intValue(), messageObject2);
}
int longValue = (int) l.longValue();
if (longValue < 0) {
int i3 = -longValue;
TLRPC.ChatFull chatFull = this.fullChats.get(i3);
TLRPC.Chat chat = getChat(Integer.valueOf(i3));
if (chat == null || ChatObject.hasAdminRights(chat) || chatFull == null || chatFull.slowmode_seconds == 0) {
return;
}
chatFull.slowmode_next_send_date = ConnectionsManager.getInstance(this.currentAccount).getCurrentTime() + chatFull.slowmode_seconds;
chatFull.flags |= 262144;
getMessagesStorage().updateChatInfo(chatFull, false);
return;
}
return;
}
if (i == NotificationCenter.updateMessageMedia) {
TLRPC.Message message = (TLRPC.Message) objArr[0];
MessageObject messageObject3 = this.dialogMessagesByIds.get(message.id);
if (messageObject3 != null) {
messageObject3.messageOwner.media = message.media;
if (message.media.ttl_seconds != 0) {
if ((message.media.photo instanceof TLRPC.TL_photoEmpty) || (message.media.document instanceof TLRPC.TL_documentEmpty)) {
messageObject3.setType();
getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
}
}
}
}
}
public void lambda$didReceivedNotification$8$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
if (user == null) {
user = getUserConfig().getCurrentUser();
putUser(user, true);
} else {
getUserConfig().setCurrentUser(user);
}
if (user == null) {
return;
}
TLRPC.TL_photos_photo tL_photos_photo = (TLRPC.TL_photos_photo) tLObject;
ArrayList<TLRPC.PhotoSize> arrayList = tL_photos_photo.photo.sizes;
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(arrayList, 100);
TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(arrayList, 1000);
user.photo = new TLRPC.TL_userProfilePhoto();
user.photo.photo_id = tL_photos_photo.photo.id;
if (closestPhotoSizeWithSize != null) {
user.photo.photo_small = closestPhotoSizeWithSize.location;
}
if (closestPhotoSizeWithSize2 != null) {
user.photo.photo_big = closestPhotoSizeWithSize2.location;
} else if (closestPhotoSizeWithSize != null) {
user.photo.photo_small = closestPhotoSizeWithSize.location;
}
getMessagesStorage().clearUserPhotos(user.id);
ArrayList<TLRPC.User> arrayList2 = new ArrayList<>();
arrayList2.add(user);
getMessagesStorage().putUsersAndChats(arrayList2, null, false, true);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$7$MessagesController();
}
});
}
}
public void lambda$null$7$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 2);
getUserConfig().saveConfig(true);
}
public void lambda$didReceivedNotification$10$MessagesController(final TLRPC.TL_wallPaperSettings tL_wallPaperSettings, TLObject tLObject, TLRPC.TL_error tL_error) {
final TLRPC.TL_wallPaper tL_wallPaper = (TLRPC.TL_wallPaper) tLObject;
final File file = new File(ApplicationLoader.getFilesDirFixed(), this.uploadingWallpaperBlurred ? "wallpaper_original.jpg" : "wallpaper.jpg");
if (tL_wallPaper != null) {
try {
AndroidUtilities.copyFile(file, FileLoader.getPathToAttach(tL_wallPaper.document, true));
} catch (Exception unused) {
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$9$MessagesController(tL_wallPaper, tL_wallPaperSettings, file);
}
});
}
public void lambda$null$9$MessagesController(TLRPC.TL_wallPaper tL_wallPaper, TLRPC.TL_wallPaperSettings tL_wallPaperSettings, File file) {
if (this.uploadingWallpaper == null || tL_wallPaper == null) {
return;
}
tL_wallPaper.settings = tL_wallPaperSettings;
tL_wallPaper.flags |= 4;
SharedPreferences.Editor edit = getGlobalMainSettings().edit();
edit.putLong("selectedBackground2", tL_wallPaper.id);
edit.putString("selectedBackgroundSlug", tL_wallPaper.slug);
edit.commit();
ArrayList<TLRPC.WallPaper> arrayList = new ArrayList<>();
arrayList.add(tL_wallPaper);
getMessagesStorage().putWallpapers(arrayList, 2);
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(tL_wallPaper.document.thumbs, 320);
if (closestPhotoSizeWithSize != null) {
ImageLoader.getInstance().replaceImageInCache(Utilities.MD5(file.getAbsolutePath()) + "@100_100", closestPhotoSizeWithSize.location.volume_id + "_" + closestPhotoSizeWithSize.location.local_id + "@100_100", ImageLocation.getForDocument(closestPhotoSizeWithSize, tL_wallPaper.document), false);
}
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.wallpapersNeedReload, Long.valueOf(tL_wallPaper.id));
}
public void lambda$didReceivedNotification$16$MessagesController(final Theme.ThemeInfo themeInfo, TLObject tLObject, TLRPC.TL_error tL_error) {
int lastIndexOf = themeInfo.name.lastIndexOf(".attheme");
String substring = lastIndexOf > 0 ? themeInfo.name.substring(0, lastIndexOf) : themeInfo.name;
if (tLObject != null) {
TLRPC.Document document = (TLRPC.Document) tLObject;
TLRPC.TL_inputDocument tL_inputDocument = new TLRPC.TL_inputDocument();
tL_inputDocument.access_hash = document.access_hash;
tL_inputDocument.id = document.id;
tL_inputDocument.file_reference = document.file_reference;
if (themeInfo.info == null || !themeInfo.info.creator) {
TLRPC.TL_account_createTheme tL_account_createTheme = new TLRPC.TL_account_createTheme();
tL_account_createTheme.document = tL_inputDocument;
tL_account_createTheme.slug = (themeInfo.info == null || TextUtils.isEmpty(themeInfo.info.slug)) ? "" : themeInfo.info.slug;
tL_account_createTheme.title = substring;
getConnectionsManager().sendRequest(tL_account_createTheme, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error2) {
MessagesController.this.lambda$null$12$MessagesController(themeInfo, tLObject2, tL_error2);
}
});
return;
}
TLRPC.TL_account_updateTheme tL_account_updateTheme = new TLRPC.TL_account_updateTheme();
TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
tL_inputTheme.id = themeInfo.info.id;
tL_inputTheme.access_hash = themeInfo.info.access_hash;
tL_account_updateTheme.theme = tL_inputTheme;
tL_account_updateTheme.slug = themeInfo.info.slug;
tL_account_updateTheme.flags |= 1;
tL_account_updateTheme.title = substring;
tL_account_updateTheme.flags |= 2;
tL_account_updateTheme.document = tL_inputDocument;
tL_account_updateTheme.flags |= 4;
tL_account_updateTheme.format = "android";
getConnectionsManager().sendRequest(tL_account_updateTheme, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error2) {
MessagesController.this.lambda$null$14$MessagesController(themeInfo, tLObject2, tL_error2);
}
});
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$15$MessagesController(themeInfo);
}
});
}
public void lambda$null$12$MessagesController(final Theme.ThemeInfo themeInfo, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$11$MessagesController(tLObject, themeInfo);
}
});
}
public void lambda$null$11$MessagesController(TLObject tLObject, Theme.ThemeInfo themeInfo) {
if (tLObject instanceof TLRPC.TL_theme) {
Theme.setThemeUploadInfo(themeInfo, (TLRPC.TL_theme) tLObject, false);
installTheme(themeInfo, themeInfo == Theme.getCurrentNightTheme());
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadedToServer, themeInfo);
return;
}
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
}
public void lambda$null$14$MessagesController(final Theme.ThemeInfo themeInfo, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$13$MessagesController(tLObject, themeInfo);
}
});
}
public void lambda$null$13$MessagesController(TLObject tLObject, Theme.ThemeInfo themeInfo) {
if (tLObject instanceof TLRPC.TL_theme) {
Theme.setThemeUploadInfo(themeInfo, (TLRPC.TL_theme) tLObject, false);
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadedToServer, themeInfo);
} else {
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
}
}
public void lambda$null$15$MessagesController(Theme.ThemeInfo themeInfo) {
getNotificationCenter().postNotificationName(NotificationCenter.themeUploadError, themeInfo);
}
public void cleanup() {
getContactsController().cleanup();
MediaController.getInstance().cleanup();
getNotificationsController().cleanup();
getSendMessagesHelper().cleanup();
getSecretChatHelper().cleanup();
getLocationController().cleanup();
getMediaDataController().cleanup();
DialogsActivity.dialogsLoaded[this.currentAccount] = false;
this.notificationsPreferences.edit().clear().commit();
this.emojiPreferences.edit().putLong("lastGifLoadTime", 0L).putLong("lastStickersLoadTime", 0L).putLong("lastStickersLoadTimeMask", 0L).putLong("lastStickersLoadTimeFavs", 0L).commit();
this.mainPreferences.edit().remove("archivehint").remove("archivehint_l").remove("gifhint").remove("soundHint").remove("dcDomainName2").remove("webFileDatacenterId").remove("last_contacts_get_diff").remove("contacts_apply_id").remove("contacts_apply_hash").remove("contacts_apply_count").commit();
this.lastScheduledServerQueryTime.clear();
this.reloadingWebpages.clear();
this.reloadingWebpagesPending.clear();
this.reloadingScheduledWebpages.clear();
this.reloadingScheduledWebpagesPending.clear();
this.dialogs_dict.clear();
this.dialogs_read_inbox_max.clear();
this.loadingPinnedDialogs.clear();
this.dialogs_read_outbox_max.clear();
this.exportedChats.clear();
this.fullUsers.clear();
this.fullChats.clear();
this.dialogsByFolder.clear();
this.unreadUnmutedDialogs = 0;
this.joiningToChannels.clear();
this.migratedChats.clear();
this.channelViewsToSend.clear();
this.pollsToCheck.clear();
this.pollsToCheckSize = 0;
this.dialogsServerOnly.clear();
this.dialogsForward.clear();
this.allDialogs.clear();
this.dialogsCanAddUsers.clear();
this.dialogsChannelsOnly.clear();
this.dialogsGroupsOnly.clear();
this.dialogsUnreadOnly.clear();
this.dialogsUsersOnly.clear();
this.dialogMessagesByIds.clear();
this.dialogMessagesByRandomIds.clear();
this.channelAdmins.clear();
this.loadingChannelAdmins.clear();
this.users.clear();
this.objectsByUsernames.clear();
this.chats.clear();
this.dialogMessage.clear();
this.deletedHistory.clear();
this.printingUsers.clear();
this.printingStrings.clear();
this.printingStringsTypes.clear();
this.onlinePrivacy.clear();
this.loadingPeerSettings.clear();
this.deletingDialogs.clear();
this.clearingHistoryDialogs.clear();
this.lastPrintingStringCount = 0;
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$cleanup$17$MessagesController();
}
});
this.createdDialogMainThreadIds.clear();
this.visibleDialogMainThreadIds.clear();
this.visibleScheduledDialogMainThreadIds.clear();
this.blockedUsers.clear();
this.sendingTypings.clear();
this.loadingFullUsers.clear();
this.loadedFullUsers.clear();
this.reloadingMessages.clear();
this.loadingFullChats.clear();
this.loadingFullParticipants.clear();
this.loadedFullParticipants.clear();
this.loadedFullChats.clear();
this.dialogsLoaded = false;
this.nextDialogsCacheOffset.clear();
this.loadingDialogs.clear();
this.dialogsEndReached.clear();
this.serverDialogsEndReached.clear();
this.loadingAppConfig = false;
this.checkingTosUpdate = false;
this.nextTosCheckTime = 0;
this.nextProxyInfoCheckTime = 0;
this.checkingProxyInfo = false;
this.loadingUnreadDialogs = false;
this.currentDeletingTaskTime = 0;
this.currentDeletingTaskMids = null;
this.currentDeletingTaskChannelId = 0;
this.gettingNewDeleteTask = false;
this.loadingBlockedUsers = false;
this.totalBlockedCount = -1;
this.blockedEndReached = false;
this.firstGettingTask = false;
this.updatingState = false;
this.resetingDialogs = false;
this.lastStatusUpdateTime = 0L;
this.offlineSent = false;
this.registeringForPush = false;
this.getDifferenceFirstSync = true;
this.uploadingAvatar = null;
this.uploadingWallpaper = null;
this.uploadingThemes.clear();
this.statusRequest = 0;
this.statusSettingState = 0;
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$cleanup$18$MessagesController();
}
});
if (this.currentDeleteTaskRunnable != null) {
Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
this.currentDeleteTaskRunnable = null;
}
addSupportUser();
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
AppPreferenceUtil.putString("PublishFcBean", "");
FcDBHelper.getInstance().deleteAll(HomeFcListBean.class);
FcDBHelper.getInstance().deleteAll(RecommendFcListBean.class);
FcDBHelper.getInstance().deleteAll(FollowedFcListBean.class);
}
public void lambda$cleanup$17$MessagesController() {
this.readTasks.clear();
this.readTasksMap.clear();
this.updatesQueueSeq.clear();
this.updatesQueuePts.clear();
this.updatesQueueQts.clear();
this.gettingUnknownChannels.clear();
this.gettingUnknownDialogs.clear();
this.updatesStartWaitTimeSeq = 0L;
this.updatesStartWaitTimePts = 0L;
this.updatesStartWaitTimeQts = 0L;
this.createdDialogIds.clear();
this.createdScheduledDialogIds.clear();
this.gettingDifference = false;
this.resetDialogsPinned = null;
this.resetDialogsAll = null;
}
public void lambda$cleanup$18$MessagesController() {
getConnectionsManager().setIsUpdating(false);
this.updatesQueueChannels.clear();
this.updatesStartWaitTimeChannels.clear();
this.gettingDifferenceChannels.clear();
this.channelsPts.clear();
this.shortPollChannels.clear();
this.needShortPollChannels.clear();
this.shortPollOnlines.clear();
this.needShortPollOnlines.clear();
}
public TLRPC.User getUser(Integer num) {
return this.users.get(num);
}
public TLObject getUserOrChat(String str) {
if (str == null || str.length() == 0) {
return null;
}
return this.objectsByUsernames.get(str.toLowerCase());
}
public ConcurrentHashMap<Integer, TLRPC.User> getUsers() {
return this.users;
}
public ConcurrentHashMap<Integer, TLRPC.Chat> getChats() {
return this.chats;
}
public TLRPC.Chat getChat(Integer num) {
return this.chats.get(num);
}
public TLRPC.EncryptedChat getEncryptedChat(Integer num) {
return this.encryptedChats.get(num);
}
public TLRPC.EncryptedChat getEncryptedChatDB(int i, boolean z) {
TLRPC.EncryptedChat encryptedChat = this.encryptedChats.get(Integer.valueOf(i));
if (encryptedChat != null) {
if (!z) {
return encryptedChat;
}
if (!(encryptedChat instanceof TLRPC.TL_encryptedChatWaiting) && !(encryptedChat instanceof TLRPC.TL_encryptedChatRequested)) {
return encryptedChat;
}
}
CountDownLatch countDownLatch = new CountDownLatch(1);
ArrayList<TLObject> arrayList = new ArrayList<>();
getMessagesStorage().getEncryptedChat(i, countDownLatch, arrayList);
try {
countDownLatch.await();
} catch (Exception e) {
FileLog.e(e);
}
if (arrayList.size() != 2) {
return encryptedChat;
}
TLRPC.EncryptedChat encryptedChat2 = (TLRPC.EncryptedChat) arrayList.get(0);
TLRPC.User user = (TLRPC.User) arrayList.get(1);
putEncryptedChat(encryptedChat2, false);
putUser(user, true);
return encryptedChat2;
}
public boolean isDialogVisible(long j, boolean z) {
return (z ? this.visibleScheduledDialogMainThreadIds : this.visibleDialogMainThreadIds).contains(Long.valueOf(j));
}
public void setLastVisibleDialogId(long j, boolean z, boolean z2) {
ArrayList<Long> arrayList = z ? this.visibleScheduledDialogMainThreadIds : this.visibleDialogMainThreadIds;
if (z2) {
if (arrayList.contains(Long.valueOf(j))) {
return;
}
arrayList.add(Long.valueOf(j));
return;
}
arrayList.remove(Long.valueOf(j));
}
public void setLastCreatedDialogId(final long j, final boolean z, final boolean z2) {
if (!z) {
ArrayList<Long> arrayList = this.createdDialogMainThreadIds;
if (z2) {
if (arrayList.contains(Long.valueOf(j))) {
return;
} else {
arrayList.add(Long.valueOf(j));
}
} else {
arrayList.remove(Long.valueOf(j));
SparseArray<MessageObject> sparseArray = this.pollsToCheck.get(j);
if (sparseArray != null) {
int size = sparseArray.size();
for (int i = 0; i < size; i++) {
sparseArray.valueAt(i).pollVisibleOnScreen = false;
}
}
}
}
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$setLastCreatedDialogId$19$MessagesController(z, z2, j);
}
});
}
public void lambda$setLastCreatedDialogId$19$MessagesController(boolean z, boolean z2, long j) {
ArrayList<Long> arrayList = z ? this.createdScheduledDialogIds : this.createdDialogIds;
if (z2) {
if (arrayList.contains(Long.valueOf(j))) {
return;
}
arrayList.add(Long.valueOf(j));
return;
}
arrayList.remove(Long.valueOf(j));
}
public TLRPC.ExportedChatInvite getExportedInvite(int i) {
return this.exportedChats.get(i);
}
public boolean putUser(TLRPC.User user, boolean z) {
if (user == null) {
return false;
}
boolean z2 = (!z || user.id / 1000 == 333 || user.id == 777000) ? false : true;
TLRPC.User user2 = this.users.get(Integer.valueOf(user.id));
if (user2 == user) {
return false;
}
if (user2 != null && !TextUtils.isEmpty(user2.username)) {
this.objectsByUsernames.remove(user2.username.toLowerCase());
}
if (!TextUtils.isEmpty(user.username)) {
this.objectsByUsernames.put(user.username.toLowerCase(), user);
}
if (user.min) {
if (user2 == null) {
this.users.put(Integer.valueOf(user.id), user);
} else if (!z2) {
if (user.bot) {
if (user.username != null) {
user2.username = user.username;
user2.flags |= 8;
} else {
user2.flags &= -9;
user2.username = null;
}
}
if (user.photo != null) {
user2.photo = user.photo;
user2.flags |= 32;
} else {
user2.flags &= -33;
user2.photo = null;
}
}
} else if (!z2) {
this.users.put(Integer.valueOf(user.id), user);
if (user.id == getUserConfig().getClientUserId()) {
getUserConfig().setCurrentUser(user);
getUserConfig().saveConfig(true);
}
if (user2 != null && user.status != null && user2.status != null && user.status.expires != user2.status.expires) {
return true;
}
} else if (user2 == null) {
this.users.put(Integer.valueOf(user.id), user);
} else if (user2.min) {
user.min = false;
if (user2.bot) {
if (user2.username != null) {
user.username = user2.username;
user.flags |= 8;
} else {
user.flags &= -9;
user.username = null;
}
}
if (user2.photo != null) {
user.photo = user2.photo;
user.flags |= 32;
} else {
user.flags &= -33;
user.photo = null;
}
this.users.put(Integer.valueOf(user.id), user);
}
return false;
}
public void putUsers(ArrayList<TLRPC.User> arrayList, boolean z) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
int size = arrayList.size();
boolean z2 = false;
for (int i = 0; i < size; i++) {
if (putUser(arrayList.get(i), z)) {
z2 = true;
}
}
if (z2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$putUsers$20$MessagesController();
}
});
}
}
public void lambda$putUsers$20$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
}
public void putChat(final TLRPC.Chat chat, boolean z) {
TLRPC.Chat chat2;
if (chat == null || (chat2 = this.chats.get(Integer.valueOf(chat.id))) == chat) {
return;
}
if (chat2 != null && !TextUtils.isEmpty(chat2.username)) {
this.objectsByUsernames.remove(chat2.username.toLowerCase());
}
if (!TextUtils.isEmpty(chat.username)) {
this.objectsByUsernames.put(chat.username.toLowerCase(), chat);
}
if (chat.min) {
if (chat2 == null) {
this.chats.put(Integer.valueOf(chat.id), chat);
return;
}
if (z) {
return;
}
chat2.title = chat.title;
chat2.photo = chat.photo;
chat2.broadcast = chat.broadcast;
chat2.verified = chat.verified;
chat2.megagroup = chat.megagroup;
if (chat.default_banned_rights != null) {
chat2.default_banned_rights = chat.default_banned_rights;
chat2.flags |= 262144;
}
if (chat.admin_rights != null) {
chat2.admin_rights = chat.admin_rights;
chat2.flags |= 16384;
}
if (chat.banned_rights != null) {
chat2.banned_rights = chat.banned_rights;
chat2.flags |= 32768;
}
if (chat.username != null) {
chat2.username = chat.username;
chat2.flags |= 64;
} else {
chat2.flags &= -65;
chat2.username = null;
}
if (chat.participants_count != 0) {
chat2.participants_count = chat.participants_count;
return;
}
return;
}
if (!z) {
if (chat2 != null) {
if (chat.version != chat2.version) {
this.loadedFullChats.remove(Integer.valueOf(chat.id));
}
if (chat2.participants_count != 0 && chat.participants_count == 0) {
chat.participants_count = chat2.participants_count;
chat.flags |= 131072;
}
int i = chat2.banned_rights != null ? chat2.banned_rights.flags : 0;
int i2 = chat.banned_rights != null ? chat.banned_rights.flags : 0;
int i3 = chat2.default_banned_rights != null ? chat2.default_banned_rights.flags : 0;
int i4 = chat.default_banned_rights != null ? chat.default_banned_rights.flags : 0;
chat2.default_banned_rights = chat.default_banned_rights;
if (chat2.default_banned_rights == null) {
chat2.flags &= -262145;
} else {
chat2.flags = 262144 | chat2.flags;
}
chat2.banned_rights = chat.banned_rights;
if (chat2.banned_rights == null) {
chat2.flags &= -32769;
} else {
chat2.flags = 32768 | chat2.flags;
}
chat2.admin_rights = chat.admin_rights;
if (chat2.admin_rights == null) {
chat2.flags &= -16385;
} else {
chat2.flags |= 16384;
}
if (i != i2 || i3 != i4) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$putChat$21$MessagesController(chat);
}
});
}
}
this.chats.put(Integer.valueOf(chat.id), chat);
return;
}
if (chat2 == null) {
this.chats.put(Integer.valueOf(chat.id), chat);
return;
}
if (chat2.min) {
chat.min = false;
chat.title = chat2.title;
chat.photo = chat2.photo;
chat.broadcast = chat2.broadcast;
chat.verified = chat2.verified;
chat.megagroup = chat2.megagroup;
if (chat2.default_banned_rights != null) {
chat.default_banned_rights = chat2.default_banned_rights;
chat.flags |= 262144;
}
if (chat2.admin_rights != null) {
chat.admin_rights = chat2.admin_rights;
chat.flags |= 16384;
}
if (chat2.banned_rights != null) {
chat.banned_rights = chat2.banned_rights;
chat.flags |= 32768;
}
if (chat2.username != null) {
chat.username = chat2.username;
chat.flags |= 64;
} else {
chat.flags &= -65;
chat.username = null;
}
if (chat2.participants_count != 0 && chat.participants_count == 0) {
chat.participants_count = chat2.participants_count;
chat.flags |= 131072;
}
this.chats.put(Integer.valueOf(chat.id), chat);
}
}
public void lambda$putChat$21$MessagesController(TLRPC.Chat chat) {
getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat);
}
public void putChats(ArrayList<TLRPC.Chat> arrayList, boolean z) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
int size = arrayList.size();
for (int i = 0; i < size; i++) {
putChat(arrayList.get(i), z);
}
}
public void setReferer(String str) {
if (str == null) {
return;
}
this.installReferer = str;
this.mainPreferences.edit().putString("installReferer", str).commit();
}
public void putEncryptedChat(TLRPC.EncryptedChat encryptedChat, boolean z) {
if (encryptedChat == null) {
return;
}
if (z) {
this.encryptedChats.putIfAbsent(Integer.valueOf(encryptedChat.id), encryptedChat);
} else {
this.encryptedChats.put(Integer.valueOf(encryptedChat.id), encryptedChat);
}
}
public void putEncryptedChats(ArrayList<TLRPC.EncryptedChat> arrayList, boolean z) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
int size = arrayList.size();
for (int i = 0; i < size; i++) {
putEncryptedChat(arrayList.get(i), z);
}
}
public TLRPC.UserFull getUserFull(int i) {
return this.fullUsers.get(i);
}
public TLRPC.ChatFull getChatFull(int i) {
return this.fullChats.get(i);
}
public void cancelLoadFullUser(int i) {
this.loadingFullUsers.remove(Integer.valueOf(i));
}
public void cancelLoadFullChat(int i) {
this.loadingFullChats.remove(Integer.valueOf(i));
}
public void clearFullUsers() {
this.loadedFullUsers.clear();
this.loadedFullChats.clear();
}
private void reloadDialogsReadValue(ArrayList<TLRPC.Dialog> arrayList, long j) {
if (j == 0 && (arrayList == null || arrayList.isEmpty())) {
return;
}
TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
if (arrayList != null) {
for (int i = 0; i < arrayList.size(); i++) {
TLRPC.InputPeer inputPeer = getInputPeer((int) arrayList.get(i).id);
if (!(inputPeer instanceof TLRPC.TL_inputPeerChannel) || inputPeer.access_hash != 0) {
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer;
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
}
}
} else {
TLRPC.InputPeer inputPeer2 = getInputPeer((int) j);
if ((inputPeer2 instanceof TLRPC.TL_inputPeerChannel) && inputPeer2.access_hash == 0) {
return;
}
TLRPC.TL_inputDialogPeer tL_inputDialogPeer2 = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer2.peer = inputPeer2;
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer2);
}
if (tL_messages_getPeerDialogs.peers.isEmpty()) {
return;
}
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$reloadDialogsReadValue$22$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$reloadDialogsReadValue$22$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
ArrayList<TLRPC.Update> arrayList = new ArrayList<>();
for (int i = 0; i < tL_messages_peerDialogs.dialogs.size(); i++) {
TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(i);
if (dialog.read_inbox_max_id == 0) {
dialog.read_inbox_max_id = 1;
}
if (dialog.read_outbox_max_id == 0) {
dialog.read_outbox_max_id = 1;
}
DialogObject.initDialog(dialog);
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
num = 0;
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(dialog.read_inbox_max_id, num.intValue())));
if (num.intValue() == 0) {
if (dialog.peer.channel_id != 0) {
TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = new TLRPC.TL_updateReadChannelInbox();
tL_updateReadChannelInbox.channel_id = dialog.peer.channel_id;
tL_updateReadChannelInbox.max_id = dialog.read_inbox_max_id;
arrayList.add(tL_updateReadChannelInbox);
} else {
TLRPC.TL_updateReadHistoryInbox tL_updateReadHistoryInbox = new TLRPC.TL_updateReadHistoryInbox();
tL_updateReadHistoryInbox.peer = dialog.peer;
tL_updateReadHistoryInbox.max_id = dialog.read_inbox_max_id;
arrayList.add(tL_updateReadHistoryInbox);
}
}
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
num2 = 0;
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(dialog.read_outbox_max_id, num2.intValue())));
if (num2.intValue() == 0) {
if (dialog.peer.channel_id != 0) {
TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = new TLRPC.TL_updateReadChannelOutbox();
tL_updateReadChannelOutbox.channel_id = dialog.peer.channel_id;
tL_updateReadChannelOutbox.max_id = dialog.read_outbox_max_id;
arrayList.add(tL_updateReadChannelOutbox);
} else {
TLRPC.TL_updateReadHistoryOutbox tL_updateReadHistoryOutbox = new TLRPC.TL_updateReadHistoryOutbox();
tL_updateReadHistoryOutbox.peer = dialog.peer;
tL_updateReadHistoryOutbox.max_id = dialog.read_outbox_max_id;
arrayList.add(tL_updateReadHistoryOutbox);
}
}
}
if (arrayList.isEmpty()) {
return;
}
processUpdateArray(arrayList, null, null, false, 0);
}
}
public String getAdminRank(int i, int i2) {
SparseArray<String> sparseArray = this.channelAdmins.get(i);
if (sparseArray == null) {
return null;
}
return sparseArray.get(i2);
}
public boolean isChannelAdminsLoaded(int i) {
return this.channelAdmins.get(i) != null;
}
public void loadChannelAdmins(final int i, boolean z) {
if (SystemClock.uptimeMillis() - this.loadingChannelAdmins.get(i) < 60) {
return;
}
this.loadingChannelAdmins.put(i, (int) (SystemClock.uptimeMillis() / 1000));
if (z) {
getMessagesStorage().loadChannelAdmins(i);
return;
}
TLRPC.TL_channels_getParticipants tL_channels_getParticipants = new TLRPC.TL_channels_getParticipants();
tL_channels_getParticipants.channel = getInputChannel(i);
tL_channels_getParticipants.limit = 100;
tL_channels_getParticipants.filter = new TLRPC.TL_channelParticipantsAdmins();
getConnectionsManager().sendRequest(tL_channels_getParticipants, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadChannelAdmins$23$MessagesController(i, tLObject, tL_error);
}
});
}
public void lambda$loadChannelAdmins$23$MessagesController(int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_channels_channelParticipants) {
processLoadedAdminsResponse(i, (TLRPC.TL_channels_channelParticipants) tLObject);
}
}
public void processLoadedAdminsResponse(int i, TLRPC.TL_channels_channelParticipants tL_channels_channelParticipants) {
SparseArray<String> sparseArray = new SparseArray<>(tL_channels_channelParticipants.participants.size());
for (int i2 = 0; i2 < tL_channels_channelParticipants.participants.size(); i2++) {
TLRPC.ChannelParticipant channelParticipant = tL_channels_channelParticipants.participants.get(i2);
sparseArray.put(channelParticipant.user_id, channelParticipant.rank != null ? channelParticipant.rank : "");
}
processLoadedChannelAdmins(sparseArray, i, false);
}
public void processLoadedChannelAdmins(final SparseArray<String> sparseArray, final int i, final boolean z) {
if (!z) {
getMessagesStorage().putChannelAdmins(i, sparseArray);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processLoadedChannelAdmins$24$MessagesController(i, sparseArray, z);
}
});
}
public void lambda$processLoadedChannelAdmins$24$MessagesController(int i, SparseArray sparseArray, boolean z) {
this.channelAdmins.put(i, sparseArray);
if (z) {
this.loadingChannelAdmins.delete(i);
loadChannelAdmins(i, false);
}
}
public void loadUsers(int[] iArr, long[] jArr, int i) {
if (iArr == null || jArr == null || iArr.length != jArr.length) {
return;
}
ArrayList<Integer> arrayList = new ArrayList<>();
if (this.users != null) {
for (int i2 : iArr) {
TLRPC.User user = this.users.get(Integer.valueOf(i2));
if (user != null) {
getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, Integer.valueOf(user.id), user);
} else {
arrayList.add(Integer.valueOf(i2));
}
}
if (arrayList.size() > 0) {
loadUsers(arrayList, jArr, i);
}
}
}
public void loadUsers(ArrayList<Integer> arrayList, long[] jArr, int i) {
if (arrayList == null || jArr == null || arrayList.size() != jArr.length) {
return;
}
ArrayList<TLRPC.InputUser> arrayList2 = new ArrayList<>();
for (int i2 = 0; i2 < arrayList.size(); i2++) {
TLRPC.TL_inputUser tL_inputUser = new TLRPC.TL_inputUser();
tL_inputUser.user_id = arrayList.get(i2).intValue();
tL_inputUser.access_hash = jArr[i2];
arrayList2.add(tL_inputUser);
}
loadUsers(arrayList2, i);
}
public void loadUsers(ArrayList<TLRPC.InputUser> arrayList, int i) {
if (arrayList == null) {
return;
}
TLRPC.TL_users_getUsers tL_users_getUsers = new TLRPC.TL_users_getUsers();
tL_users_getUsers.id.addAll(arrayList);
getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_users_getUsers, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUsers$26$MessagesController(tLObject, tL_error);
}
}), i);
}
public void lambda$loadUsers$26$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.Vector) {
TLRPC.Vector vector = (TLRPC.Vector) tLObject;
if (vector.objects.isEmpty()) {
return;
}
for (int i = 0; i < vector.objects.size(); i++) {
ArrayList<TLRPC.User> arrayList = new ArrayList<>();
final TLRPC.User user = (TLRPC.User) vector.objects.get(i);
arrayList.add(user);
getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$25$MessagesController(user);
}
});
}
}
}
public void lambda$null$25$MessagesController(TLRPC.User user) {
putUser(user, false);
getNotificationCenter().postNotificationName(NotificationCenter.userInfoDidLoad, Integer.valueOf(user.id), user);
}
public void loadFullChat(final int i, final int i2, boolean z) {
TLRPC.TL_messages_getFullChat tL_messages_getFullChat;
boolean contains = this.loadedFullChats.contains(Integer.valueOf(i));
if (this.loadingFullChats.contains(Integer.valueOf(i))) {
return;
}
if (z || !contains) {
this.loadingFullChats.add(Integer.valueOf(i));
final long j = -i;
final TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (ChatObject.isChannel(chat)) {
TLRPC.TL_channels_getFullChannel tL_channels_getFullChannel = new TLRPC.TL_channels_getFullChannel();
tL_channels_getFullChannel.channel = getInputChannel(chat);
tL_messages_getFullChat = tL_channels_getFullChannel;
if (chat.megagroup) {
loadChannelAdmins(i, !contains);
tL_messages_getFullChat = tL_channels_getFullChannel;
}
} else {
TLRPC.TL_messages_getFullChat tL_messages_getFullChat2 = new TLRPC.TL_messages_getFullChat();
tL_messages_getFullChat2.chat_id = i;
if (this.dialogs_read_inbox_max.get(Long.valueOf(j)) != null) {
tL_messages_getFullChat = tL_messages_getFullChat2;
}
reloadDialogsReadValue(null, j);
tL_messages_getFullChat = tL_messages_getFullChat2;
}
int sendRequest = getConnectionsManager().sendRequest(tL_messages_getFullChat, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadFullChat$29$MessagesController(chat, j, i, i2, tLObject, tL_error);
}
});
if (i2 != 0) {
getConnectionsManager().bindRequestToGuid(sendRequest, i2);
}
}
}
public void lambda$loadFullChat$29$MessagesController(TLRPC.Chat chat, long j, final int i, final int i2, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
final TLRPC.TL_messages_chatFull tL_messages_chatFull = (TLRPC.TL_messages_chatFull) tLObject;
getMessagesStorage().putUsersAndChats(tL_messages_chatFull.users, tL_messages_chatFull.chats, true, true);
getMessagesStorage().updateChatInfo(tL_messages_chatFull.full_chat, false);
if (ChatObject.isChannel(chat)) {
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j));
}
this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(tL_messages_chatFull.full_chat.read_inbox_max_id, num.intValue())));
if (num.intValue() == 0) {
ArrayList<TLRPC.Update> arrayList = new ArrayList<>();
TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = new TLRPC.TL_updateReadChannelInbox();
tL_updateReadChannelInbox.channel_id = i;
tL_updateReadChannelInbox.max_id = tL_messages_chatFull.full_chat.read_inbox_max_id;
arrayList.add(tL_updateReadChannelInbox);
processUpdateArray(arrayList, null, null, false, 0);
}
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j));
if (num2 == null) {
num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j));
}
this.dialogs_read_outbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(tL_messages_chatFull.full_chat.read_outbox_max_id, num2.intValue())));
if (num2.intValue() == 0) {
ArrayList<TLRPC.Update> arrayList2 = new ArrayList<>();
TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = new TLRPC.TL_updateReadChannelOutbox();
tL_updateReadChannelOutbox.channel_id = i;
tL_updateReadChannelOutbox.max_id = tL_messages_chatFull.full_chat.read_outbox_max_id;
arrayList2.add(tL_updateReadChannelOutbox);
processUpdateArray(arrayList2, null, null, false, 0);
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$27$MessagesController(i, tL_messages_chatFull, i2);
}
});
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$28$MessagesController(tL_error, i);
}
});
}
public void lambda$null$27$MessagesController(int i, TLRPC.TL_messages_chatFull tL_messages_chatFull, int i2) {
this.fullChats.put(i, tL_messages_chatFull.full_chat);
applyDialogNotificationsSettings(-i, tL_messages_chatFull.full_chat.notify_settings);
for (int i3 = 0; i3 < tL_messages_chatFull.full_chat.bot_info.size(); i3++) {
getMediaDataController().putBotInfo(tL_messages_chatFull.full_chat.bot_info.get(i3));
}
this.exportedChats.put(i, tL_messages_chatFull.full_chat.exported_invite);
this.loadingFullChats.remove(Integer.valueOf(i));
this.loadedFullChats.add(Integer.valueOf(i));
putUsers(tL_messages_chatFull.users, false);
putChats(tL_messages_chatFull.chats, false);
if (tL_messages_chatFull.full_chat.stickerset != null) {
getMediaDataController().getGroupStickerSetById(tL_messages_chatFull.full_chat.stickerset);
}
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, tL_messages_chatFull.full_chat, Integer.valueOf(i2), false, null);
}
public void lambda$null$28$MessagesController(TLRPC.TL_error tL_error, int i) {
checkChannelError(tL_error.text, i);
this.loadingFullChats.remove(Integer.valueOf(i));
}
public void loadFullUser(TLRPC.User user, int i, boolean z) {
loadFullUser(user, 0, i, z);
}
public void loadFullUser(int i, int i2, boolean z) {
loadFullUser(null, i, i2, z);
}
public void loadFullUser(final TLRPC.User user, int i, final int i2, boolean z) {
if (user == null || this.loadingFullUsers.contains(Integer.valueOf(user.id)) || (!z && this.loadedFullUsers.contains(Integer.valueOf(user.id)))) {
if (i == 0 || this.loadingFullUsers.contains(Integer.valueOf(i))) {
return;
}
if (!z && this.loadedFullUsers.contains(Integer.valueOf(i))) {
return;
}
}
final int i3 = user != null ? user.id : i;
this.loadingFullUsers.add(Integer.valueOf(i3));
TLRPCContacts.CL_user_getFulluser cL_user_getFulluser = new TLRPCContacts.CL_user_getFulluser();
cL_user_getFulluser.inputUser = user != null ? getInputUser(user) : getInputUser(i);
long j = i3;
if (this.dialogs_read_inbox_max.get(Long.valueOf(j)) == null || this.dialogs_read_outbox_max.get(Long.valueOf(j)) == null) {
reloadDialogsReadValue(null, j);
}
getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(cL_user_getFulluser, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadFullUser$32$MessagesController(i3, user, i2, tLObject, tL_error);
}
}), i2);
}
public void lambda$loadFullUser$32$MessagesController(final int i, final TLRPC.User user, final int i2, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
final TLRPC.UserFull userFull = (TLRPC.UserFull) tLObject;
getMessagesStorage().updateUserInfo(userFull, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$30$MessagesController(userFull, i, user, i2);
}
});
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$31$MessagesController(i);
}
});
}
public void lambda$null$30$MessagesController(TLRPC.UserFull userFull, int i, TLRPC.User user, int i2) {
String str;
savePeerSettings(userFull.user.id, userFull.settings, false);
applyDialogNotificationsSettings(i, userFull.notify_settings);
if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
getMediaDataController().putBotInfo(userFull.bot_info);
}
int indexOfKey = this.blockedUsers.indexOfKey(i);
if (userFull.blocked) {
if (indexOfKey < 0) {
this.blockedUsers.put(i, 1);
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
}
} else if (indexOfKey >= 0) {
this.blockedUsers.removeAt(indexOfKey);
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
}
this.fullUsers.put(i, userFull);
this.loadingFullUsers.remove(Integer.valueOf(i));
this.loadedFullUsers.add(Integer.valueOf(i));
if (user != null) {
str = user.first_name + user.last_name + user.username;
} else {
str = null;
}
ArrayList<TLRPC.User> arrayList = new ArrayList<>();
arrayList.add(userFull.user);
putUsers(arrayList, false);
getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
if (str != null) {
if (!str.equals(userFull.user.first_name + userFull.user.last_name + userFull.user.username)) {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 1);
}
}
if (userFull.bot_info instanceof TLRPC.TL_botInfo) {
getNotificationCenter().postNotificationName(NotificationCenter.botInfoDidLoad, userFull.bot_info, Integer.valueOf(i2));
}
getNotificationCenter().postNotificationName(NotificationCenter.userFullInfoDidLoad, Integer.valueOf(i), userFull, null);
}
public void lambda$null$31$MessagesController(int i) {
this.loadingFullUsers.remove(Integer.valueOf(i));
}
private void reloadMessages(ArrayList<Integer> arrayList, final long j, final boolean z) {
TLRPC.TL_messages_getMessages tL_messages_getMessages;
if (arrayList.isEmpty()) {
return;
}
final ArrayList<Integer> arrayList2 = new ArrayList<>();
final TLRPC.Chat chatByDialog = ChatObject.getChatByDialog(j, this.currentAccount);
if (ChatObject.isChannel(chatByDialog)) {
TLRPC.TL_channels_getMessages tL_channels_getMessages = new TLRPC.TL_channels_getMessages();
tL_channels_getMessages.channel = getInputChannel(chatByDialog);
tL_channels_getMessages.id = arrayList2;
tL_messages_getMessages = tL_channels_getMessages;
} else {
TLRPC.TL_messages_getMessages tL_messages_getMessages2 = new TLRPC.TL_messages_getMessages();
tL_messages_getMessages2.id = arrayList2;
tL_messages_getMessages = tL_messages_getMessages2;
}
ArrayList<Integer> arrayList3 = this.reloadingMessages.get(j);
for (int i = 0; i < arrayList.size(); i++) {
Integer num = arrayList.get(i);
if (arrayList3 == null || !arrayList3.contains(num)) {
arrayList2.add(num);
}
}
if (arrayList2.isEmpty()) {
return;
}
if (arrayList3 == null) {
arrayList3 = new ArrayList<>();
this.reloadingMessages.put(j, arrayList3);
}
arrayList3.addAll(arrayList2);
getConnectionsManager().sendRequest(tL_messages_getMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$reloadMessages$34$MessagesController(j, chatByDialog, z, arrayList2, tLObject, tL_error);
}
});
}
public void lambda$reloadMessages$34$MessagesController(final long j, TLRPC.Chat chat, boolean z, final ArrayList arrayList, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
SparseArray sparseArray = new SparseArray();
for (int i = 0; i < messages_messages.users.size(); i++) {
TLRPC.User user = messages_messages.users.get(i);
sparseArray.put(user.id, user);
}
SparseArray sparseArray2 = new SparseArray();
for (int i2 = 0; i2 < messages_messages.chats.size(); i2++) {
TLRPC.Chat chat2 = messages_messages.chats.get(i2);
sparseArray2.put(chat2.id, chat2);
}
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j));
this.dialogs_read_inbox_max.put(Long.valueOf(j), num);
}
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j));
if (num2 == null) {
num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j));
this.dialogs_read_outbox_max.put(Long.valueOf(j), num2);
}
Integer num3 = num2;
ArrayList arrayList2 = new ArrayList();
int i3 = 0;
while (i3 < messages_messages.messages.size()) {
TLRPC.Message message = messages_messages.messages.get(i3);
if (chat != null && chat.megagroup) {
message.flags |= Integer.MIN_VALUE;
}
message.dialog_id = j;
if (!z) {
message.unread = (message.out ? num3 : num).intValue() < message.id;
}
ArrayList arrayList3 = arrayList2;
arrayList3.add(new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, true));
i3++;
arrayList2 = arrayList3;
}
final ArrayList arrayList4 = arrayList2;
ImageLoader.saveMessagesThumbs(messages_messages.messages);
getMessagesStorage().putMessages(messages_messages, j, -1, 0, false, z);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$33$MessagesController(j, arrayList, arrayList4);
}
});
}
}
public void lambda$null$33$MessagesController(long j, ArrayList arrayList, ArrayList arrayList2) {
ArrayList<Integer> arrayList3 = this.reloadingMessages.get(j);
if (arrayList3 != null) {
arrayList3.removeAll(arrayList);
if (arrayList3.isEmpty()) {
this.reloadingMessages.remove(j);
}
}
MessageObject messageObject = this.dialogMessage.get(j);
if (messageObject != null) {
int i = 0;
while (true) {
if (i >= arrayList2.size()) {
break;
}
MessageObject messageObject2 = (MessageObject) arrayList2.get(i);
if (messageObject == null || messageObject.getId() != messageObject2.getId()) {
i++;
} else {
this.dialogMessage.put(j, messageObject2);
if (messageObject2.messageOwner.to_id.channel_id == 0) {
MessageObject messageObject3 = this.dialogMessagesByIds.get(messageObject2.getId());
this.dialogMessagesByIds.remove(messageObject2.getId());
if (messageObject3 != null) {
this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
}
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
}
}
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList2);
}
public void hidePeerSettingsBar(long j, TLRPC.User user, TLRPC.Chat chat) {
if (user == null && chat == null) {
return;
}
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
edit.putInt("dialog_bar_vis3" + j, 3);
edit.commit();
if (((int) j) != 0) {
TLRPC.TL_messages_hidePeerSettingsBar tL_messages_hidePeerSettingsBar = new TLRPC.TL_messages_hidePeerSettingsBar();
if (user != null) {
tL_messages_hidePeerSettingsBar.peer = getInputPeer(user.id);
} else if (chat != null) {
tL_messages_hidePeerSettingsBar.peer = getInputPeer(-chat.id);
}
getConnectionsManager().sendRequest(tL_messages_hidePeerSettingsBar, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$hidePeerSettingsBar$35(tLObject, tL_error);
}
});
}
}
public void reportSpam(long j, TLRPC.User user, TLRPC.Chat chat, TLRPC.EncryptedChat encryptedChat, boolean z) {
if (user == null && chat == null && encryptedChat == null) {
return;
}
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
edit.putInt("dialog_bar_vis3" + j, 3);
edit.commit();
if (((int) j) != 0) {
TLRPC.TL_account_reportPeer tL_account_reportPeer = new TLRPC.TL_account_reportPeer();
if (chat != null) {
tL_account_reportPeer.peer = getInputPeer(-chat.id);
} else if (user != null) {
tL_account_reportPeer.peer = getInputPeer(user.id);
}
if (z) {
tL_account_reportPeer.reason = new TLRPC.TL_inputReportReasonGeoIrrelevant();
} else {
tL_account_reportPeer.reason = new TLRPC.TL_inputReportReasonSpam();
}
getConnectionsManager().sendRequest(tL_account_reportPeer, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$reportSpam$37(tLObject, tL_error);
}
}, 2);
return;
}
if (encryptedChat == null || encryptedChat.access_hash == 0) {
return;
}
TLRPC.TL_messages_reportEncryptedSpam tL_messages_reportEncryptedSpam = new TLRPC.TL_messages_reportEncryptedSpam();
tL_messages_reportEncryptedSpam.peer = new TLRPC.TL_inputEncryptedChat();
tL_messages_reportEncryptedSpam.peer.chat_id = encryptedChat.id;
tL_messages_reportEncryptedSpam.peer.access_hash = encryptedChat.access_hash;
getConnectionsManager().sendRequest(tL_messages_reportEncryptedSpam, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$reportSpam$36(tLObject, tL_error);
}
}, 2);
}
private void savePeerSettings(long j, TLRPC.TL_peerSettings tL_peerSettings, boolean z) {
if (tL_peerSettings != null) {
if (this.notificationsPreferences.getInt("dialog_bar_vis3" + j, 0) == 3) {
return;
}
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
edit.putInt("dialog_bar_vis3" + j, (tL_peerSettings.report_spam || tL_peerSettings.add_contact || tL_peerSettings.block_contact || tL_peerSettings.share_contact || tL_peerSettings.report_geo) ? false : true ? 1 : 2);
edit.putBoolean("dialog_bar_share" + j, tL_peerSettings.share_contact);
edit.putBoolean("dialog_bar_report" + j, tL_peerSettings.report_spam);
edit.putBoolean("dialog_bar_add" + j, tL_peerSettings.add_contact);
edit.putBoolean("dialog_bar_block" + j, tL_peerSettings.block_contact);
edit.putBoolean("dialog_bar_exception" + j, tL_peerSettings.need_contacts_exception);
edit.putBoolean("dialog_bar_location" + j, tL_peerSettings.report_geo);
edit.commit();
getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, Long.valueOf(j));
}
}
public void loadPeerSettings(TLRPC.User user, TLRPC.Chat chat) {
int i;
if (user == null && chat == null) {
return;
}
if (user != null) {
i = user.id;
} else {
i = -chat.id;
}
final long j = i;
if (this.loadingPeerSettings.indexOfKey(j) >= 0) {
return;
}
this.loadingPeerSettings.put(j, true);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("request spam button for " + j);
}
int i2 = this.notificationsPreferences.getInt("dialog_bar_vis3" + j, 0);
if (i2 == 1 || i2 == 3) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("dialog bar already hidden for " + j);
return;
}
return;
}
TLRPC.TL_messages_getPeerSettings tL_messages_getPeerSettings = new TLRPC.TL_messages_getPeerSettings();
if (user != null) {
tL_messages_getPeerSettings.peer = getInputPeer(user.id);
} else if (chat != null) {
tL_messages_getPeerSettings.peer = getInputPeer(-chat.id);
}
getConnectionsManager().sendRequest(tL_messages_getPeerSettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadPeerSettings$39$MessagesController(j, tLObject, tL_error);
}
});
}
public void lambda$loadPeerSettings$39$MessagesController(final long j, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$38$MessagesController(j, tLObject);
}
});
}
public void lambda$null$38$MessagesController(long j, TLObject tLObject) {
this.loadingPeerSettings.remove(j);
if (tLObject != null) {
savePeerSettings(j, (TLRPC.TL_peerSettings) tLObject, false);
}
}
public void processNewChannelDifferenceParams(int i, int i2, int i3) {
int i4 = this.channelsPts.get(i3);
if (i4 == 0) {
i4 = getMessagesStorage().getChannelPtsSync(i3);
if (i4 == 0) {
i4 = 1;
}
this.channelsPts.put(i3, i4);
}
if (i4 + i2 == i) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("APPLY CHANNEL PTS");
}
this.channelsPts.put(i3, i);
getMessagesStorage().saveChannelPts(i3, i);
return;
}
if (i4 != i) {
long j = this.updatesStartWaitTimeChannels.get(i3);
if (this.gettingDifferenceChannels.get(i3) || j == 0 || Math.abs(System.currentTimeMillis() - j) <= 1500) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("ADD CHANNEL UPDATE TO QUEUE pts = " + i + " pts_count = " + i2);
}
if (j == 0) {
this.updatesStartWaitTimeChannels.put(i3, System.currentTimeMillis());
}
UserActionUpdatesPts userActionUpdatesPts = new UserActionUpdatesPts();
userActionUpdatesPts.pts = i;
userActionUpdatesPts.pts_count = i2;
userActionUpdatesPts.chat_id = i3;
ArrayList<TLRPC.Updates> arrayList = this.updatesQueueChannels.get(i3);
if (arrayList == null) {
arrayList = new ArrayList<>();
this.updatesQueueChannels.put(i3, arrayList);
}
arrayList.add(userActionUpdatesPts);
return;
}
getChannelDifference(i3);
}
}
public void processNewDifferenceParams(int i, int i2, int i3, int i4) {
if (i2 != -1) {
if (getMessagesStorage().getLastPtsValue() + i4 == i2) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("APPLY PTS");
}
getMessagesStorage().setLastPtsValue(i2);
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
} else if (getMessagesStorage().getLastPtsValue() != i2) {
if (this.gettingDifference || this.updatesStartWaitTimePts == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimePts) <= 1500) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("ADD UPDATE TO QUEUE pts = " + i2 + " pts_count = " + i4);
}
if (this.updatesStartWaitTimePts == 0) {
this.updatesStartWaitTimePts = System.currentTimeMillis();
}
UserActionUpdatesPts userActionUpdatesPts = new UserActionUpdatesPts();
userActionUpdatesPts.pts = i2;
userActionUpdatesPts.pts_count = i4;
this.updatesQueuePts.add(userActionUpdatesPts);
} else {
getDifference();
}
}
}
if (i != -1) {
if (getMessagesStorage().getLastSeqValue() + 1 == i) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("APPLY SEQ");
}
getMessagesStorage().setLastSeqValue(i);
if (i3 != -1) {
getMessagesStorage().setLastDateValue(i3);
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
return;
}
if (getMessagesStorage().getLastSeqValue() != i) {
if (this.gettingDifference || this.updatesStartWaitTimeSeq == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimeSeq) <= 1500) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("ADD UPDATE TO QUEUE seq = " + i);
}
if (this.updatesStartWaitTimeSeq == 0) {
this.updatesStartWaitTimeSeq = System.currentTimeMillis();
}
UserActionUpdatesSeq userActionUpdatesSeq = new UserActionUpdatesSeq();
userActionUpdatesSeq.seq = i;
this.updatesQueueSeq.add(userActionUpdatesSeq);
return;
}
getDifference();
}
}
}
public void didAddedNewTask(final int i, final SparseArray<ArrayList<Long>> sparseArray) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$didAddedNewTask$40$MessagesController(i);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$didAddedNewTask$41$MessagesController(sparseArray);
}
});
}
public void lambda$didAddedNewTask$40$MessagesController(int i) {
int i2;
if ((this.currentDeletingTaskMids != null || this.gettingNewDeleteTask) && ((i2 = this.currentDeletingTaskTime) == 0 || i >= i2)) {
return;
}
getNewDeleteTask(null, 0);
}
public void lambda$didAddedNewTask$41$MessagesController(SparseArray sparseArray) {
getNotificationCenter().postNotificationName(NotificationCenter.didCreatedNewDeleteTask, sparseArray);
}
public void getNewDeleteTask(final ArrayList<Integer> arrayList, final int i) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$getNewDeleteTask$42$MessagesController(arrayList, i);
}
});
}
public void lambda$getNewDeleteTask$42$MessagesController(ArrayList arrayList, int i) {
this.gettingNewDeleteTask = true;
getMessagesStorage().getNewTask(arrayList, i);
}
private boolean checkDeletingTask(boolean z) {
int i;
int currentTime = getConnectionsManager().getCurrentTime();
if (this.currentDeletingTaskMids == null || (!z && ((i = this.currentDeletingTaskTime) == 0 || i > currentTime))) {
return false;
}
this.currentDeletingTaskTime = 0;
if (this.currentDeleteTaskRunnable != null && !z) {
Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
}
this.currentDeleteTaskRunnable = null;
final ArrayList arrayList = new ArrayList(this.currentDeletingTaskMids);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$checkDeletingTask$44$MessagesController(arrayList);
}
});
return true;
}
public void lambda$checkDeletingTask$44$MessagesController(final ArrayList arrayList) {
if (!arrayList.isEmpty() && ((Integer) arrayList.get(0)).intValue() > 0) {
getMessagesStorage().emptyMessagesMedia(arrayList);
} else {
deleteMessages(arrayList, null, null, 0L, 0, false, false);
}
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$43$MessagesController(arrayList);
}
});
}
public void lambda$null$43$MessagesController(ArrayList arrayList) {
getNewDeleteTask(arrayList, this.currentDeletingTaskChannelId);
this.currentDeletingTaskTime = 0;
this.currentDeletingTaskMids = null;
}
public void processLoadedDeleteTask(final int i, final ArrayList<Integer> arrayList, int i2) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processLoadedDeleteTask$46$MessagesController(arrayList, i);
}
});
}
public void lambda$processLoadedDeleteTask$46$MessagesController(ArrayList arrayList, int i) {
this.gettingNewDeleteTask = false;
if (arrayList != null) {
this.currentDeletingTaskTime = i;
this.currentDeletingTaskMids = arrayList;
if (this.currentDeleteTaskRunnable != null) {
Utilities.stageQueue.cancelRunnable(this.currentDeleteTaskRunnable);
this.currentDeleteTaskRunnable = null;
}
if (checkDeletingTask(false)) {
return;
}
this.currentDeleteTaskRunnable = new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$45$MessagesController();
}
};
Utilities.stageQueue.postRunnable(this.currentDeleteTaskRunnable, Math.abs(getConnectionsManager().getCurrentTime() - this.currentDeletingTaskTime) * 1000);
return;
}
this.currentDeletingTaskTime = 0;
this.currentDeletingTaskMids = null;
}
public void lambda$null$45$MessagesController() {
checkDeletingTask(true);
}
public void loadDialogPhotos(final int i, final int i2, final long j, boolean z, final int i3) {
if (z) {
getMessagesStorage().getDialogPhotos(i, i2, j, i3);
return;
}
if (i > 0) {
TLRPC.User user = getUser(Integer.valueOf(i));
if (user == null) {
return;
}
TLRPC.TL_photos_getUserPhotos tL_photos_getUserPhotos = new TLRPC.TL_photos_getUserPhotos();
tL_photos_getUserPhotos.limit = i2;
tL_photos_getUserPhotos.offset = 0;
tL_photos_getUserPhotos.max_id = (int) j;
tL_photos_getUserPhotos.user_id = getInputUser(user);
getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_photos_getUserPhotos, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadDialogPhotos$47$MessagesController(i, i2, j, i3, tLObject, tL_error);
}
}), i3);
return;
}
if (i < 0) {
TLRPC.TL_messages_search tL_messages_search = new TLRPC.TL_messages_search();
tL_messages_search.filter = new TLRPC.TL_inputMessagesFilterChatPhotos();
tL_messages_search.limit = i2;
tL_messages_search.offset_id = (int) j;
tL_messages_search.q = "";
tL_messages_search.peer = getInputPeer(i);
getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_messages_search, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadDialogPhotos$48$MessagesController(i, i2, j, i3, tLObject, tL_error);
}
}), i3);
}
}
public void lambda$loadDialogPhotos$47$MessagesController(int i, int i2, long j, int i3, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
processLoadedUserPhotos((TLRPC.photos_Photos) tLObject, i, i2, j, false, i3);
}
}
public void lambda$loadDialogPhotos$48$MessagesController(int i, int i2, long j, int i3, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
TLRPC.TL_photos_photos tL_photos_photos = new TLRPC.TL_photos_photos();
tL_photos_photos.count = messages_messages.count;
tL_photos_photos.users.addAll(messages_messages.users);
for (int i4 = 0; i4 < messages_messages.messages.size(); i4++) {
TLRPC.Message message = messages_messages.messages.get(i4);
if (message.action != null && message.action.photo != null) {
tL_photos_photos.photos.add(message.action.photo);
}
}
processLoadedUserPhotos(tL_photos_photos, i, i2, j, false, i3);
}
}
public void blockUser(int i) {
TLRPC.User user = getUser(Integer.valueOf(i));
if (user == null || this.blockedUsers.indexOfKey(i) >= 0) {
return;
}
this.blockedUsers.put(i, 1);
if (user.bot) {
getMediaDataController().removeInline(i);
} else {
getMediaDataController().removePeer(i);
}
int i2 = this.totalBlockedCount;
if (i2 >= 0) {
this.totalBlockedCount = i2 + 1;
}
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
TLRPC.TL_contacts_block tL_contacts_block = new TLRPC.TL_contacts_block();
tL_contacts_block.id = getInputUser(user);
getConnectionsManager().sendRequest(tL_contacts_block, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$blockUser$49(tLObject, tL_error);
}
});
}
public void setUserBannedRole(final int i, TLRPC.User user, TLRPC.TL_chatBannedRights tL_chatBannedRights, final boolean z, final BaseFragment baseFragment) {
if (user == null || tL_chatBannedRights == null) {
return;
}
final TLRPC.TL_channels_editBanned tL_channels_editBanned = new TLRPC.TL_channels_editBanned();
tL_channels_editBanned.channel = getInputChannel(i);
tL_channels_editBanned.user_id = getInputUser(user);
tL_channels_editBanned.banned_rights = tL_chatBannedRights;
getConnectionsManager().sendRequest(tL_channels_editBanned, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$setUserBannedRole$52$MessagesController(i, baseFragment, tL_channels_editBanned, z, tLObject, tL_error);
}
});
}
public void lambda$setUserBannedRole$52$MessagesController(final int i, final BaseFragment baseFragment, final TLRPC.TL_channels_editBanned tL_channels_editBanned, final boolean z, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$50$MessagesController(i);
}
}, 1000L);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$51$MessagesController(tL_error, baseFragment, tL_channels_editBanned, z);
}
});
}
}
public void lambda$null$50$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void lambda$null$51$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_editBanned tL_channels_editBanned, boolean z) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_editBanned, Boolean.valueOf(z));
}
public void setChannelSlowMode(final int i, int i2) {
TLRPC.TL_channels_toggleSlowMode tL_channels_toggleSlowMode = new TLRPC.TL_channels_toggleSlowMode();
tL_channels_toggleSlowMode.seconds = i2;
tL_channels_toggleSlowMode.channel = getInputChannel(i);
getConnectionsManager().sendRequest(tL_channels_toggleSlowMode, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$setChannelSlowMode$54$MessagesController(i, tLObject, tL_error);
}
});
}
public void lambda$setChannelSlowMode$54$MessagesController(final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
getMessagesController().processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$53$MessagesController(i);
}
}, 1000L);
}
}
public void lambda$null$53$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void setDefaultBannedRole(final int i, TLRPC.TL_chatBannedRights tL_chatBannedRights, final boolean z, final BaseFragment baseFragment) {
if (tL_chatBannedRights == null) {
return;
}
final TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights = new TLRPC.TL_messages_editChatDefaultBannedRights();
tL_messages_editChatDefaultBannedRights.peer = getInputPeer(-i);
tL_messages_editChatDefaultBannedRights.banned_rights = tL_chatBannedRights;
getConnectionsManager().sendRequest(tL_messages_editChatDefaultBannedRights, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$setDefaultBannedRole$57$MessagesController(i, baseFragment, tL_messages_editChatDefaultBannedRights, z, tLObject, tL_error);
}
});
}
public void lambda$setDefaultBannedRole$57$MessagesController(final int i, final BaseFragment baseFragment, final TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights, final boolean z, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$55$MessagesController(i);
}
}, 1000L);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$56$MessagesController(tL_error, baseFragment, tL_messages_editChatDefaultBannedRights, z);
}
});
}
}
public void lambda$null$55$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void lambda$null$56$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_editChatDefaultBannedRights tL_messages_editChatDefaultBannedRights, boolean z) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_editChatDefaultBannedRights, Boolean.valueOf(z));
}
public void setUserAdminRole(final int i, TLRPC.User user, TLRPC.TL_chatAdminRights tL_chatAdminRights, String str, final boolean z, final BaseFragment baseFragment, boolean z2) {
if (user == null || tL_chatAdminRights == null) {
return;
}
TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (ChatObject.isChannel(chat)) {
final TLRPC.TL_channels_editAdmin tL_channels_editAdmin = new TLRPC.TL_channels_editAdmin();
tL_channels_editAdmin.channel = getInputChannel(chat);
tL_channels_editAdmin.user_id = getInputUser(user);
tL_channels_editAdmin.admin_rights = tL_chatAdminRights;
tL_channels_editAdmin.rank = str;
getConnectionsManager().sendRequest(tL_channels_editAdmin, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$setUserAdminRole$60$MessagesController(i, baseFragment, tL_channels_editAdmin, z, tLObject, tL_error);
}
});
return;
}
final TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin = new TLRPC.TL_messages_editChatAdmin();
tL_messages_editChatAdmin.chat_id = i;
tL_messages_editChatAdmin.user_id = getInputUser(user);
tL_messages_editChatAdmin.is_admin = tL_chatAdminRights.change_info || tL_chatAdminRights.delete_messages || tL_chatAdminRights.ban_users || tL_chatAdminRights.invite_users || tL_chatAdminRights.pin_messages || tL_chatAdminRights.add_admins;
final RequestDelegate requestDelegate = new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$setUserAdminRole$63$MessagesController(i, baseFragment, tL_messages_editChatAdmin, tLObject, tL_error);
}
};
if (tL_messages_editChatAdmin.is_admin && z2) {
addUserToChat(i, user, null, 0, null, baseFragment, new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$setUserAdminRole$64$MessagesController(tL_messages_editChatAdmin, requestDelegate);
}
});
} else {
getConnectionsManager().sendRequest(tL_messages_editChatAdmin, requestDelegate);
}
}
public void lambda$setUserAdminRole$60$MessagesController(final int i, final BaseFragment baseFragment, final TLRPC.TL_channels_editAdmin tL_channels_editAdmin, final boolean z, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$58$MessagesController(i);
}
}, 1000L);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$59$MessagesController(tL_error, baseFragment, tL_channels_editAdmin, z);
}
});
}
}
public void lambda$null$58$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void lambda$null$59$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_editAdmin tL_channels_editAdmin, boolean z) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_editAdmin, Boolean.valueOf(z));
}
public void lambda$null$61$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void lambda$setUserAdminRole$63$MessagesController(final int i, final BaseFragment baseFragment, final TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$61$MessagesController(i);
}
}, 1000L);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$62$MessagesController(tL_error, baseFragment, tL_messages_editChatAdmin);
}
});
}
}
public void lambda$null$62$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_editChatAdmin, false);
}
public void lambda$setUserAdminRole$64$MessagesController(TLRPC.TL_messages_editChatAdmin tL_messages_editChatAdmin, RequestDelegate requestDelegate) {
getConnectionsManager().sendRequest(tL_messages_editChatAdmin, requestDelegate);
}
public void unblockUser(int i) {
TLRPC.TL_contacts_unblock tL_contacts_unblock = new TLRPC.TL_contacts_unblock();
TLRPC.User user = getUser(Integer.valueOf(i));
if (user == null) {
return;
}
this.totalBlockedCount--;
this.blockedUsers.delete(user.id);
tL_contacts_unblock.id = getInputUser(user);
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
getConnectionsManager().sendRequest(tL_contacts_unblock, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$unblockUser$65(tLObject, tL_error);
}
});
}
public void getBlockedUsers(final boolean z) {
if (!getUserConfig().isClientActivated() || this.loadingBlockedUsers) {
return;
}
this.loadingBlockedUsers = true;
final TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked = new TLRPC.TL_contacts_getBlocked();
tL_contacts_getBlocked.offset = z ? 0 : this.blockedUsers.size();
tL_contacts_getBlocked.limit = z ? 20 : 100;
getConnectionsManager().sendRequest(tL_contacts_getBlocked, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$getBlockedUsers$67$MessagesController(z, tL_contacts_getBlocked, tLObject, tL_error);
}
});
}
public void lambda$getBlockedUsers$67$MessagesController(final boolean z, final TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$66$MessagesController(tLObject, z, tL_contacts_getBlocked);
}
});
}
public void lambda$null$66$MessagesController(TLObject tLObject, boolean z, TLRPC.TL_contacts_getBlocked tL_contacts_getBlocked) {
if (tLObject != null) {
TLRPC.contacts_Blocked contacts_blocked = (TLRPC.contacts_Blocked) tLObject;
putUsers(contacts_blocked.users, false);
getMessagesStorage().putUsersAndChats(contacts_blocked.users, null, true, true);
if (z) {
this.blockedUsers.clear();
}
this.totalBlockedCount = Math.max(contacts_blocked.count, contacts_blocked.blocked.size());
this.blockedEndReached = contacts_blocked.blocked.size() < tL_contacts_getBlocked.limit;
int size = contacts_blocked.blocked.size();
for (int i = 0; i < size; i++) {
this.blockedUsers.put(contacts_blocked.blocked.get(i).user_id, 1);
}
this.loadingBlockedUsers = false;
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
}
}
public void deleteUserPhoto(TLRPC.InputPhoto inputPhoto) {
if (inputPhoto == null) {
TLRPC.TL_photos_updateProfilePhoto tL_photos_updateProfilePhoto = new TLRPC.TL_photos_updateProfilePhoto();
tL_photos_updateProfilePhoto.id = new TLRPC.TL_inputPhotoEmpty();
getUserConfig().getCurrentUser().photo = new TLRPC.TL_userProfilePhotoEmpty();
TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
if (user == null) {
user = getUserConfig().getCurrentUser();
}
if (user == null) {
return;
}
user.photo = getUserConfig().getCurrentUser().photo;
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(UPDATE_MASK_ALL));
getConnectionsManager().sendRequest(tL_photos_updateProfilePhoto, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteUserPhoto$69$MessagesController(tLObject, tL_error);
}
});
return;
}
TLRPC.TL_photos_deletePhotos tL_photos_deletePhotos = new TLRPC.TL_photos_deletePhotos();
tL_photos_deletePhotos.id.add(inputPhoto);
getConnectionsManager().sendRequest(tL_photos_deletePhotos, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$deleteUserPhoto$70(tLObject, tL_error);
}
});
}
public void lambda$deleteUserPhoto$69$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.User user = getUser(Integer.valueOf(getUserConfig().getClientUserId()));
if (user == null) {
user = getUserConfig().getCurrentUser();
putUser(user, false);
} else {
getUserConfig().setCurrentUser(user);
}
if (user == null) {
return;
}
getMessagesStorage().clearUserPhotos(user.id);
ArrayList<TLRPC.User> arrayList = new ArrayList<>();
arrayList.add(user);
getMessagesStorage().putUsersAndChats(arrayList, null, false, true);
user.photo = (TLRPC.UserProfilePhoto) tLObject;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$68$MessagesController();
}
});
}
}
public void lambda$null$68$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(UPDATE_MASK_ALL));
getUserConfig().saveConfig(true);
}
public void processLoadedUserPhotos(final TLRPC.photos_Photos photos_photos, final int i, final int i2, long j, final boolean z, final int i3) {
if (!z) {
getMessagesStorage().putUsersAndChats(photos_photos.users, null, true, true);
getMessagesStorage().putDialogPhotos(i, photos_photos);
} else if (photos_photos == null || photos_photos.photos.isEmpty()) {
loadDialogPhotos(i, i2, j, false, i3);
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processLoadedUserPhotos$71$MessagesController(photos_photos, z, i, i2, i3);
}
});
}
public void lambda$processLoadedUserPhotos$71$MessagesController(TLRPC.photos_Photos photos_photos, boolean z, int i, int i2, int i3) {
putUsers(photos_photos.users, z);
getNotificationCenter().postNotificationName(NotificationCenter.dialogPhotosLoaded, Integer.valueOf(i), Integer.valueOf(i2), Boolean.valueOf(z), Integer.valueOf(i3), photos_photos.photos);
}
public void uploadAndApplyUserAvatar(TLRPC.FileLocation fileLocation) {
if (fileLocation == null) {
return;
}
this.uploadingAvatar = FileLoader.getDirectory(4) + "/" + fileLocation.volume_id + "_" + fileLocation.local_id + ".jpg";
getFileLoader().uploadFile(this.uploadingAvatar, false, true, 16777216);
}
public void uploadAvatar(TLRPC.FileLocation fileLocation) {
if (fileLocation == null) {
return;
}
this.uploadingAvatar = FileLoader.getDirectory(4) + "/" + fileLocation.volume_id + "_" + fileLocation.local_id + ".jpg";
getFileLoader().uploadFile(this.uploadingAvatar, false, true, 16777216, false);
}
public void saveTheme(Theme.ThemeInfo themeInfo, boolean z, boolean z2) {
if (themeInfo.info != null) {
TLRPC.TL_account_saveTheme tL_account_saveTheme = new TLRPC.TL_account_saveTheme();
TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
tL_inputTheme.id = themeInfo.info.id;
tL_inputTheme.access_hash = themeInfo.info.access_hash;
tL_account_saveTheme.theme = tL_inputTheme;
tL_account_saveTheme.unsave = z2;
getConnectionsManager().sendRequest(tL_account_saveTheme, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$saveTheme$72(tLObject, tL_error);
}
});
}
if (z2) {
return;
}
installTheme(themeInfo, z);
}
public void installTheme(Theme.ThemeInfo themeInfo, boolean z) {
TLRPC.TL_account_installTheme tL_account_installTheme = new TLRPC.TL_account_installTheme();
tL_account_installTheme.dark = z;
if (themeInfo.info != null) {
tL_account_installTheme.format = "android";
TLRPC.TL_inputTheme tL_inputTheme = new TLRPC.TL_inputTheme();
tL_inputTheme.id = themeInfo.info.id;
tL_inputTheme.access_hash = themeInfo.info.access_hash;
tL_account_installTheme.theme = tL_inputTheme;
tL_account_installTheme.flags |= 2;
}
getConnectionsManager().sendRequest(tL_account_installTheme, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$installTheme$73(tLObject, tL_error);
}
});
if (TextUtils.isEmpty(themeInfo.slug)) {
return;
}
TLRPC.TL_account_installWallPaper tL_account_installWallPaper = new TLRPC.TL_account_installWallPaper();
TLRPC.TL_inputWallPaperSlug tL_inputWallPaperSlug = new TLRPC.TL_inputWallPaperSlug();
tL_inputWallPaperSlug.slug = themeInfo.slug;
tL_account_installWallPaper.wallpaper = tL_inputWallPaperSlug;
tL_account_installWallPaper.settings = new TLRPC.TL_wallPaperSettings();
tL_account_installWallPaper.settings.blur = themeInfo.isBlured;
tL_account_installWallPaper.settings.motion = themeInfo.isMotion;
getConnectionsManager().sendRequest(tL_account_installWallPaper, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$installTheme$74(tLObject, tL_error);
}
});
}
public void saveThemeToServer(final Theme.ThemeInfo themeInfo) {
if (themeInfo == null || this.uploadingThemes.containsKey(themeInfo.pathToFile)) {
return;
}
this.uploadingThemes.put(themeInfo.pathToFile, themeInfo);
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$saveThemeToServer$76$MessagesController(themeInfo);
}
});
}
public void lambda$saveThemeToServer$76$MessagesController(final Theme.ThemeInfo themeInfo) {
final String createThemePreviewImage = Theme.createThemePreviewImage(themeInfo);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$75$MessagesController(createThemePreviewImage, themeInfo);
}
});
}
public void lambda$null$75$MessagesController(String str, Theme.ThemeInfo themeInfo) {
if (str == null) {
this.uploadingThemes.remove(themeInfo.pathToFile);
return;
}
themeInfo.uploadingFile = themeInfo.pathToFile;
themeInfo.uploadingThumb = str;
this.uploadingThemes.put(str, themeInfo);
new File(themeInfo.pathToFile).length();
new File(str).length();
getFileLoader().uploadFile(themeInfo.pathToFile, false, true, ConnectionsManager.FileTypeFile);
getFileLoader().uploadFile(str, false, true, 16777216);
}
public void saveWallpaperToServer(File file, final long j, final String str, long j2, boolean z, boolean z2, int i, float f, final boolean z3, long j3) {
TLRPC.TL_account_saveWallPaper tL_account_saveWallPaper;
NativeByteBuffer nativeByteBuffer;
final long createPendingTask;
if (this.uploadingWallpaper != null) {
File file2 = new File(ApplicationLoader.getFilesDirFixed(), this.uploadingWallpaperBlurred ? "wallpaper_original.jpg" : "wallpaper.jpg");
if (file != null && (file.getAbsolutePath().equals(this.uploadingWallpaper) || file.equals(file2))) {
this.uploadingWallpaperMotion = z2;
this.uploadingWallpaperBlurred = z;
return;
} else {
getFileLoader().cancelUploadFile(this.uploadingWallpaper, false);
this.uploadingWallpaper = null;
}
}
if (file != null) {
this.uploadingWallpaper = file.getAbsolutePath();
this.uploadingWallpaperMotion = z2;
this.uploadingWallpaperBlurred = z;
getFileLoader().uploadFile(this.uploadingWallpaper, false, true, 16777216);
return;
}
if (j2 != 0) {
TLRPC.TL_inputWallPaper tL_inputWallPaper = new TLRPC.TL_inputWallPaper();
tL_inputWallPaper.id = j;
tL_inputWallPaper.access_hash = j2;
TLRPC.TL_wallPaperSettings tL_wallPaperSettings = new TLRPC.TL_wallPaperSettings();
tL_wallPaperSettings.blur = z;
tL_wallPaperSettings.motion = z2;
if (i != 0) {
tL_wallPaperSettings.background_color = i;
tL_wallPaperSettings.flags = 1 | tL_wallPaperSettings.flags;
tL_wallPaperSettings.intensity = (int) (100.0f * f);
tL_wallPaperSettings.flags |= 8;
}
if (z3) {
TLRPC.TL_account_installWallPaper tL_account_installWallPaper = new TLRPC.TL_account_installWallPaper();
tL_account_installWallPaper.wallpaper = tL_inputWallPaper;
tL_account_installWallPaper.settings = tL_wallPaperSettings;
tL_account_saveWallPaper = tL_account_installWallPaper;
} else {
TLRPC.TL_account_saveWallPaper tL_account_saveWallPaper2 = new TLRPC.TL_account_saveWallPaper();
tL_account_saveWallPaper2.wallpaper = tL_inputWallPaper;
tL_account_saveWallPaper2.settings = tL_wallPaperSettings;
tL_account_saveWallPaper = tL_account_saveWallPaper2;
}
if (j3 != 0) {
createPendingTask = j3;
} else {
try {
nativeByteBuffer = new NativeByteBuffer(1024);
try {
nativeByteBuffer.writeInt32(19);
nativeByteBuffer.writeInt64(j);
nativeByteBuffer.writeInt64(j2);
nativeByteBuffer.writeBool(z);
nativeByteBuffer.writeBool(z2);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeDouble(f);
nativeByteBuffer.writeBool(z3);
if (str != null) {
nativeByteBuffer.writeString(str);
} else {
nativeByteBuffer.writeString("");
}
nativeByteBuffer.limit(nativeByteBuffer.position());
} catch (Exception e) {
e = e;
FileLog.e(e);
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
getConnectionsManager().sendRequest(tL_account_saveWallPaper, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$saveWallpaperToServer$77$MessagesController(createPendingTask, z3, j, str, tLObject, tL_error);
}
});
}
} catch (Exception e2) {
e = e2;
nativeByteBuffer = null;
}
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
getConnectionsManager().sendRequest(tL_account_saveWallPaper, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$saveWallpaperToServer$77$MessagesController(createPendingTask, z3, j, str, tLObject, tL_error);
}
});
}
}
public void lambda$saveWallpaperToServer$77$MessagesController(long j, boolean z, long j2, String str, TLObject tLObject, TLRPC.TL_error tL_error) {
getMessagesStorage().removePendingTask(j);
if (z || this.uploadingWallpaper == null) {
return;
}
SharedPreferences.Editor edit = getGlobalMainSettings().edit();
edit.putLong("selectedBackground2", j2);
if (!TextUtils.isEmpty(str)) {
edit.putString("selectedBackgroundSlug", str);
} else {
edit.remove("selectedBackgroundSlug");
}
edit.commit();
}
public void markChannelDialogMessageAsDeleted(ArrayList<Integer> arrayList, int i) {
MessageObject messageObject = this.dialogMessage.get(-i);
if (messageObject != null) {
for (int i2 = 0; i2 < arrayList.size(); i2++) {
if (messageObject.getId() == arrayList.get(i2).intValue()) {
messageObject.deleted = true;
return;
}
}
}
}
public void deleteMessages(ArrayList<Integer> arrayList, ArrayList<Long> arrayList2, TLRPC.EncryptedChat encryptedChat, long j, int i, boolean z, boolean z2) {
deleteMessages(arrayList, arrayList2, encryptedChat, j, i, true, z2, 0L, null);
}
public void deleteMessages(ArrayList<Integer> arrayList, ArrayList<Long> arrayList2, TLRPC.EncryptedChat encryptedChat, long j, final int i, boolean z, boolean z2, long j2, TLObject tLObject) {
ArrayList<Integer> arrayList3;
NativeByteBuffer nativeByteBuffer;
final long createPendingTask;
TLRPC.TL_messages_deleteMessages tL_messages_deleteMessages;
NativeByteBuffer nativeByteBuffer2;
final long createPendingTask2;
TLRPC.TL_channels_deleteMessages tL_channels_deleteMessages;
NativeByteBuffer nativeByteBuffer3;
final long createPendingTask3;
TLRPC.TL_messages_deleteScheduledMessages tL_messages_deleteScheduledMessages;
char c;
if ((arrayList == null || arrayList.isEmpty()) && tLObject == null) {
return;
}
NativeByteBuffer nativeByteBuffer4 = null;
if (j2 == 0) {
arrayList3 = new ArrayList<>();
for (int i2 = 0; i2 < arrayList.size(); i2++) {
Integer num = arrayList.get(i2);
if (num.intValue() > 0) {
arrayList3.add(num);
}
}
if (z2) {
c = 1;
getMessagesStorage().markMessagesAsDeleted(arrayList, true, i, false, true);
} else {
c = 1;
if (i == 0) {
for (int i3 = 0; i3 < arrayList.size(); i3++) {
MessageObject messageObject = this.dialogMessagesByIds.get(arrayList.get(i3).intValue());
if (messageObject != null) {
messageObject.deleted = true;
}
}
} else {
markChannelDialogMessageAsDeleted(arrayList, i);
}
getMessagesStorage().markMessagesAsDeleted(arrayList, true, i, z, false);
getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, null, true, i);
}
NotificationCenter notificationCenter = getNotificationCenter();
int i4 = NotificationCenter.messagesDeleted;
Object[] objArr = new Object[3];
objArr[0] = arrayList;
objArr[c] = Integer.valueOf(i);
objArr[2] = Boolean.valueOf(z2);
notificationCenter.postNotificationName(i4, objArr);
} else {
arrayList3 = null;
}
if (z2) {
if (tLObject != null) {
tL_messages_deleteScheduledMessages = (TLRPC.TL_messages_deleteScheduledMessages) tLObject;
createPendingTask3 = j2;
} else {
TLRPC.TL_messages_deleteScheduledMessages tL_messages_deleteScheduledMessages2 = new TLRPC.TL_messages_deleteScheduledMessages();
tL_messages_deleteScheduledMessages2.id = arrayList3;
tL_messages_deleteScheduledMessages2.peer = getInputPeer((int) j);
try {
nativeByteBuffer3 = new NativeByteBuffer(tL_messages_deleteScheduledMessages2.getObjectSize() + 16);
try {
nativeByteBuffer3.writeInt32(18);
nativeByteBuffer3.writeInt64(j);
nativeByteBuffer3.writeInt32(i);
tL_messages_deleteScheduledMessages2.serializeToStream(nativeByteBuffer3);
} catch (Exception e) {
e = e;
nativeByteBuffer4 = nativeByteBuffer3;
FileLog.e(e);
nativeByteBuffer3 = nativeByteBuffer4;
createPendingTask3 = MessagesStorage.getInstance(this.currentAccount).createPendingTask(nativeByteBuffer3);
tL_messages_deleteScheduledMessages = tL_messages_deleteScheduledMessages2;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_deleteScheduledMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$78$MessagesController(createPendingTask3, tLObject2, tL_error);
}
});
return;
}
} catch (Exception e2) {
e = e2;
}
createPendingTask3 = MessagesStorage.getInstance(this.currentAccount).createPendingTask(nativeByteBuffer3);
tL_messages_deleteScheduledMessages = tL_messages_deleteScheduledMessages2;
}
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_deleteScheduledMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$78$MessagesController(createPendingTask3, tLObject2, tL_error);
}
});
return;
}
if (i != 0) {
if (tLObject != null) {
tL_channels_deleteMessages = (TLRPC.TL_channels_deleteMessages) tLObject;
createPendingTask2 = j2;
} else {
TLRPC.TL_channels_deleteMessages tL_channels_deleteMessages2 = new TLRPC.TL_channels_deleteMessages();
tL_channels_deleteMessages2.id = arrayList3;
tL_channels_deleteMessages2.channel = getInputChannel(i);
try {
nativeByteBuffer2 = new NativeByteBuffer(tL_channels_deleteMessages2.getObjectSize() + 8);
try {
nativeByteBuffer2.writeInt32(7);
nativeByteBuffer2.writeInt32(i);
tL_channels_deleteMessages2.serializeToStream(nativeByteBuffer2);
} catch (Exception e3) {
e = e3;
nativeByteBuffer4 = nativeByteBuffer2;
FileLog.e(e);
nativeByteBuffer2 = nativeByteBuffer4;
createPendingTask2 = getMessagesStorage().createPendingTask(nativeByteBuffer2);
tL_channels_deleteMessages = tL_channels_deleteMessages2;
getConnectionsManager().sendRequest(tL_channels_deleteMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$79$MessagesController(i, createPendingTask2, tLObject2, tL_error);
}
});
return;
}
} catch (Exception e4) {
e = e4;
}
createPendingTask2 = getMessagesStorage().createPendingTask(nativeByteBuffer2);
tL_channels_deleteMessages = tL_channels_deleteMessages2;
}
getConnectionsManager().sendRequest(tL_channels_deleteMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$79$MessagesController(i, createPendingTask2, tLObject2, tL_error);
}
});
return;
}
if (arrayList2 != null && encryptedChat != null && !arrayList2.isEmpty()) {
getSecretChatHelper().sendMessagesDeleteMessage(encryptedChat, arrayList2, null);
}
if (tLObject != null) {
tL_messages_deleteMessages = (TLRPC.TL_messages_deleteMessages) tLObject;
createPendingTask = j2;
} else {
TLRPC.TL_messages_deleteMessages tL_messages_deleteMessages2 = new TLRPC.TL_messages_deleteMessages();
tL_messages_deleteMessages2.id = arrayList3;
tL_messages_deleteMessages2.revoke = z;
try {
nativeByteBuffer = new NativeByteBuffer(tL_messages_deleteMessages2.getObjectSize() + 8);
} catch (Exception e5) {
e = e5;
}
try {
nativeByteBuffer.writeInt32(7);
nativeByteBuffer.writeInt32(i);
tL_messages_deleteMessages2.serializeToStream(nativeByteBuffer);
} catch (Exception e6) {
e = e6;
nativeByteBuffer4 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer4;
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
tL_messages_deleteMessages = tL_messages_deleteMessages2;
getConnectionsManager().sendRequest(tL_messages_deleteMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$80$MessagesController(createPendingTask, tLObject2, tL_error);
}
});
}
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
tL_messages_deleteMessages = tL_messages_deleteMessages2;
}
getConnectionsManager().sendRequest(tL_messages_deleteMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject2, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteMessages$80$MessagesController(createPendingTask, tLObject2, tL_error);
}
});
}
public void lambda$deleteMessages$78$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
}
if (j != 0) {
MessagesStorage.getInstance(this.currentAccount).removePendingTask(j);
}
}
public void lambda$deleteMessages$79$MessagesController(int i, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewChannelDifferenceParams(tL_messages_affectedMessages.pts, tL_messages_affectedMessages.pts_count, i);
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void lambda$deleteMessages$80$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void pinMessage(TLRPC.Chat chat, TLRPC.User user, int i, boolean z) {
if (chat == null && user == null) {
return;
}
TLRPC.TL_messages_updatePinnedMessage tL_messages_updatePinnedMessage = new TLRPC.TL_messages_updatePinnedMessage();
tL_messages_updatePinnedMessage.peer = getInputPeer(chat != null ? -chat.id : user.id);
tL_messages_updatePinnedMessage.id = i;
tL_messages_updatePinnedMessage.silent = !z;
getConnectionsManager().sendRequest(tL_messages_updatePinnedMessage, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$pinMessage$81$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$pinMessage$81$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void deleteUserChannelHistory(final TLRPC.Chat chat, final TLRPC.User user, int i) {
if (i == 0) {
getMessagesStorage().deleteUserChannelHistory(chat.id, user.id);
}
TLRPC.TL_channels_deleteUserHistory tL_channels_deleteUserHistory = new TLRPC.TL_channels_deleteUserHistory();
tL_channels_deleteUserHistory.channel = getInputChannel(chat);
tL_channels_deleteUserHistory.user_id = getInputUser(user);
getConnectionsManager().sendRequest(tL_channels_deleteUserHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteUserChannelHistory$82$MessagesController(chat, user, tLObject, tL_error);
}
});
}
public void lambda$deleteUserChannelHistory$82$MessagesController(TLRPC.Chat chat, TLRPC.User user, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedHistory tL_messages_affectedHistory = (TLRPC.TL_messages_affectedHistory) tLObject;
if (tL_messages_affectedHistory.offset > 0) {
deleteUserChannelHistory(chat, user, tL_messages_affectedHistory.offset);
}
processNewChannelDifferenceParams(tL_messages_affectedHistory.pts, tL_messages_affectedHistory.pts_count, chat.id);
}
}
public ArrayList<TLRPC.Dialog> getAllDialogs() {
return this.allDialogs;
}
public boolean isDialogsEndReached(int i) {
return this.dialogsEndReached.get(i);
}
public boolean isLoadingDialogs(int i) {
return this.loadingDialogs.get(i);
}
public boolean isServerDialogsEndReached(int i) {
return this.serverDialogsEndReached.get(i);
}
public boolean hasHiddenArchive() {
return SharedConfig.archiveHidden && this.dialogs_dict.get(DialogObject.makeFolderDialogId(1)) != null;
}
public ArrayList<TLRPC.Dialog> getDialogs(int i) {
ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(i);
return arrayList == null ? new ArrayList<>() : arrayList;
}
private void removeDialog(TLRPC.Dialog dialog) {
if (dialog == null) {
return;
}
final long j = dialog.id;
if (this.dialogsServerOnly.remove(dialog) && DialogObject.isChannel(dialog)) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$removeDialog$83$MessagesController(j);
}
});
}
this.allDialogs.remove(dialog);
this.dialogsCanAddUsers.remove(dialog);
this.dialogsChannelsOnly.remove(dialog);
this.dialogsGroupsOnly.remove(dialog);
this.dialogsUnreadOnly.remove(dialog);
this.dialogsUsersOnly.remove(dialog);
this.dialogsForward.remove(dialog);
this.dialogs_dict.remove(j);
this.dialogs_read_inbox_max.remove(Long.valueOf(j));
this.dialogs_read_outbox_max.remove(Long.valueOf(j));
ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(dialog.folder_id);
if (arrayList != null) {
arrayList.remove(dialog);
}
}
public void lambda$removeDialog$83$MessagesController(long j) {
int i = -((int) j);
this.channelsPts.delete(i);
this.shortPollChannels.delete(i);
this.needShortPollChannels.delete(i);
this.shortPollOnlines.delete(i);
this.needShortPollOnlines.delete(i);
}
public void deleteDialog(long j, int i) {
deleteDialog(j, i, false);
}
public void deleteDialog(long j, int i, boolean z) {
deleteDialog(j, true, i, 0, z, null, 0L);
}
public void setDialogsInTransaction(boolean z) {
this.dialogsInTransaction = z;
if (z) {
return;
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}
public void deleteDialog(final long j, boolean z, final int i, int i2, final boolean z2, TLRPC.InputPeer inputPeer, long j2) {
int i3;
MessagesController messagesController;
boolean z3;
int i4;
NativeByteBuffer nativeByteBuffer;
final long createPendingTask;
int i5;
boolean z4;
int i6;
TLRPC.Chat chat;
int i7;
if (i == 2) {
getMessagesStorage().deleteDialog(j, i);
return;
}
if (i == 0 || i == 3) {
getMediaDataController().uninstallShortcut(j);
}
int i8 = (int) j;
int i9 = (int) (j >> 32);
if (z) {
getMessagesStorage().deleteDialog(j, i);
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (i == 0 || i == 3) {
getNotificationsController().deleteNotificationChannel(j);
}
if (dialog != null) {
i5 = i2 == 0 ? Math.max(Math.max(Math.max(0, dialog.top_message), dialog.read_inbox_max_id), dialog.read_outbox_max_id) : i2;
if (i == 0 || i == 3) {
TLRPC.Dialog dialog2 = this.proxyDialog;
i6 = i8;
z4 = dialog2 != null && dialog2.id == j;
if (z4) {
this.isLeftProxyChannel = true;
if (this.proxyDialog.id < 0 && (chat = getChat(Integer.valueOf(-((int) this.proxyDialog.id)))) != null) {
chat.left = true;
}
sortDialogs(null);
dialog = dialog;
} else {
removeDialog(dialog);
int i10 = this.nextDialogsCacheOffset.get(dialog.folder_id, 0);
if (i10 > 0) {
this.nextDialogsCacheOffset.put(dialog.folder_id, i10 - 1);
}
}
} else {
dialog.unread_count = 0;
i6 = i8;
z4 = false;
}
if (z4) {
messagesController = this;
i3 = i6;
} else {
MessageObject messageObject = this.dialogMessage.get(dialog.id);
this.dialogMessage.remove(dialog.id);
if (messageObject != null) {
i7 = messageObject.getId();
this.dialogMessagesByIds.remove(messageObject.getId());
} else {
i7 = dialog.top_message;
messageObject = this.dialogMessagesByIds.get(dialog.top_message);
this.dialogMessagesByIds.remove(dialog.top_message);
}
if (messageObject != null && messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject.messageOwner.random_id);
}
if (i == 1 && i6 != 0 && i7 > 0) {
TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
tL_messageService.id = dialog.top_message;
tL_messageService.out = ((long) getUserConfig().getClientUserId()) == j;
tL_messageService.from_id = getUserConfig().getClientUserId();
tL_messageService.flags |= 256;
tL_messageService.action = new TLRPC.TL_messageActionHistoryClear();
tL_messageService.date = dialog.last_message_date;
i3 = i6;
tL_messageService.dialog_id = i3;
if (i3 > 0) {
tL_messageService.to_id = new TLRPC.TL_peerUser();
tL_messageService.to_id.user_id = i3;
} else {
int i11 = -i3;
if (ChatObject.isChannel(getChat(Integer.valueOf(i11)))) {
tL_messageService.to_id = new TLRPC.TL_peerChannel();
tL_messageService.to_id.channel_id = i11;
} else {
tL_messageService.to_id = new TLRPC.TL_peerChat();
tL_messageService.to_id.chat_id = i11;
}
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, tL_messageService, this.createdDialogIds.contains(Long.valueOf(tL_messageService.dialog_id)));
ArrayList<MessageObject> arrayList = new ArrayList<>();
arrayList.add(messageObject2);
ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
arrayList2.add(tL_messageService);
messagesController = this;
messagesController.updateInterfaceWithMessages(j, arrayList, false);
getMessagesStorage().putMessages(arrayList2, false, true, false, 0, false);
} else {
messagesController = this;
i3 = i6;
dialog.top_message = 0;
}
}
} else {
i3 = i8;
messagesController = this;
i5 = i2;
z4 = false;
}
if (messagesController.dialogsInTransaction) {
z3 = false;
} else if (z4) {
z3 = false;
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
} else {
z3 = false;
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.removeAllMessagesFromDialog, Long.valueOf(j), false);
}
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$deleteDialog$85$MessagesController(j);
}
});
i4 = i5;
} else {
i3 = i8;
messagesController = this;
z3 = false;
i4 = i2;
}
if (i == 3) {
return;
}
if (i3 == 0) {
if (i == 1) {
getSecretChatHelper().sendClearHistoryMessage(messagesController.getEncryptedChat(Integer.valueOf(i9)), null);
return;
} else {
getSecretChatHelper().declineSecretChat(i9);
return;
}
}
TLRPC.InputPeer inputPeer2 = inputPeer == null ? messagesController.getInputPeer(i3) : inputPeer;
if (inputPeer2 == null) {
return;
}
boolean z5 = inputPeer2 instanceof TLRPC.TL_inputPeerChannel;
if (!z5 || i != 0) {
if (i4 > 0 && i4 != Integer.MAX_VALUE) {
messagesController.deletedHistory.put(j, Integer.valueOf(i4));
}
if (j2 == 0) {
try {
nativeByteBuffer = new NativeByteBuffer(inputPeer2.getObjectSize() + 28);
} catch (Exception e) {
e = e;
nativeByteBuffer = null;
}
try {
nativeByteBuffer.writeInt32(13);
nativeByteBuffer.writeInt64(j);
nativeByteBuffer.writeBool(z);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeInt32(i4);
nativeByteBuffer.writeBool(z2);
inputPeer2.serializeToStream(nativeByteBuffer);
} catch (Exception e2) {
e = e2;
FileLog.e(e);
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
if (!z5) {
}
}
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
if (!z5) {
TLRPC.TL_messages_deleteHistory tL_messages_deleteHistory = new TLRPC.TL_messages_deleteHistory();
tL_messages_deleteHistory.peer = inputPeer2;
tL_messages_deleteHistory.max_id = i != 0 ? i4 : Integer.MAX_VALUE;
if (i != 0) {
z3 = true;
}
tL_messages_deleteHistory.just_clear = z3;
tL_messages_deleteHistory.revoke = z2;
final int i12 = i4;
final TLRPC.InputPeer inputPeer3 = inputPeer2;
getConnectionsManager().sendRequest(tL_messages_deleteHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteDialog$88$MessagesController(createPendingTask, j, i, i12, z2, inputPeer3, tLObject, tL_error);
}
}, 64);
return;
}
if (i == 0) {
if (createPendingTask != 0) {
getMessagesStorage().removePendingTask(createPendingTask);
return;
}
return;
}
TLRPC.TL_channels_deleteHistory tL_channels_deleteHistory = new TLRPC.TL_channels_deleteHistory();
tL_channels_deleteHistory.channel = new TLRPC.TL_inputChannel();
tL_channels_deleteHistory.channel.channel_id = inputPeer2.channel_id;
tL_channels_deleteHistory.channel.access_hash = inputPeer2.access_hash;
if (i4 <= 0) {
i4 = Integer.MAX_VALUE;
}
tL_channels_deleteHistory.max_id = i4;
final long j3 = createPendingTask;
getConnectionsManager().sendRequest(tL_channels_deleteHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteDialog$87$MessagesController(j3, j, tLObject, tL_error);
}
}, 64);
return;
}
}
createPendingTask = j2;
if (!z5) {
}
}
public void lambda$deleteDialog$85$MessagesController(final long j) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$84$MessagesController(j);
}
});
}
public void lambda$null$84$MessagesController(long j) {
getNotificationsController().removeNotificationsForDialog(j);
}
public void lambda$deleteDialog$87$MessagesController(long j, final long j2, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$86$MessagesController(j2);
}
});
}
public void lambda$null$86$MessagesController(long j) {
this.deletedHistory.remove(j);
}
public void lambda$deleteDialog$88$MessagesController(long j, long j2, int i, int i2, boolean z, TLRPC.InputPeer inputPeer, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
if (tL_error == null) {
TLRPC.TL_messages_affectedHistory tL_messages_affectedHistory = (TLRPC.TL_messages_affectedHistory) tLObject;
if (tL_messages_affectedHistory.offset > 0) {
deleteDialog(j2, false, i, i2, z, inputPeer, 0L);
}
processNewDifferenceParams(-1, tL_messages_affectedHistory.pts, -1, tL_messages_affectedHistory.pts_count);
getMessagesStorage().onDeleteQueryComplete(j2);
}
}
public void saveGif(final Object obj, TLRPC.Document document) {
if (obj == null || !MessageObject.isGifDocument(document)) {
return;
}
final TLRPC.TL_messages_saveGif tL_messages_saveGif = new TLRPC.TL_messages_saveGif();
tL_messages_saveGif.id = new TLRPC.TL_inputDocument();
tL_messages_saveGif.id.id = document.id;
tL_messages_saveGif.id.access_hash = document.access_hash;
tL_messages_saveGif.id.file_reference = document.file_reference;
if (tL_messages_saveGif.id.file_reference == null) {
tL_messages_saveGif.id.file_reference = new byte[0];
}
tL_messages_saveGif.unsave = false;
getConnectionsManager().sendRequest(tL_messages_saveGif, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$saveGif$89$MessagesController(obj, tL_messages_saveGif, tLObject, tL_error);
}
});
}
public void lambda$saveGif$89$MessagesController(Object obj, TLRPC.TL_messages_saveGif tL_messages_saveGif, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null || !FileRefController.isFileRefError(tL_error.text) || obj == null) {
return;
}
getFileRefController().requestReference(obj, tL_messages_saveGif);
}
public void saveRecentSticker(final Object obj, TLRPC.Document document, boolean z) {
if (obj == null || document == null) {
return;
}
final TLRPC.TL_messages_saveRecentSticker tL_messages_saveRecentSticker = new TLRPC.TL_messages_saveRecentSticker();
tL_messages_saveRecentSticker.id = new TLRPC.TL_inputDocument();
tL_messages_saveRecentSticker.id.id = document.id;
tL_messages_saveRecentSticker.id.access_hash = document.access_hash;
tL_messages_saveRecentSticker.id.file_reference = document.file_reference;
if (tL_messages_saveRecentSticker.id.file_reference == null) {
tL_messages_saveRecentSticker.id.file_reference = new byte[0];
}
tL_messages_saveRecentSticker.unsave = false;
tL_messages_saveRecentSticker.attached = z;
getConnectionsManager().sendRequest(tL_messages_saveRecentSticker, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$saveRecentSticker$90$MessagesController(obj, tL_messages_saveRecentSticker, tLObject, tL_error);
}
});
}
public void lambda$saveRecentSticker$90$MessagesController(Object obj, TLRPC.TL_messages_saveRecentSticker tL_messages_saveRecentSticker, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null || !FileRefController.isFileRefError(tL_error.text) || obj == null) {
return;
}
getFileRefController().requestReference(obj, tL_messages_saveRecentSticker);
}
public void loadChannelParticipants(final Integer num) {
if (this.loadingFullParticipants.contains(num) || this.loadedFullParticipants.contains(num)) {
return;
}
this.loadingFullParticipants.add(num);
TLRPC.TL_channels_getParticipants tL_channels_getParticipants = new TLRPC.TL_channels_getParticipants();
tL_channels_getParticipants.channel = getInputChannel(num.intValue());
tL_channels_getParticipants.filter = new TLRPC.TL_channelParticipantsRecent();
tL_channels_getParticipants.offset = 0;
tL_channels_getParticipants.limit = 32;
getConnectionsManager().sendRequest(tL_channels_getParticipants, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadChannelParticipants$92$MessagesController(num, tLObject, tL_error);
}
});
}
public void lambda$loadChannelParticipants$92$MessagesController(final Integer num, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$91$MessagesController(tL_error, tLObject, num);
}
});
}
public void lambda$null$91$MessagesController(TLRPC.TL_error tL_error, TLObject tLObject, Integer num) {
if (tL_error == null && (tLObject instanceof TLRPC.TL_channels_channelParticipants)) {
TLRPC.TL_channels_channelParticipants tL_channels_channelParticipants = (TLRPC.TL_channels_channelParticipants) tLObject;
putUsers(tL_channels_channelParticipants.users, false);
getMessagesStorage().putUsersAndChats(tL_channels_channelParticipants.users, null, true, true);
getMessagesStorage().updateChannelUsers(num.intValue(), tL_channels_channelParticipants.participants);
this.loadedFullParticipants.add(num);
}
this.loadingFullParticipants.remove(num);
}
public void processChatInfo(final int i, final TLRPC.ChatFull chatFull, final ArrayList<TLRPC.User> arrayList, final boolean z, final boolean z2, final boolean z3, final MessageObject messageObject) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processChatInfo$93$MessagesController(z, i, z3, z2, chatFull, arrayList, messageObject);
}
});
}
public void lambda$processChatInfo$93$MessagesController(boolean z, int i, boolean z2, boolean z3, TLRPC.ChatFull chatFull, ArrayList arrayList, MessageObject messageObject) {
if (z && i > 0 && !z2) {
loadFullChat(i, 0, z3);
}
if (chatFull != null) {
if (this.fullChats.get(i) == null) {
this.fullChats.put(i, chatFull);
}
putUsers(arrayList, z);
if (chatFull.stickerset != null) {
getMediaDataController().getGroupStickerSetById(chatFull.stickerset);
}
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, Boolean.valueOf(z2), messageObject);
}
}
public void loadUserInfo(TLRPC.User user, boolean z, int i) {
getMessagesStorage().loadUserInfo(user, z, i);
}
public void processUserInfo(final TLRPC.User user, final TLRPC.UserFull userFull, final boolean z, final boolean z2, final MessageObject messageObject, final int i) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUserInfo$94$MessagesController(z, user, i, z2, userFull, messageObject);
}
});
}
public void lambda$processUserInfo$94$MessagesController(boolean z, TLRPC.User user, int i, boolean z2, TLRPC.UserFull userFull, MessageObject messageObject) {
if (z) {
loadFullUser(user, i, z2);
}
if (userFull != null) {
if (this.fullUsers.get(user.id) == null) {
this.fullUsers.put(user.id, userFull);
if (userFull.blocked) {
this.blockedUsers.put(user.id, 1);
} else {
this.blockedUsers.delete(user.id);
}
}
getNotificationCenter().postNotificationName(NotificationCenter.userFullInfoDidLoad, Integer.valueOf(user.id), userFull, messageObject);
}
}
public void updateTimerProc() {
ArrayList arrayList;
long currentTimeMillis = System.currentTimeMillis();
checkDeletingTask(false);
checkReadTasks();
if (getUserConfig().isClientActivated()) {
if (getConnectionsManager().getPauseTime() == 0 && ApplicationLoader.isScreenOn && !ApplicationLoader.mainInterfacePausedStageQueue) {
if (ApplicationLoader.mainInterfacePausedStageQueueTime != 0 && Math.abs(ApplicationLoader.mainInterfacePausedStageQueueTime - System.currentTimeMillis()) > 1000 && this.statusSettingState != 1 && (this.lastStatusUpdateTime == 0 || Math.abs(System.currentTimeMillis() - this.lastStatusUpdateTime) >= 55000 || this.offlineSent)) {
this.statusSettingState = 1;
if (this.statusRequest != 0) {
getConnectionsManager().cancelRequest(this.statusRequest, true);
}
TLRPC.TL_account_updateStatus tL_account_updateStatus = new TLRPC.TL_account_updateStatus();
tL_account_updateStatus.offline = false;
this.statusRequest = getConnectionsManager().sendRequest(tL_account_updateStatus, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateTimerProc$95$MessagesController(tLObject, tL_error);
}
});
}
} else if (this.statusSettingState != 2 && !this.offlineSent && Math.abs(System.currentTimeMillis() - getConnectionsManager().getPauseTime()) >= AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS) {
this.statusSettingState = 2;
if (this.statusRequest != 0) {
getConnectionsManager().cancelRequest(this.statusRequest, true);
}
TLRPC.TL_account_updateStatus tL_account_updateStatus2 = new TLRPC.TL_account_updateStatus();
tL_account_updateStatus2.offline = true;
this.statusRequest = getConnectionsManager().sendRequest(tL_account_updateStatus2, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateTimerProc$96$MessagesController(tLObject, tL_error);
}
});
}
if (this.updatesQueueChannels.size() != 0) {
for (int i = 0; i < this.updatesQueueChannels.size(); i++) {
int keyAt = this.updatesQueueChannels.keyAt(i);
if (this.updatesStartWaitTimeChannels.valueAt(i) + 1500 < currentTimeMillis) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("QUEUE CHANNEL " + keyAt + " UPDATES WAIT TIMEOUT - CHECK QUEUE");
}
processChannelsUpdatesQueue(keyAt, 0);
}
}
}
for (int i2 = 0; i2 < 3; i2++) {
if (getUpdatesStartTime(i2) != 0 && getUpdatesStartTime(i2) + 1500 < currentTimeMillis) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d(i2 + " QUEUE UPDATES WAIT TIMEOUT - CHECK QUEUE");
}
processUpdatesQueue(i2, 0);
}
}
}
if (Math.abs(System.currentTimeMillis() - this.lastViewsCheckTime) >= DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS) {
this.lastViewsCheckTime = System.currentTimeMillis();
if (this.channelViewsToSend.size() != 0) {
int i3 = 0;
while (i3 < this.channelViewsToSend.size()) {
final int keyAt2 = this.channelViewsToSend.keyAt(i3);
final TLRPC.TL_messages_getMessagesViews tL_messages_getMessagesViews = new TLRPC.TL_messages_getMessagesViews();
tL_messages_getMessagesViews.peer = getInputPeer(keyAt2);
tL_messages_getMessagesViews.id = this.channelViewsToSend.valueAt(i3);
tL_messages_getMessagesViews.increment = i3 == 0;
getConnectionsManager().sendRequest(tL_messages_getMessagesViews, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateTimerProc$98$MessagesController(keyAt2, tL_messages_getMessagesViews, tLObject, tL_error);
}
});
i3++;
}
this.channelViewsToSend.clear();
}
if (this.pollsToCheckSize > 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$updateTimerProc$100$MessagesController();
}
});
}
}
if (!this.onlinePrivacy.isEmpty()) {
ArrayList arrayList2 = null;
int currentTime = getConnectionsManager().getCurrentTime();
for (Map.Entry<Integer, Integer> entry : this.onlinePrivacy.entrySet()) {
if (entry.getValue().intValue() < currentTime - 30) {
if (arrayList2 == null) {
arrayList2 = new ArrayList();
}
arrayList2.add(entry.getKey());
}
}
if (arrayList2 != null) {
Iterator it = arrayList2.iterator();
while (it.hasNext()) {
this.onlinePrivacy.remove((Integer) it.next());
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$updateTimerProc$101$MessagesController();
}
});
}
}
if (this.shortPollChannels.size() != 0) {
int i4 = 0;
while (i4 < this.shortPollChannels.size()) {
int keyAt3 = this.shortPollChannels.keyAt(i4);
if (this.shortPollChannels.valueAt(i4) < System.currentTimeMillis() / 1000) {
this.shortPollChannels.delete(keyAt3);
i4--;
if (this.needShortPollChannels.indexOfKey(keyAt3) >= 0) {
getChannelDifference(keyAt3);
}
}
i4++;
}
}
if (this.shortPollOnlines.size() != 0) {
long uptimeMillis = SystemClock.uptimeMillis() / 1000;
int i5 = 0;
while (i5 < this.shortPollOnlines.size()) {
final int keyAt4 = this.shortPollOnlines.keyAt(i5);
if (this.shortPollOnlines.valueAt(i5) < uptimeMillis) {
if (this.needShortPollChannels.indexOfKey(keyAt4) >= 0) {
this.shortPollOnlines.put(keyAt4, (int) (300 + uptimeMillis));
} else {
this.shortPollOnlines.delete(keyAt4);
i5--;
}
TLRPC.TL_messages_getOnlines tL_messages_getOnlines = new TLRPC.TL_messages_getOnlines();
tL_messages_getOnlines.peer = getInputPeer(-keyAt4);
getConnectionsManager().sendRequest(tL_messages_getOnlines, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateTimerProc$103$MessagesController(keyAt4, tLObject, tL_error);
}
});
}
i5++;
}
}
if (!this.printingUsers.isEmpty() || this.lastPrintingStringCount != this.printingUsers.size()) {
ArrayList arrayList3 = new ArrayList(this.printingUsers.keySet());
int i6 = 0;
boolean z = false;
while (i6 < arrayList3.size()) {
long longValue = ((Long) arrayList3.get(i6)).longValue();
ArrayList<PrintingUser> arrayList4 = this.printingUsers.get(Long.valueOf(longValue));
if (arrayList4 != null) {
int i7 = 0;
while (i7 < arrayList4.size()) {
PrintingUser printingUser = arrayList4.get(i7);
ArrayList arrayList5 = arrayList3;
if (printingUser.lastTime + (printingUser.action instanceof TLRPC.TL_sendMessageGamePlayAction ? UIMsg.m_AppUI.MSG_RADAR_SEARCH_RETURN_RESULT : 5900) < currentTimeMillis) {
arrayList4.remove(printingUser);
i7--;
z = true;
}
i7++;
arrayList3 = arrayList5;
}
}
ArrayList arrayList6 = arrayList3;
if (arrayList4 == null || arrayList4.isEmpty()) {
this.printingUsers.remove(Long.valueOf(longValue));
arrayList = arrayList6;
arrayList.remove(i6);
i6--;
} else {
arrayList = arrayList6;
}
i6++;
arrayList3 = arrayList;
}
updatePrintingStrings();
if (z) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$updateTimerProc$104$MessagesController();
}
});
}
}
if (Theme.selectedAutoNightType == 1 && Math.abs(currentTimeMillis - lastThemeCheckTime) >= 60) {
AndroidUtilities.runOnUIThread(this.themeCheckRunnable);
lastThemeCheckTime = currentTimeMillis;
}
if (getUserConfig().savedPasswordHash != null && Math.abs(currentTimeMillis - lastPasswordCheckTime) >= 60) {
AndroidUtilities.runOnUIThread(this.passwordCheckRunnable);
lastPasswordCheckTime = currentTimeMillis;
}
if (this.lastPushRegisterSendTime != 0 && Math.abs(SystemClock.elapsedRealtime() - this.lastPushRegisterSendTime) >= 10800000) {
GcmPushListenerService.sendRegistrationToServer(SharedConfig.pushString);
}
getLocationController().update();
lambda$checkProxyInfo$107$MessagesController(false);
checkTosUpdate();
}
public void lambda$updateTimerProc$95$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
this.lastStatusUpdateTime = System.currentTimeMillis();
this.offlineSent = false;
this.statusSettingState = 0;
} else {
long j = this.lastStatusUpdateTime;
if (j != 0) {
this.lastStatusUpdateTime = j + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
}
}
this.statusRequest = 0;
}
public void lambda$updateTimerProc$96$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
this.offlineSent = true;
} else {
long j = this.lastStatusUpdateTime;
if (j != 0) {
this.lastStatusUpdateTime = j + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
}
}
this.statusRequest = 0;
}
public void lambda$updateTimerProc$98$MessagesController(int i, TLRPC.TL_messages_getMessagesViews tL_messages_getMessagesViews, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.Vector vector = (TLRPC.Vector) tLObject;
final SparseArray<SparseIntArray> sparseArray = new SparseArray<>();
SparseIntArray sparseIntArray = sparseArray.get(i);
if (sparseIntArray == null) {
sparseIntArray = new SparseIntArray();
sparseArray.put(i, sparseIntArray);
}
for (int i2 = 0; i2 < tL_messages_getMessagesViews.id.size() && i2 < vector.objects.size(); i2++) {
sparseIntArray.put(tL_messages_getMessagesViews.id.get(i2).intValue(), ((Integer) vector.objects.get(i2)).intValue());
}
getMessagesStorage().putChannelViews(sparseArray, tL_messages_getMessagesViews.peer instanceof TLRPC.TL_inputPeerChannel);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$97$MessagesController(sparseArray);
}
});
}
}
public void lambda$null$97$MessagesController(SparseArray sparseArray) {
getNotificationCenter().postNotificationName(NotificationCenter.didUpdatedMessagesViews, sparseArray);
}
public void lambda$updateTimerProc$100$MessagesController() {
long uptimeMillis = SystemClock.uptimeMillis();
int size = this.pollsToCheck.size();
int i = 0;
while (i < size) {
SparseArray<MessageObject> valueAt = this.pollsToCheck.valueAt(i);
if (valueAt != null) {
int size2 = valueAt.size();
int i2 = 0;
while (i2 < size2) {
MessageObject valueAt2 = valueAt.valueAt(i2);
if (Math.abs(uptimeMillis - valueAt2.pollLastCheckTime) < 30000) {
if (!valueAt2.pollVisibleOnScreen) {
valueAt.remove(valueAt2.getId());
size2--;
i2--;
}
} else {
valueAt2.pollLastCheckTime = uptimeMillis;
TLRPC.TL_messages_getPollResults tL_messages_getPollResults = new TLRPC.TL_messages_getPollResults();
tL_messages_getPollResults.peer = getInputPeer((int) valueAt2.getDialogId());
tL_messages_getPollResults.msg_id = valueAt2.getId();
getConnectionsManager().sendRequest(tL_messages_getPollResults, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$null$99$MessagesController(tLObject, tL_error);
}
});
}
i2++;
}
if (valueAt.size() == 0) {
LongSparseArray<SparseArray<MessageObject>> longSparseArray = this.pollsToCheck;
longSparseArray.remove(longSparseArray.keyAt(i));
size--;
i--;
}
}
i++;
}
this.pollsToCheckSize = this.pollsToCheck.size();
}
public void lambda$null$99$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void lambda$updateTimerProc$101$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
}
public void lambda$updateTimerProc$103$MessagesController(final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
final TLRPC.TL_chatOnlines tL_chatOnlines = (TLRPC.TL_chatOnlines) tLObject;
getMessagesStorage().updateChatOnlineCount(i, tL_chatOnlines.onlines);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$102$MessagesController(i, tL_chatOnlines);
}
});
}
}
public void lambda$null$102$MessagesController(int i, TLRPC.TL_chatOnlines tL_chatOnlines) {
getNotificationCenter().postNotificationName(NotificationCenter.chatOnlineCountDidLoad, Integer.valueOf(i), Integer.valueOf(tL_chatOnlines.onlines));
}
public void lambda$updateTimerProc$104$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
}
private void checkTosUpdate() {
if (this.nextTosCheckTime > getConnectionsManager().getCurrentTime() || this.checkingTosUpdate || !getUserConfig().isClientActivated()) {
return;
}
this.checkingTosUpdate = true;
getConnectionsManager().sendRequest(new TLRPC.TL_help_getTermsOfServiceUpdate(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$checkTosUpdate$106$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$checkTosUpdate$106$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
this.checkingTosUpdate = false;
if (tLObject instanceof TLRPC.TL_help_termsOfServiceUpdateEmpty) {
this.nextTosCheckTime = ((TLRPC.TL_help_termsOfServiceUpdateEmpty) tLObject).expires;
} else if (tLObject instanceof TLRPC.TL_help_termsOfServiceUpdate) {
final TLRPC.TL_help_termsOfServiceUpdate tL_help_termsOfServiceUpdate = (TLRPC.TL_help_termsOfServiceUpdate) tLObject;
this.nextTosCheckTime = tL_help_termsOfServiceUpdate.expires;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$105$MessagesController(tL_help_termsOfServiceUpdate);
}
});
} else {
this.nextTosCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
}
this.notificationsPreferences.edit().putInt("nextTosCheckTime", this.nextTosCheckTime).commit();
}
public void lambda$null$105$MessagesController(TLRPC.TL_help_termsOfServiceUpdate tL_help_termsOfServiceUpdate) {
getNotificationCenter().postNotificationName(NotificationCenter.needShowAlert, 4, tL_help_termsOfServiceUpdate.terms_of_service);
}
public void checkProxyInfo(final boolean z) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$checkProxyInfo$107$MessagesController(z);
}
});
}
public void lambda$checkProxyInfo$107$MessagesController(boolean z) {
char c;
String str;
if (z && this.checkingProxyInfo) {
this.checkingProxyInfo = false;
}
if ((!z && this.nextProxyInfoCheckTime > getConnectionsManager().getCurrentTime()) || this.checkingProxyInfo) {
return;
}
if (this.checkingProxyInfoRequestId != 0) {
getConnectionsManager().cancelRequest(this.checkingProxyInfoRequestId, true);
this.checkingProxyInfoRequestId = 0;
}
SharedPreferences globalMainSettings = getGlobalMainSettings();
boolean z2 = globalMainSettings.getBoolean("proxy_enabled", false);
final String string = globalMainSettings.getString("proxy_ip", "");
final String string2 = globalMainSettings.getString("proxy_secret", "");
if (this.proxyDialogId != 0 && (str = this.proxyDialogAddress) != null) {
if (!str.equals(string + string2)) {
c = 1;
this.lastCheckProxyId++;
if (z2 || TextUtils.isEmpty(string) || TextUtils.isEmpty(string2)) {
c = 2;
} else {
this.checkingProxyInfo = true;
final int i = this.lastCheckProxyId;
this.checkingProxyInfoRequestId = getConnectionsManager().sendRequest(new TLRPC.TL_help_getProxyData(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$checkProxyInfoInternal$112$MessagesController(i, string, string2, tLObject, tL_error);
}
});
}
if (c == 0) {
this.proxyDialogId = 0L;
this.proxyDialogAddress = null;
getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).remove("proxyDialogAddress").commit();
this.nextProxyInfoCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
if (c == 2) {
this.checkingProxyInfo = false;
if (this.checkingProxyInfoRequestId != 0) {
getConnectionsManager().cancelRequest(this.checkingProxyInfoRequestId, true);
this.checkingProxyInfoRequestId = 0;
}
}
AndroidUtilities.runOnUIThread(new $$Lambda$MessagesController$WtsUhQjlW6lBfZ38AQy9EpI5Kc(this));
return;
}
return;
}
}
c = 0;
this.lastCheckProxyId++;
if (z2) {
}
c = 2;
if (c == 0) {
}
}
public void lambda$checkProxyInfoInternal$112$MessagesController(final int i, String str, String str2, TLObject tLObject, TLRPC.TL_error tL_error) {
long j;
final long j2;
if (i != this.lastCheckProxyId) {
return;
}
boolean z = true;
if (tLObject instanceof TLRPC.TL_help_proxyDataEmpty) {
this.nextProxyInfoCheckTime = ((TLRPC.TL_help_proxyDataEmpty) tLObject).expires;
} else if (tLObject instanceof TLRPC.TL_help_proxyDataPromo) {
final TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo = (TLRPC.TL_help_proxyDataPromo) tLObject;
if (tL_help_proxyDataPromo.peer.user_id != 0) {
j = tL_help_proxyDataPromo.peer.user_id;
} else {
if (tL_help_proxyDataPromo.peer.chat_id != 0) {
j = -tL_help_proxyDataPromo.peer.chat_id;
int i2 = 0;
while (true) {
if (i2 >= tL_help_proxyDataPromo.chats.size()) {
break;
}
TLRPC.Chat chat = tL_help_proxyDataPromo.chats.get(i2);
if (chat.id != tL_help_proxyDataPromo.peer.chat_id) {
i2++;
} else if (!chat.kicked) {
}
}
z = false;
} else {
j = -tL_help_proxyDataPromo.peer.channel_id;
int i3 = 0;
while (true) {
if (i3 >= tL_help_proxyDataPromo.chats.size()) {
break;
}
TLRPC.Chat chat2 = tL_help_proxyDataPromo.chats.get(i3);
if (chat2.id != tL_help_proxyDataPromo.peer.channel_id) {
i3++;
} else if (!chat2.kicked) {
}
}
}
j2 = j;
this.proxyDialogId = j2;
this.proxyDialogAddress = str + str2;
getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).putString("proxyDialogAddress", this.proxyDialogAddress).commit();
this.nextProxyInfoCheckTime = tL_help_proxyDataPromo.expires;
if (!z) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$111$MessagesController(j2, tL_help_proxyDataPromo, i);
}
});
}
}
j2 = j;
z = false;
this.proxyDialogId = j2;
this.proxyDialogAddress = str + str2;
getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).putString("proxyDialogAddress", this.proxyDialogAddress).commit();
this.nextProxyInfoCheckTime = tL_help_proxyDataPromo.expires;
if (!z) {
}
} else {
this.nextProxyInfoCheckTime = getConnectionsManager().getCurrentTime() + CacheConstants.HOUR;
}
if (z) {
this.proxyDialogId = 0L;
getGlobalMainSettings().edit().putLong("proxy_dialog", this.proxyDialogId).remove("proxyDialogAddress").commit();
this.checkingProxyInfoRequestId = 0;
this.checkingProxyInfo = false;
AndroidUtilities.runOnUIThread(new $$Lambda$MessagesController$WtsUhQjlW6lBfZ38AQy9EpI5Kc(this));
}
}
public void lambda$null$111$MessagesController(final long j, final TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, final int i) {
TLRPC.Dialog dialog = this.proxyDialog;
if (dialog != null && j != dialog.id) {
removeProxyDialog();
}
TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
this.proxyDialog = dialog2;
if (dialog2 != null) {
this.checkingProxyInfo = false;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
return;
}
SparseArray sparseArray = new SparseArray();
SparseArray sparseArray2 = new SparseArray();
for (int i2 = 0; i2 < tL_help_proxyDataPromo.users.size(); i2++) {
TLRPC.User user = tL_help_proxyDataPromo.users.get(i2);
sparseArray.put(user.id, user);
}
for (int i3 = 0; i3 < tL_help_proxyDataPromo.chats.size(); i3++) {
TLRPC.Chat chat = tL_help_proxyDataPromo.chats.get(i3);
sparseArray2.put(chat.id, chat);
}
TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
if (tL_help_proxyDataPromo.peer.user_id != 0) {
tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerUser();
tL_inputDialogPeer.peer.user_id = tL_help_proxyDataPromo.peer.user_id;
TLRPC.User user2 = (TLRPC.User) sparseArray.get(tL_help_proxyDataPromo.peer.user_id);
if (user2 != null) {
tL_inputDialogPeer.peer.access_hash = user2.access_hash;
}
} else if (tL_help_proxyDataPromo.peer.chat_id != 0) {
tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerChat();
tL_inputDialogPeer.peer.chat_id = tL_help_proxyDataPromo.peer.chat_id;
TLRPC.Chat chat2 = (TLRPC.Chat) sparseArray2.get(tL_help_proxyDataPromo.peer.chat_id);
if (chat2 != null) {
tL_inputDialogPeer.peer.access_hash = chat2.access_hash;
}
} else {
tL_inputDialogPeer.peer = new TLRPC.TL_inputPeerChannel();
tL_inputDialogPeer.peer.channel_id = tL_help_proxyDataPromo.peer.channel_id;
TLRPC.Chat chat3 = (TLRPC.Chat) sparseArray2.get(tL_help_proxyDataPromo.peer.channel_id);
if (chat3 != null) {
tL_inputDialogPeer.peer.access_hash = chat3.access_hash;
}
}
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
this.checkingProxyInfoRequestId = getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$null$110$MessagesController(i, tL_help_proxyDataPromo, j, tLObject, tL_error);
}
});
}
public void lambda$null$110$MessagesController(int i, final TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, final long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (i != this.lastCheckProxyId) {
return;
}
this.checkingProxyInfoRequestId = 0;
final TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
if (tL_messages_peerDialogs != null && !tL_messages_peerDialogs.dialogs.isEmpty()) {
getMessagesStorage().putUsersAndChats(tL_help_proxyDataPromo.users, tL_help_proxyDataPromo.chats, true, true);
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.chats = tL_messages_peerDialogs.chats;
tL_messages_dialogs.users = tL_messages_peerDialogs.users;
tL_messages_dialogs.dialogs = tL_messages_peerDialogs.dialogs;
tL_messages_dialogs.messages = tL_messages_peerDialogs.messages;
getMessagesStorage().putDialogs(tL_messages_dialogs, 2);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$108$MessagesController(tL_help_proxyDataPromo, tL_messages_peerDialogs, j);
}
});
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$109$MessagesController();
}
});
}
this.checkingProxyInfo = false;
}
public void lambda$null$108$MessagesController(TLRPC.TL_help_proxyDataPromo tL_help_proxyDataPromo, TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, long j) {
putUsers(tL_help_proxyDataPromo.users, false);
putChats(tL_help_proxyDataPromo.chats, false);
putUsers(tL_messages_peerDialogs.users, false);
putChats(tL_messages_peerDialogs.chats, false);
TLRPC.Dialog dialog = this.proxyDialog;
if (dialog != null) {
int i = (int) dialog.id;
if (i < 0) {
TLRPC.Chat chat = getChat(Integer.valueOf(-i));
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(this.proxyDialog);
}
} else {
removeDialog(this.proxyDialog);
}
}
TLRPC.Dialog dialog2 = tL_messages_peerDialogs.dialogs.get(0);
this.proxyDialog = dialog2;
dialog2.id = j;
this.proxyDialog.folder_id = 0;
if (DialogObject.isChannel(this.proxyDialog)) {
this.channelsPts.put(-((int) this.proxyDialog.id), this.proxyDialog.pts);
}
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(this.proxyDialog.id));
if (num == null) {
num = r2;
}
this.dialogs_read_inbox_max.put(Long.valueOf(this.proxyDialog.id), Integer.valueOf(Math.max(num.intValue(), this.proxyDialog.read_inbox_max_id)));
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(this.proxyDialog.id));
this.dialogs_read_outbox_max.put(Long.valueOf(this.proxyDialog.id), Integer.valueOf(Math.max((num2 != null ? num2 : 0).intValue(), this.proxyDialog.read_outbox_max_id)));
this.dialogs_dict.put(j, this.proxyDialog);
if (!tL_messages_peerDialogs.messages.isEmpty()) {
SparseArray sparseArray = new SparseArray();
SparseArray sparseArray2 = new SparseArray();
for (int i2 = 0; i2 < tL_messages_peerDialogs.users.size(); i2++) {
TLRPC.User user = tL_messages_peerDialogs.users.get(i2);
sparseArray.put(user.id, user);
}
for (int i3 = 0; i3 < tL_messages_peerDialogs.chats.size(); i3++) {
TLRPC.Chat chat2 = tL_messages_peerDialogs.chats.get(i3);
sparseArray2.put(chat2.id, chat2);
}
MessageObject messageObject = new MessageObject(this.currentAccount, tL_messages_peerDialogs.messages.get(0), (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
this.dialogMessage.put(j, messageObject);
if (this.proxyDialog.last_message_date == 0) {
this.proxyDialog.last_message_date = messageObject.messageOwner.date;
}
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}
public void lambda$null$109$MessagesController() {
TLRPC.Dialog dialog = this.proxyDialog;
if (dialog != null) {
int i = (int) dialog.id;
if (i < 0) {
TLRPC.Chat chat = getChat(Integer.valueOf(-i));
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(this.proxyDialog);
}
} else {
removeDialog(this.proxyDialog);
}
this.proxyDialog = null;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
}
public void removeProxyDialog() {
TLRPC.Dialog dialog = this.proxyDialog;
if (dialog == null) {
return;
}
int i = (int) dialog.id;
if (i < 0) {
TLRPC.Chat chat = getChat(Integer.valueOf(-i));
if (ChatObject.isNotInChat(chat) || chat.restricted) {
removeDialog(this.proxyDialog);
}
} else {
removeDialog(this.proxyDialog);
}
this.proxyDialog = null;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public boolean isProxyDialog(long j, boolean z) {
TLRPC.Dialog dialog = this.proxyDialog;
return dialog != null && dialog.id == j && (!z || this.isLeftProxyChannel);
}
private String getUserNameForTyping(TLRPC.User user) {
if (user == null) {
return "";
}
if (user.first_name == null || user.first_name.length() <= 0) {
return (user.last_name == null || user.last_name.length() <= 0) ? "" : user.last_name;
}
return user.first_name;
}
private void updatePrintingStrings() {
final LongSparseArray longSparseArray = new LongSparseArray();
final LongSparseArray longSparseArray2 = new LongSparseArray();
for (Map.Entry<Long, ArrayList<PrintingUser>> entry : this.printingUsers.entrySet()) {
long longValue = entry.getKey().longValue();
ArrayList<PrintingUser> value = entry.getValue();
int i = (int) longValue;
if (i > 0 || i == 0 || value.size() == 1) {
PrintingUser printingUser = value.get(0);
TLRPC.User user = getUser(Integer.valueOf(printingUser.userId));
if (user != null) {
if (printingUser.action instanceof TLRPC.TL_sendMessageRecordAudioAction) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsRecordingAudio", R.string.IsRecordingAudio, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("RecordingAudio", R.string.RecordingAudio));
}
longSparseArray2.put(longValue, 1);
} else if ((printingUser.action instanceof TLRPC.TL_sendMessageRecordRoundAction) || (printingUser.action instanceof TLRPC.TL_sendMessageUploadRoundAction)) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsRecordingRound", R.string.IsRecordingRound, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("RecordingRound", R.string.RecordingRound));
}
longSparseArray2.put(longValue, 4);
} else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadAudioAction) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsSendingAudio", R.string.IsSendingAudio, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("SendingAudio", R.string.SendingAudio));
}
longSparseArray2.put(longValue, 2);
} else if ((printingUser.action instanceof TLRPC.TL_sendMessageUploadVideoAction) || (printingUser.action instanceof TLRPC.TL_sendMessageRecordVideoAction)) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsSendingVideo", R.string.IsSendingVideo, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("SendingVideoStatus", R.string.SendingVideoStatus));
}
longSparseArray2.put(longValue, 2);
} else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadDocumentAction) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsSendingFile", R.string.IsSendingFile, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("SendingFile", R.string.SendingFile));
}
longSparseArray2.put(longValue, 2);
} else if (printingUser.action instanceof TLRPC.TL_sendMessageUploadPhotoAction) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsSendingPhoto", R.string.IsSendingPhoto, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("SendingPhoto", R.string.SendingPhoto));
}
longSparseArray2.put(longValue, 2);
} else if (printingUser.action instanceof TLRPC.TL_sendMessageGamePlayAction) {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsSendingGame", R.string.IsSendingGame, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("SendingGame", R.string.SendingGame));
}
longSparseArray2.put(longValue, 3);
} else {
if (i < 0) {
longSparseArray.put(longValue, LocaleController.formatString("IsTypingGroup", R.string.IsTypingGroup, getUserNameForTyping(user)));
} else {
longSparseArray.put(longValue, LocaleController.getString("Typing", R.string.Typing));
}
longSparseArray2.put(longValue, 0);
}
}
} else {
StringBuilder sb = new StringBuilder();
Iterator<PrintingUser> it = value.iterator();
int i2 = 0;
while (it.hasNext()) {
TLRPC.User user2 = getUser(Integer.valueOf(it.next().userId));
if (user2 != null) {
if (sb.length() != 0) {
sb.append(", ");
}
sb.append(getUserNameForTyping(user2));
i2++;
}
if (i2 == 2) {
break;
}
}
if (sb.length() != 0) {
if (i2 == 1) {
longSparseArray.put(longValue, LocaleController.formatString("IsTypingGroup", R.string.IsTypingGroup, sb.toString()));
} else if (value.size() > 2) {
try {
longSparseArray.put(longValue, String.format(LocaleController.getPluralString("AndMoreTypingGroup", value.size() - 2), sb.toString(), Integer.valueOf(value.size() - 2)));
} catch (Exception unused) {
longSparseArray.put(longValue, "LOC_ERR: AndMoreTypingGroup");
}
} else {
longSparseArray.put(longValue, LocaleController.formatString("AreTypingGroup", R.string.AreTypingGroup, sb.toString()));
}
longSparseArray2.put(longValue, 0);
}
}
}
this.lastPrintingStringCount = longSparseArray.size();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$updatePrintingStrings$113$MessagesController(longSparseArray, longSparseArray2);
}
});
}
public void lambda$updatePrintingStrings$113$MessagesController(LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
this.printingStrings = longSparseArray;
this.printingStringsTypes = longSparseArray2;
}
public void cancelTyping(int i, long j) {
LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
if (longSparseArray != null) {
longSparseArray.remove(j);
}
}
public void sendTyping(final long j, final int i, int i2) {
TLRPC.Chat chat;
if (j == 0) {
return;
}
LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
if (longSparseArray == null || longSparseArray.get(j) == null) {
if (longSparseArray == null) {
longSparseArray = new LongSparseArray<>();
this.sendingTypings.put(i, longSparseArray);
}
int i3 = (int) j;
int i4 = (int) (j >> 32);
if (i3 == 0) {
if (i != 0) {
return;
}
TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i4));
if (encryptedChat.auth_key == null || encryptedChat.auth_key.length <= 1 || !(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_messages_setEncryptedTyping tL_messages_setEncryptedTyping = new TLRPC.TL_messages_setEncryptedTyping();
tL_messages_setEncryptedTyping.peer = new TLRPC.TL_inputEncryptedChat();
tL_messages_setEncryptedTyping.peer.chat_id = encryptedChat.id;
tL_messages_setEncryptedTyping.peer.access_hash = encryptedChat.access_hash;
tL_messages_setEncryptedTyping.typing = true;
longSparseArray.put(j, true);
int sendRequest = getConnectionsManager().sendRequest(tL_messages_setEncryptedTyping, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$sendTyping$117$MessagesController(i, j, tLObject, tL_error);
}
}, 2);
if (i2 != 0) {
getConnectionsManager().bindRequestToGuid(sendRequest, i2);
return;
}
return;
}
TLRPC.TL_messages_setTyping tL_messages_setTyping = new TLRPC.TL_messages_setTyping();
tL_messages_setTyping.peer = getInputPeer(i3);
if ((!(tL_messages_setTyping.peer instanceof TLRPC.TL_inputPeerChannel) || ((chat = getChat(Integer.valueOf(tL_messages_setTyping.peer.channel_id))) != null && chat.megagroup)) && tL_messages_setTyping.peer != null) {
if (i == 0) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageTypingAction();
} else if (i == 1) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageRecordAudioAction();
} else if (i == 2) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageCancelAction();
} else if (i == 3) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadDocumentAction();
} else if (i == 4) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadPhotoAction();
} else if (i == 5) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadVideoAction();
} else if (i == 6) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageGamePlayAction();
} else if (i == 7) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageRecordRoundAction();
} else if (i == 8) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadRoundAction();
} else if (i == 9) {
tL_messages_setTyping.action = new TLRPC.TL_sendMessageUploadAudioAction();
}
longSparseArray.put(j, true);
int sendRequest2 = getConnectionsManager().sendRequest(tL_messages_setTyping, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$sendTyping$115$MessagesController(i, j, tLObject, tL_error);
}
}, 2);
if (i2 != 0) {
getConnectionsManager().bindRequestToGuid(sendRequest2, i2);
}
}
}
}
public void lambda$sendTyping$115$MessagesController(final int i, final long j, TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$114$MessagesController(i, j);
}
});
}
public void lambda$null$114$MessagesController(int i, long j) {
LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
if (longSparseArray != null) {
longSparseArray.remove(j);
}
}
public void lambda$sendTyping$117$MessagesController(final int i, final long j, TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$116$MessagesController(i, j);
}
});
}
public void lambda$null$116$MessagesController(int i, long j) {
LongSparseArray<Boolean> longSparseArray = this.sendingTypings.get(i);
if (longSparseArray != null) {
longSparseArray.remove(j);
}
}
public void removeDeletedMessagesFromArray(long j, ArrayList<TLRPC.Message> arrayList) {
int i = 0;
int intValue = this.deletedHistory.get(j, 0).intValue();
if (intValue == 0) {
return;
}
int size = arrayList.size();
while (i < size) {
if (arrayList.get(i).id <= intValue) {
arrayList.remove(i);
i--;
size--;
}
i++;
}
}
public void loadMessages(long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, boolean z2, boolean z3, int i8) {
loadMessages(j, i, i2, i3, z, i4, i5, i6, i7, z2, z3, i8, 0, 0, 0, false, 0);
}
public void loadMessages(long j, int i, int i2, int i3, boolean z, int i4, int i5, int i6, int i7, boolean z2, boolean z3, int i8, int i9, int i10, int i11, boolean z4, int i12) {
loadMessagesInternal(j, i, i2, i3, z, i4, i5, i6, i7, z2, z3, i8, i9, i10, i11, z4, i12, true);
}
private void loadMessagesInternal(final long j, final int i, final int i2, final int i3, boolean z, final int i4, final int i5, final int i6, final int i7, final boolean z2, boolean z3, final int i8, final int i9, final int i10, final int i11, final boolean z4, final int i12, boolean z5) {
int i13 = (int) j;
if (z || i13 == 0) {
getMessagesStorage().getMessages(j, i, i2, i3, i4, i5, i6, z2, z3, i8);
return;
}
if (z3) {
TLRPC.TL_messages_getScheduledHistory tL_messages_getScheduledHistory = new TLRPC.TL_messages_getScheduledHistory();
tL_messages_getScheduledHistory.peer = getInputPeer(i13);
tL_messages_getScheduledHistory.hash = i4;
ConnectionsManager.getInstance(this.currentAccount).bindRequestToGuid(ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_getScheduledHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadMessagesInternal$118$MessagesController(i2, i3, j, i, i5, i9, i7, i10, i11, i6, z2, i8, z4, i12, tLObject, tL_error);
}
}), i5);
return;
}
if (z5 && ((i6 == 3 || i6 == 2) && i7 == 0)) {
TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
TLRPC.InputPeer inputPeer = getInputPeer(i13);
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer;
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadMessagesInternal$119$MessagesController(j, i, i2, i3, i4, i5, i6, z2, i8, i9, i11, z4, tLObject, tL_error);
}
});
return;
}
TLRPC.TL_messages_getHistory tL_messages_getHistory = new TLRPC.TL_messages_getHistory();
tL_messages_getHistory.peer = getInputPeer(i13);
if (i6 == 4) {
tL_messages_getHistory.add_offset = (-i) + 5;
} else if (i6 == 3) {
tL_messages_getHistory.add_offset = (-i) / 2;
} else if (i6 == 1) {
tL_messages_getHistory.add_offset = (-i) - 1;
} else if (i6 == 2 && i2 != 0) {
tL_messages_getHistory.add_offset = (-i) + 6;
} else if (i13 < 0 && i2 != 0 && ChatObject.isChannel(getChat(Integer.valueOf(-i13)))) {
tL_messages_getHistory.add_offset = -1;
tL_messages_getHistory.limit++;
}
tL_messages_getHistory.limit = i;
tL_messages_getHistory.offset_id = i2;
tL_messages_getHistory.offset_date = i3;
getConnectionsManager().bindRequestToGuid(getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadMessagesInternal$120$MessagesController(j, i, i2, i3, i5, i9, i7, i10, i11, i6, z2, i8, z4, i12, tLObject, tL_error);
}
}), i5);
}
public void lambda$loadMessagesInternal$118$MessagesController(int i, int i2, long j, int i3, int i4, int i5, int i6, int i7, int i8, int i9, boolean z, int i10, boolean z2, int i11, TLObject tLObject, TLRPC.TL_error tL_error) {
int i12;
if (tLObject != null) {
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
if (messages_messages instanceof TLRPC.TL_messages_messagesNotModified) {
return;
}
if (i2 == 0 || messages_messages.messages.isEmpty()) {
i12 = i;
} else {
int i13 = messages_messages.messages.get(messages_messages.messages.size() - 1).id;
int size = messages_messages.messages.size() - 1;
while (true) {
if (size < 0) {
break;
}
TLRPC.Message message = messages_messages.messages.get(size);
if (message.date > i2) {
i13 = message.id;
break;
}
size--;
}
i12 = i13;
}
processLoadedMessages(messages_messages, j, i3, i12, i2, false, i4, i5, i6, i7, i8, i9, z, false, true, i10, z2, i11);
}
}
public void lambda$loadMessagesInternal$119$MessagesController(long j, int i, int i2, int i3, int i4, int i5, int i6, boolean z, int i7, int i8, int i9, boolean z2, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
if (!tL_messages_peerDialogs.dialogs.isEmpty()) {
TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(0);
if (dialog.top_message != 0) {
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.chats = tL_messages_peerDialogs.chats;
tL_messages_dialogs.users = tL_messages_peerDialogs.users;
tL_messages_dialogs.dialogs = tL_messages_peerDialogs.dialogs;
tL_messages_dialogs.messages = tL_messages_peerDialogs.messages;
getMessagesStorage().putDialogs(tL_messages_dialogs, 0);
}
loadMessagesInternal(j, i, i2, i3, false, i4, i5, i6, dialog.top_message, z, false, i7, i8, dialog.unread_count, i9, z2, dialog.unread_mentions_count, false);
return;
}
loadMessagesInternal(j, i, i2, i3, false, i4, i5, i6, -1, z, false, i7, i8, tL_messages_peerDialogs.state.unread_count, i9, z2, 0, false);
}
}
public void lambda$loadMessagesInternal$120$MessagesController(long j, int i, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, boolean z, int i10, boolean z2, int i11, TLObject tLObject, TLRPC.TL_error tL_error) {
int i12;
if (tLObject != null) {
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
removeDeletedMessagesFromArray(j, messages_messages.messages);
if (messages_messages.messages.size() > i) {
messages_messages.messages.remove(0);
}
if (i3 == 0 || messages_messages.messages.isEmpty()) {
i12 = i2;
} else {
int i13 = messages_messages.messages.get(messages_messages.messages.size() - 1).id;
int size = messages_messages.messages.size() - 1;
while (true) {
if (size < 0) {
break;
}
TLRPC.Message message = messages_messages.messages.get(size);
if (message.date > i3) {
i13 = message.id;
break;
}
size--;
}
i12 = i13;
}
processLoadedMessages(messages_messages, j, i, i12, i3, false, i4, i5, i6, i7, i8, i9, z, false, false, i10, z2, i11);
}
}
public void reloadWebPages(final long j, HashMap<String, ArrayList<MessageObject>> hashMap, final boolean z) {
final HashMap<String, ArrayList<MessageObject>> hashMap2 = z ? this.reloadingScheduledWebpages : this.reloadingWebpages;
final LongSparseArray<ArrayList<MessageObject>> longSparseArray = z ? this.reloadingScheduledWebpagesPending : this.reloadingWebpagesPending;
for (Map.Entry<String, ArrayList<MessageObject>> entry : hashMap.entrySet()) {
final String key = entry.getKey();
ArrayList<MessageObject> value = entry.getValue();
ArrayList<MessageObject> arrayList = hashMap2.get(key);
if (arrayList == null) {
arrayList = new ArrayList<>();
hashMap2.put(key, arrayList);
}
arrayList.addAll(value);
TLRPC.TL_messages_getWebPagePreview tL_messages_getWebPagePreview = new TLRPC.TL_messages_getWebPagePreview();
tL_messages_getWebPagePreview.message = key;
getConnectionsManager().sendRequest(tL_messages_getWebPagePreview, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$reloadWebPages$122$MessagesController(hashMap2, key, longSparseArray, j, z, tLObject, tL_error);
}
});
}
}
public void lambda$reloadWebPages$122$MessagesController(final HashMap hashMap, final String str, final LongSparseArray longSparseArray, final long j, final boolean z, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$121$MessagesController(hashMap, str, tLObject, longSparseArray, j, z);
}
});
}
public void lambda$null$121$MessagesController(HashMap hashMap, String str, TLObject tLObject, LongSparseArray longSparseArray, long j, boolean z) {
ArrayList arrayList = (ArrayList) hashMap.remove(str);
if (arrayList == null) {
return;
}
TLRPC.TL_messages_messages tL_messages_messages = new TLRPC.TL_messages_messages();
if (!(tLObject instanceof TLRPC.TL_messageMediaWebPage)) {
for (int i = 0; i < arrayList.size(); i++) {
((MessageObject) arrayList.get(i)).messageOwner.media.webpage = new TLRPC.TL_webPageEmpty();
tL_messages_messages.messages.add(((MessageObject) arrayList.get(i)).messageOwner);
}
} else {
TLRPC.TL_messageMediaWebPage tL_messageMediaWebPage = (TLRPC.TL_messageMediaWebPage) tLObject;
if ((tL_messageMediaWebPage.webpage instanceof TLRPC.TL_webPage) || (tL_messageMediaWebPage.webpage instanceof TLRPC.TL_webPageEmpty)) {
for (int i2 = 0; i2 < arrayList.size(); i2++) {
((MessageObject) arrayList.get(i2)).messageOwner.media.webpage = tL_messageMediaWebPage.webpage;
if (i2 == 0) {
ImageLoader.saveMessageThumbs(((MessageObject) arrayList.get(i2)).messageOwner);
}
tL_messages_messages.messages.add(((MessageObject) arrayList.get(i2)).messageOwner);
}
} else {
longSparseArray.put(tL_messageMediaWebPage.webpage.id, arrayList);
}
}
if (tL_messages_messages.messages.isEmpty()) {
return;
}
getMessagesStorage().putMessages((TLRPC.messages_Messages) tL_messages_messages, j, -2, 0, false, z);
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList);
}
public void processLoadedMessages(final TLRPC.messages_Messages messages_messages, final long j, final int i, final int i2, final int i3, final boolean z, final int i4, final int i5, final int i6, final int i7, final int i8, final int i9, final boolean z2, final boolean z3, final boolean z4, final int i10, final boolean z5, final int i11) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processLoadedMessages$125$MessagesController(messages_messages, j, z4, z, i, i9, z5, i5, i2, i3, i4, i6, z2, i10, i7, i8, i11, z3);
}
});
}
public void lambda$processLoadedMessages$125$MessagesController(final TLRPC.messages_Messages messages_messages, final long j, final boolean z, final boolean z2, final int i, final int i2, final boolean z3, final int i3, final int i4, final int i5, final int i6, final int i7, final boolean z4, final int i8, final int i9, final int i10, final int i11, final boolean z5) {
boolean z6;
boolean z7;
TLRPC.messages_Messages messages_messages2;
int i12;
int i13;
int size;
long j2;
boolean z8;
int i14;
boolean z9;
TLRPC.User user;
int i15;
boolean z10;
if (messages_messages instanceof TLRPC.TL_messages_channelMessages) {
int i16 = -((int) j);
if (!z && this.channelsPts.get(i16) == 0 && getMessagesStorage().getChannelPtsSync(i16) == 0) {
this.channelsPts.put(i16, messages_messages.pts);
if (this.needShortPollChannels.indexOfKey(i16) >= 0 && this.shortPollChannels.indexOfKey(i16) < 0) {
getChannelDifference(i16, 2, 0L, null);
} else {
getChannelDifference(i16);
}
z10 = true;
} else {
z10 = false;
}
int i17 = 0;
while (true) {
if (i17 >= messages_messages.chats.size()) {
z7 = z10;
z6 = false;
break;
}
TLRPC.Chat chat = messages_messages.chats.get(i17);
if (chat.id == i16) {
z7 = z10;
z6 = chat.megagroup;
break;
}
i17++;
}
} else {
z6 = false;
z7 = false;
}
int i18 = (int) j;
int i19 = (int) (j >> 32);
if (!z2) {
ImageLoader.saveMessagesThumbs(messages_messages.messages);
}
if (i19 != 1 && i18 != 0 && z2) {
long j3 = 0;
if (messages_messages.messages.size() == 0 || (z && SystemClock.uptimeMillis() - this.lastScheduledServerQueryTime.get(j, 0L).longValue() > DefaultLoadErrorHandlingPolicy.DEFAULT_TRACK_BLACKLIST_MS)) {
if (z) {
this.lastScheduledServerQueryTime.put(j, Long.valueOf(SystemClock.uptimeMillis()));
int size2 = messages_messages.messages.size();
for (int i20 = 0; i20 < size2; i20++) {
if (messages_messages.messages.get(i20).id >= 0) {
j3 = (((((((((((j3 * 20261) + 2147483648L) + r4.id) % 2147483648L) * 20261) + 2147483648L) + r4.edit_date) % 2147483648L) * 20261) + 2147483648L) + r4.date) % 2147483648L;
}
}
i15 = ((int) j3) - 1;
} else {
i15 = 0;
}
final int i21 = i15;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$123$MessagesController(j, i, i2, z3, i3, i4, i5, i21, i6, i7, z4, z, i8, i9, i10, i11);
}
});
messages_messages2 = messages_messages;
if (messages_messages2.messages.isEmpty()) {
return;
}
SparseArray sparseArray = new SparseArray();
SparseArray sparseArray2 = new SparseArray();
for (i12 = 0; i12 < messages_messages2.users.size(); i12++) {
TLRPC.User user2 = messages_messages2.users.get(i12);
sparseArray.put(user2.id, user2);
}
for (i13 = 0; i13 < messages_messages2.chats.size(); i13++) {
TLRPC.Chat chat2 = messages_messages2.chats.get(i13);
sparseArray2.put(chat2.id, chat2);
}
size = messages_messages2.messages.size();
MessagesController messagesController = this;
if (z2) {
Integer num = messagesController.dialogs_read_inbox_max.get(Long.valueOf(j));
if (num == null) {
j2 = j;
z9 = false;
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j2));
messagesController.dialogs_read_inbox_max.put(Long.valueOf(j), num);
} else {
j2 = j;
z9 = false;
}
Integer num2 = messagesController.dialogs_read_outbox_max.get(Long.valueOf(j));
if (num2 == null) {
num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j2));
messagesController.dialogs_read_outbox_max.put(Long.valueOf(j), num2);
}
for (int i22 = 0; i22 < size; i22++) {
TLRPC.Message message = messages_messages2.messages.get(i22);
if (z6) {
message.flags |= Integer.MIN_VALUE;
}
if (!z) {
if ((message.action instanceof TLRPC.TL_messageActionChatDeleteUser) && (user = (TLRPC.User) sparseArray.get(message.action.user_id)) != null && user.bot) {
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
message.flags |= 64;
}
if ((message.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message.action instanceof TLRPC.TL_messageActionChannelCreate)) {
message.unread = z9;
message.media_unread = z9;
} else {
message.unread = (message.out ? num2 : num).intValue() < message.id;
}
}
}
z8 = z;
getMessagesStorage().putMessages(messages_messages, j, i2, i4, z7, z);
} else {
j2 = j;
z8 = z;
}
final ArrayList arrayList = new ArrayList();
final ArrayList arrayList2 = new ArrayList();
HashMap hashMap = new HashMap();
i14 = 0;
while (i14 < size) {
TLRPC.Message message2 = messages_messages2.messages.get(i14);
message2.dialog_id = j2;
int i23 = messagesController.currentAccount;
int i24 = i14;
HashMap hashMap2 = hashMap;
MessageObject messageObject = new MessageObject(i23, message2, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, true);
messageObject.scheduled = z8;
arrayList.add(messageObject);
if (z2) {
if (message2.legacy && message2.layer < 105) {
arrayList2.add(Integer.valueOf(message2.id));
} else if ((message2.media instanceof TLRPC.TL_messageMediaUnsupported) && message2.media.bytes != null) {
if (message2.media.bytes.length != 0) {
if (message2.media.bytes.length == 1) {
}
if (message2.media instanceof TLRPC.TL_messageMediaWebPage) {
if ((message2.media.webpage instanceof TLRPC.TL_webPagePending) && message2.media.webpage.date <= getConnectionsManager().getCurrentTime()) {
arrayList2.add(Integer.valueOf(message2.id));
} else if (message2.media.webpage instanceof TLRPC.TL_webPageUrlPending) {
ArrayList arrayList3 = (ArrayList) hashMap2.get(message2.media.webpage.url);
if (arrayList3 == null) {
arrayList3 = new ArrayList();
hashMap2.put(message2.media.webpage.url, arrayList3);
}
arrayList3.add(messageObject);
}
}
}
arrayList2.add(Integer.valueOf(message2.id));
if (message2.media instanceof TLRPC.TL_messageMediaWebPage) {
}
}
if (message2.media instanceof TLRPC.TL_messageMediaWebPage) {
}
}
i14 = i24 + 1;
hashMap = hashMap2;
messagesController = this;
}
final HashMap hashMap3 = hashMap;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$124$MessagesController(messages_messages, z2, z, z3, i2, i3, i, j, arrayList, i7, i9, i10, z5, i6, i8, i4, i11, arrayList2, hashMap3);
}
});
}
}
messages_messages2 = messages_messages;
SparseArray sparseArray3 = new SparseArray();
SparseArray sparseArray22 = new SparseArray();
while (i12 < messages_messages2.users.size()) {
}
while (i13 < messages_messages2.chats.size()) {
}
size = messages_messages2.messages.size();
MessagesController messagesController2 = this;
if (z2) {
}
final ArrayList arrayList4 = new ArrayList();
final ArrayList arrayList22 = new ArrayList();
HashMap hashMap4 = new HashMap();
i14 = 0;
while (i14 < size) {
}
final HashMap hashMap32 = hashMap4;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$124$MessagesController(messages_messages, z2, z, z3, i2, i3, i, j, arrayList4, i7, i9, i10, z5, i6, i8, i4, i11, arrayList22, hashMap32);
}
});
}
public void lambda$null$123$MessagesController(long j, int i, int i2, boolean z, int i3, int i4, int i5, int i6, int i7, int i8, boolean z2, boolean z3, int i9, int i10, int i11, int i12) {
loadMessages(j, i, (i2 == 2 && z) ? i3 : i4, i5, false, i6, i7, i2, i8, z2, z3, i9, i3, i10, i11, z, i12);
}
public void lambda$null$124$MessagesController(TLRPC.messages_Messages messages_messages, boolean z, boolean z2, boolean z3, int i, int i2, int i3, long j, ArrayList arrayList, int i4, int i5, int i6, boolean z4, int i7, int i8, int i9, int i10, ArrayList arrayList2, HashMap hashMap) {
int i11;
int i12;
putUsers(messages_messages.users, z);
putChats(messages_messages.chats, z);
if (z2) {
i12 = 0;
} else {
if (z3 && i == 2) {
i12 = Integer.MAX_VALUE;
for (int i13 = 0; i13 < messages_messages.messages.size(); i13++) {
TLRPC.Message message = messages_messages.messages.get(i13);
if ((!message.out || message.from_scheduled) && message.id > i2 && message.id < i12) {
i12 = message.id;
}
}
i11 = i2;
} else {
i11 = i2;
i12 = Integer.MAX_VALUE;
}
if (i12 == Integer.MAX_VALUE) {
i12 = i11;
}
}
if (z2 && i3 == 1) {
getNotificationCenter().postNotificationName(NotificationCenter.scheduledMessagesUpdated, Long.valueOf(j), Integer.valueOf(arrayList.size()));
}
getNotificationCenter().postNotificationName(NotificationCenter.messagesDidLoad, Long.valueOf(j), Integer.valueOf(i3), arrayList, Boolean.valueOf(z), Integer.valueOf(i12), Integer.valueOf(i4), Integer.valueOf(i5), Integer.valueOf(i6), Integer.valueOf(i), Boolean.valueOf(z4), Integer.valueOf(i7), Integer.valueOf(i8), Integer.valueOf(i9), Integer.valueOf(i10), Boolean.valueOf(z2));
if (!arrayList2.isEmpty()) {
reloadMessages(arrayList2, j, z2);
}
if (hashMap.isEmpty()) {
return;
}
reloadWebPages(j, hashMap, z2);
}
public void loadHintDialogs() {
if (!this.hintDialogs.isEmpty() || TextUtils.isEmpty(this.installReferer)) {
return;
}
TLRPC.TL_help_getRecentMeUrls tL_help_getRecentMeUrls = new TLRPC.TL_help_getRecentMeUrls();
tL_help_getRecentMeUrls.referer = this.installReferer;
getConnectionsManager().sendRequest(tL_help_getRecentMeUrls, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadHintDialogs$127$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$loadHintDialogs$127$MessagesController(final TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$126$MessagesController(tLObject);
}
});
}
}
public void lambda$null$126$MessagesController(TLObject tLObject) {
TLRPC.TL_help_recentMeUrls tL_help_recentMeUrls = (TLRPC.TL_help_recentMeUrls) tLObject;
putUsers(tL_help_recentMeUrls.users, false);
putChats(tL_help_recentMeUrls.chats, false);
this.hintDialogs.clear();
this.hintDialogs.addAll(tL_help_recentMeUrls.urls);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
private TLRPC.TL_dialogFolder ensureFolderDialogExists(int i, boolean[] zArr) {
if (i == 0) {
return null;
}
long makeFolderDialogId = DialogObject.makeFolderDialogId(i);
TLRPC.Dialog dialog = this.dialogs_dict.get(makeFolderDialogId);
if (dialog instanceof TLRPC.TL_dialogFolder) {
if (zArr != null) {
zArr[0] = false;
}
return (TLRPC.TL_dialogFolder) dialog;
}
if (zArr != null) {
zArr[0] = true;
}
TLRPC.TL_dialogFolder tL_dialogFolder = new TLRPC.TL_dialogFolder();
tL_dialogFolder.id = makeFolderDialogId;
tL_dialogFolder.peer = new TLRPC.TL_peerUser();
tL_dialogFolder.folder = new TLRPC.TL_folder();
tL_dialogFolder.folder.id = i;
tL_dialogFolder.folder.title = LocaleController.getString("ArchivedChats", R.string.ArchivedChats);
tL_dialogFolder.pinned = true;
int i2 = 0;
for (int i3 = 0; i3 < this.allDialogs.size(); i3++) {
TLRPC.Dialog dialog2 = this.allDialogs.get(i3);
if (!dialog2.pinned) {
break;
}
i2 = Math.max(dialog2.pinnedNum, i2);
}
tL_dialogFolder.pinnedNum = i2 + 1;
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.dialogs.add(tL_dialogFolder);
getMessagesStorage().putDialogs(tL_messages_dialogs, 1);
this.dialogs_dict.put(makeFolderDialogId, tL_dialogFolder);
this.allDialogs.add(0, tL_dialogFolder);
return tL_dialogFolder;
}
public void lambda$onFolderEmpty$128$MessagesController(int i) {
long makeFolderDialogId = DialogObject.makeFolderDialogId(i);
TLRPC.Dialog dialog = this.dialogs_dict.get(makeFolderDialogId);
if (dialog == null) {
return;
}
this.dialogs_dict.remove(makeFolderDialogId);
this.allDialogs.remove(dialog);
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.folderBecomeEmpty, Integer.valueOf(i));
}
public void onFolderEmpty(final int i) {
if (getUserConfig().getDialogLoadOffsets(i)[0] == Integer.MAX_VALUE) {
lambda$onFolderEmpty$128$MessagesController(i);
} else {
loadDialogs(i, 0, 10, false, new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$onFolderEmpty$128$MessagesController(i);
}
});
}
}
public void checkIfFolderEmpty(int i) {
if (i == 0) {
return;
}
getMessagesStorage().checkIfFolderEmpty(i);
}
public int addDialogToFolder(long j, int i, int i2, long j2) {
ArrayList<Long> arrayList = new ArrayList<>(1);
arrayList.add(Long.valueOf(j));
return addDialogToFolder(arrayList, i, i2, null, j2);
}
public int addDialogToFolder(ArrayList<Long> arrayList, int i, int i2, ArrayList<TLRPC.TL_inputFolderPeer> arrayList2, long j) {
boolean[] zArr;
final long j2;
NativeByteBuffer nativeByteBuffer;
long createPendingTask;
TLRPC.Dialog dialog;
int i3;
int i4;
int i5;
TLRPC.TL_folders_editPeerFolders tL_folders_editPeerFolders = new TLRPC.TL_folders_editPeerFolders();
int i6 = 1;
if (j == 0) {
int clientUserId = getUserConfig().getClientUserId();
int size = arrayList.size();
boolean z = false;
boolean[] zArr2 = null;
int i7 = 0;
int i8 = 0;
while (i7 < size) {
long longValue = arrayList.get(i7).longValue();
if ((DialogObject.isPeerDialogId(longValue) || DialogObject.isSecretDialogId(longValue)) && !((i == i6 && (longValue == clientUserId || longValue == 777000 || isProxyDialog(longValue, false))) || (dialog = this.dialogs_dict.get(longValue)) == null)) {
dialog.folder_id = i;
if (i2 > 0) {
i3 = 1;
dialog.pinned = true;
dialog.pinnedNum = i2;
} else {
i3 = 1;
dialog.pinned = false;
dialog.pinnedNum = 0;
}
if (zArr2 == null) {
zArr2 = new boolean[i3];
ensureFolderDialogExists(i, zArr2);
}
boolean[] zArr3 = zArr2;
if (DialogObject.isSecretDialogId(longValue)) {
i4 = i7;
i5 = size;
getMessagesStorage().setDialogsFolderId(null, null, longValue, i);
} else {
i4 = i7;
i5 = size;
TLRPC.TL_inputFolderPeer tL_inputFolderPeer = new TLRPC.TL_inputFolderPeer();
tL_inputFolderPeer.folder_id = i;
tL_inputFolderPeer.peer = getInputPeer((int) longValue);
tL_folders_editPeerFolders.folder_peers.add(tL_inputFolderPeer);
i8 += tL_inputFolderPeer.getObjectSize();
}
zArr2 = zArr3;
z = true;
} else {
i4 = i7;
i5 = size;
}
i7 = i4 + 1;
size = i5;
i6 = 1;
}
if (!z) {
return 0;
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
if (i8 != 0) {
try {
nativeByteBuffer = new NativeByteBuffer(i8 + 12);
} catch (Exception e) {
e = e;
nativeByteBuffer = null;
}
try {
nativeByteBuffer.writeInt32(17);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeInt32(tL_folders_editPeerFolders.folder_peers.size());
int size2 = tL_folders_editPeerFolders.folder_peers.size();
for (int i9 = 0; i9 < size2; i9++) {
tL_folders_editPeerFolders.folder_peers.get(i9).serializeToStream(nativeByteBuffer);
}
} catch (Exception e2) {
e = e2;
FileLog.e(e);
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
zArr = zArr2;
j2 = createPendingTask;
if (!tL_folders_editPeerFolders.folder_peers.isEmpty()) {
}
if (zArr != null) {
}
}
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
} else {
createPendingTask = 0;
}
zArr = zArr2;
j2 = createPendingTask;
} else {
tL_folders_editPeerFolders.folder_peers = arrayList2;
zArr = null;
j2 = j;
}
if (!tL_folders_editPeerFolders.folder_peers.isEmpty()) {
getConnectionsManager().sendRequest(tL_folders_editPeerFolders, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$addDialogToFolder$129$MessagesController(j2, tLObject, tL_error);
}
});
getMessagesStorage().setDialogsFolderId(null, tL_folders_editPeerFolders.folder_peers, 0L, i);
}
if (zArr != null) {
return 0;
}
return zArr[0] ? 2 : 1;
}
public void lambda$addDialogToFolder$129$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
processUpdates((TLRPC.Updates) tLObject, false);
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void loadDialogs(int i, int i2, int i3, boolean z) {
loadDialogs(i, i2, i3, z, null);
}
public void loadDialogs(final int i, int i2, final int i3, boolean z, final Runnable runnable) {
MessageObject messageObject;
int i4;
int i5;
if (this.loadingDialogs.get(i) || this.resetingDialogs) {
return;
}
boolean z2 = true;
this.loadingDialogs.put(i, true);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
if (z) {
getMessagesStorage().getDialogs(i, i2 != 0 ? this.nextDialogsCacheOffset.get(i, 0) : 0, i3);
return;
}
TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
tL_messages_getDialogs.limit = i3;
tL_messages_getDialogs.exclude_pinned = true;
if (i != 0) {
tL_messages_getDialogs.flags |= 2;
tL_messages_getDialogs.folder_id = i;
}
int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i);
if (dialogLoadOffsets[0] != -1) {
if (dialogLoadOffsets[0] == Integer.MAX_VALUE) {
this.dialogsEndReached.put(i, true);
this.serverDialogsEndReached.put(i, true);
this.loadingDialogs.put(i, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
return;
}
tL_messages_getDialogs.offset_id = dialogLoadOffsets[0];
tL_messages_getDialogs.offset_date = dialogLoadOffsets[1];
if (tL_messages_getDialogs.offset_id == 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
} else {
if (dialogLoadOffsets[4] != 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChannel();
tL_messages_getDialogs.offset_peer.channel_id = dialogLoadOffsets[4];
} else if (dialogLoadOffsets[2] != 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerUser();
tL_messages_getDialogs.offset_peer.user_id = dialogLoadOffsets[2];
} else {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChat();
tL_messages_getDialogs.offset_peer.chat_id = dialogLoadOffsets[3];
}
tL_messages_getDialogs.offset_peer.access_hash = (dialogLoadOffsets[5] << 32) | dialogLoadOffsets[5];
}
} else {
ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
int size = dialogs.size() - 1;
while (true) {
if (size < 0) {
z2 = false;
break;
}
TLRPC.Dialog dialog = dialogs.get(size);
if (!dialog.pinned) {
int i6 = (int) dialog.id;
int i7 = (int) (dialog.id >> 32);
if (i6 != 0 && i7 != 1 && dialog.top_message > 0 && (messageObject = this.dialogMessage.get(dialog.id)) != null && messageObject.getId() > 0) {
tL_messages_getDialogs.offset_date = messageObject.messageOwner.date;
tL_messages_getDialogs.offset_id = messageObject.messageOwner.id;
if (messageObject.messageOwner.to_id.channel_id != 0) {
i5 = messageObject.messageOwner.to_id.channel_id;
} else if (messageObject.messageOwner.to_id.chat_id != 0) {
i5 = messageObject.messageOwner.to_id.chat_id;
} else {
i4 = messageObject.messageOwner.to_id.user_id;
tL_messages_getDialogs.offset_peer = getInputPeer(i4);
}
i4 = -i5;
tL_messages_getDialogs.offset_peer = getInputPeer(i4);
}
}
size--;
}
if (!z2) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
}
}
getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadDialogs$130$MessagesController(i, i3, runnable, tLObject, tL_error);
}
});
}
public void lambda$loadDialogs$130$MessagesController(int i, int i2, Runnable runnable, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.messages_Dialogs messages_dialogs = (TLRPC.messages_Dialogs) tLObject;
processLoadedDialogs(messages_dialogs, null, i, 0, i2, 0, false, false, false);
if (runnable == null || !messages_dialogs.dialogs.isEmpty()) {
return;
}
AndroidUtilities.runOnUIThread(runnable);
}
}
public void loadGlobalNotificationsSettings() {
if (this.loadingNotificationSettings == 0 && !getUserConfig().notificationsSettingsLoaded) {
SharedPreferences notificationsSettings = getNotificationsSettings(this.currentAccount);
SharedPreferences.Editor editor = null;
if (notificationsSettings.contains("EnableGroup")) {
boolean z = notificationsSettings.getBoolean("EnableGroup", true);
SharedPreferences.Editor edit = notificationsSettings.edit();
if (!z) {
edit.putInt("EnableGroup2", Integer.MAX_VALUE);
edit.putInt("EnableChannel2", Integer.MAX_VALUE);
}
edit.remove("EnableGroup").commit();
editor = edit;
}
if (notificationsSettings.contains("EnableAll")) {
boolean z2 = notificationsSettings.getBoolean("EnableAll", true);
if (editor == null) {
editor = notificationsSettings.edit();
}
if (!z2) {
editor.putInt("EnableAll2", Integer.MAX_VALUE);
}
editor.remove("EnableAll").commit();
}
if (editor != null) {
editor.commit();
}
this.loadingNotificationSettings = 3;
for (final int i = 0; i < 3; i++) {
TLRPC.TL_account_getNotifySettings tL_account_getNotifySettings = new TLRPC.TL_account_getNotifySettings();
if (i == 0) {
tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyChats();
} else if (i == 1) {
tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyUsers();
} else if (i == 2) {
tL_account_getNotifySettings.peer = new TLRPC.TL_inputNotifyBroadcasts();
}
getConnectionsManager().sendRequest(tL_account_getNotifySettings, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadGlobalNotificationsSettings$132$MessagesController(i, tLObject, tL_error);
}
});
}
}
if (getUserConfig().notificationsSignUpSettingsLoaded) {
return;
}
loadSignUpNotificationsSettings();
}
public void lambda$loadGlobalNotificationsSettings$132$MessagesController(final int i, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$131$MessagesController(tLObject, i);
}
});
}
public void lambda$null$131$MessagesController(TLObject tLObject, int i) {
if (tLObject != null) {
this.loadingNotificationSettings--;
TLRPC.TL_peerNotifySettings tL_peerNotifySettings = (TLRPC.TL_peerNotifySettings) tLObject;
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
if (i == 0) {
if ((tL_peerNotifySettings.flags & 1) != 0) {
edit.putBoolean("EnablePreviewGroup", tL_peerNotifySettings.show_previews);
}
int i2 = tL_peerNotifySettings.flags;
if ((tL_peerNotifySettings.flags & 4) != 0) {
edit.putInt("EnableGroup2", tL_peerNotifySettings.mute_until);
}
} else if (i == 1) {
if ((tL_peerNotifySettings.flags & 1) != 0) {
edit.putBoolean("EnablePreviewAll", tL_peerNotifySettings.show_previews);
}
int i3 = tL_peerNotifySettings.flags;
if ((tL_peerNotifySettings.flags & 4) != 0) {
edit.putInt("EnableAll2", tL_peerNotifySettings.mute_until);
}
} else if (i == 2) {
if ((tL_peerNotifySettings.flags & 1) != 0) {
edit.putBoolean("EnablePreviewChannel", tL_peerNotifySettings.show_previews);
}
int i4 = tL_peerNotifySettings.flags;
if ((tL_peerNotifySettings.flags & 4) != 0) {
edit.putInt("EnableChannel2", tL_peerNotifySettings.mute_until);
}
}
edit.commit();
if (this.loadingNotificationSettings == 0) {
getUserConfig().notificationsSettingsLoaded = true;
getUserConfig().saveConfig(false);
}
}
}
public void loadSignUpNotificationsSettings() {
if (this.loadingNotificationSignUpSettings) {
return;
}
this.loadingNotificationSignUpSettings = true;
getConnectionsManager().sendRequest(new TLRPC.TL_account_getContactSignUpNotification(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadSignUpNotificationsSettings$134$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$loadSignUpNotificationsSettings$134$MessagesController(final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$133$MessagesController(tLObject);
}
});
}
public void lambda$null$133$MessagesController(TLObject tLObject) {
this.loadingNotificationSignUpSettings = false;
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
boolean z = tLObject instanceof TLRPC.TL_boolFalse;
this.enableJoined = z;
edit.putBoolean("EnableContactJoined", z);
edit.commit();
getUserConfig().notificationsSignUpSettingsLoaded = true;
getUserConfig().saveConfig(false);
}
public void forceResetDialogs() {
resetDialogs(true, getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
getNotificationsController().deleteAllNotificationChannels();
}
public void loadUnknownDialog(TLRPC.InputPeer inputPeer, long j) {
NativeByteBuffer nativeByteBuffer;
if (inputPeer == null) {
return;
}
final long peerDialogId = DialogObject.getPeerDialogId(inputPeer);
if (this.gettingUnknownDialogs.indexOfKey(peerDialogId) >= 0) {
return;
}
this.gettingUnknownDialogs.put(peerDialogId, true);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("load unknown dialog " + peerDialogId);
}
TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer;
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
if (j == 0) {
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(inputPeer.getObjectSize() + 4);
try {
nativeByteBuffer.writeInt32(15);
inputPeer.serializeToStream(nativeByteBuffer);
} catch (Exception e) {
e = e;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
final long j2 = j;
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUnknownDialog$135$MessagesController(j2, peerDialogId, tLObject, tL_error);
}
});
}
} catch (Exception e2) {
e = e2;
}
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
final long j22 = j;
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUnknownDialog$135$MessagesController(j22, peerDialogId, tLObject, tL_error);
}
});
}
public void lambda$loadUnknownDialog$135$MessagesController(long j, long j2, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
if (!tL_messages_peerDialogs.dialogs.isEmpty() && !(tL_messages_peerDialogs.dialogs.get(0) instanceof TLRPC.TL_dialogFolder)) {
TLRPC.TL_dialog tL_dialog = (TLRPC.TL_dialog) tL_messages_peerDialogs.dialogs.get(0);
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
processLoadedDialogs(tL_messages_dialogs, null, tL_dialog.folder_id, 0, 1, this.DIALOGS_LOAD_TYPE_UNKNOWN, false, false, false);
}
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
this.gettingUnknownDialogs.delete(j2);
}
private void fetchFolderInLoadedPinnedDialogs(TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs) {
TLRPC.InputPeer tL_inputPeerUser;
int size = tL_messages_peerDialogs.dialogs.size();
int i = 0;
for (int i2 = 0; i2 < size; i2++) {
TLRPC.Dialog dialog = tL_messages_peerDialogs.dialogs.get(i2);
if (dialog instanceof TLRPC.TL_dialogFolder) {
TLRPC.TL_dialogFolder tL_dialogFolder = (TLRPC.TL_dialogFolder) dialog;
long peerDialogId = DialogObject.getPeerDialogId(dialog.peer);
if (tL_dialogFolder.top_message == 0 || peerDialogId == 0) {
tL_messages_peerDialogs.dialogs.remove(tL_dialogFolder);
} else {
int size2 = tL_messages_peerDialogs.messages.size();
for (int i3 = 0; i3 < size2; i3++) {
TLRPC.Message message = tL_messages_peerDialogs.messages.get(i3);
if (peerDialogId == MessageObject.getDialogId(message) && dialog.top_message == message.id) {
TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
tL_dialog.peer = dialog.peer;
tL_dialog.top_message = dialog.top_message;
tL_dialog.folder_id = tL_dialogFolder.folder.id;
tL_dialog.flags |= 16;
tL_messages_peerDialogs.dialogs.add(tL_dialog);
if (dialog.peer instanceof TLRPC.TL_peerChannel) {
tL_inputPeerUser = new TLRPC.TL_inputPeerChannel();
tL_inputPeerUser.channel_id = dialog.peer.channel_id;
int size3 = tL_messages_peerDialogs.chats.size();
while (true) {
if (i >= size3) {
break;
}
TLRPC.Chat chat = tL_messages_peerDialogs.chats.get(i);
if (chat.id == tL_inputPeerUser.channel_id) {
tL_inputPeerUser.access_hash = chat.access_hash;
break;
}
i++;
}
} else if (dialog.peer instanceof TLRPC.TL_peerChat) {
tL_inputPeerUser = new TLRPC.TL_inputPeerChat();
tL_inputPeerUser.chat_id = dialog.peer.chat_id;
} else {
tL_inputPeerUser = new TLRPC.TL_inputPeerUser();
tL_inputPeerUser.user_id = dialog.peer.user_id;
int size4 = tL_messages_peerDialogs.users.size();
while (true) {
if (i >= size4) {
break;
}
TLRPC.User user = tL_messages_peerDialogs.users.get(i);
if (user.id == tL_inputPeerUser.user_id) {
tL_inputPeerUser.access_hash = user.access_hash;
break;
}
i++;
}
}
loadUnknownDialog(tL_inputPeerUser, 0L);
return;
}
}
return;
}
}
}
}
public void lambda$resetDialogs$136$MessagesController(int i, int i2, int i3, int i4, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
this.resetDialogsPinned = (TLRPC.TL_messages_peerDialogs) tLObject;
for (int i5 = 0; i5 < this.resetDialogsPinned.dialogs.size(); i5++) {
this.resetDialogsPinned.dialogs.get(i5).pinned = true;
}
resetDialogs(false, i, i2, i3, i4);
}
}
public void lambda$resetDialogs$137$MessagesController(int i, int i2, int i3, int i4, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
this.resetDialogsAll = (TLRPC.messages_Dialogs) tLObject;
resetDialogs(false, i, i2, i3, i4);
}
}
private void resetDialogs(boolean z, final int i, final int i2, final int i3, final int i4) {
TLRPC.messages_Dialogs messages_dialogs;
TLRPC.User user;
Integer num;
Integer num2;
Integer num3;
MessageObject messageObject;
TLRPC.Chat chat;
Integer num4 = 0;
if (z) {
if (this.resetingDialogs) {
return;
}
getUserConfig().setPinnedDialogsLoaded(1, false);
this.resetingDialogs = true;
getConnectionsManager().sendRequest(new TLRPC.TL_messages_getPinnedDialogs(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$resetDialogs$136$MessagesController(i, i2, i3, i4, tLObject, tL_error);
}
});
TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
tL_messages_getDialogs.limit = 100;
tL_messages_getDialogs.exclude_pinned = true;
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$resetDialogs$137$MessagesController(i, i2, i3, i4, tLObject, tL_error);
}
});
return;
}
if (this.resetDialogsPinned == null || (messages_dialogs = this.resetDialogsAll) == null) {
return;
}
int size = messages_dialogs.messages.size();
int size2 = this.resetDialogsAll.dialogs.size();
fetchFolderInLoadedPinnedDialogs(this.resetDialogsPinned);
this.resetDialogsAll.dialogs.addAll(this.resetDialogsPinned.dialogs);
this.resetDialogsAll.messages.addAll(this.resetDialogsPinned.messages);
this.resetDialogsAll.users.addAll(this.resetDialogsPinned.users);
this.resetDialogsAll.chats.addAll(this.resetDialogsPinned.chats);
LongSparseArray<TLRPC.Dialog> longSparseArray = new LongSparseArray<>();
LongSparseArray<MessageObject> longSparseArray2 = new LongSparseArray<>();
SparseArray sparseArray = new SparseArray();
SparseArray sparseArray2 = new SparseArray();
for (int i5 = 0; i5 < this.resetDialogsAll.users.size(); i5++) {
TLRPC.User user2 = this.resetDialogsAll.users.get(i5);
sparseArray.put(user2.id, user2);
}
for (int i6 = 0; i6 < this.resetDialogsAll.chats.size(); i6++) {
TLRPC.Chat chat2 = this.resetDialogsAll.chats.get(i6);
sparseArray2.put(chat2.id, chat2);
}
TLRPC.Message message = null;
for (int i7 = 0; i7 < this.resetDialogsAll.messages.size(); i7++) {
TLRPC.Message message2 = this.resetDialogsAll.messages.get(i7);
if (i7 < size && (message == null || message2.date < message.date)) {
message = message2;
}
if (message2.to_id.channel_id != 0) {
TLRPC.Chat chat3 = (TLRPC.Chat) sparseArray2.get(message2.to_id.channel_id);
if (chat3 == null || !chat3.left) {
if (chat3 != null && chat3.megagroup) {
message2.flags |= Integer.MIN_VALUE;
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
longSparseArray2.put(messageObject2.getDialogId(), messageObject2);
}
} else {
if (message2.to_id.chat_id != 0 && (chat = (TLRPC.Chat) sparseArray2.get(message2.to_id.chat_id)) != null && chat.migrated_to != null) {
}
MessageObject messageObject22 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
longSparseArray2.put(messageObject22.getDialogId(), messageObject22);
}
}
int i8 = 0;
while (i8 < this.resetDialogsAll.dialogs.size()) {
TLRPC.Dialog dialog = this.resetDialogsAll.dialogs.get(i8);
DialogObject.initDialog(dialog);
if (dialog.id != 0) {
if (dialog.last_message_date == 0 && (messageObject = longSparseArray2.get(dialog.id)) != null) {
dialog.last_message_date = messageObject.messageOwner.date;
}
if (DialogObject.isChannel(dialog)) {
TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
if (chat4 == null || !chat4.left) {
this.channelsPts.put(-((int) dialog.id), dialog.pts);
longSparseArray.put(dialog.id, dialog);
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
num = num4;
}
num2 = num4;
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num3 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num3 == null) {
num3 = num2;
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num3.intValue(), dialog.read_outbox_max_id)));
}
} else {
if (((int) dialog.id) < 0) {
TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
if (chat5 != null) {
}
}
longSparseArray.put(dialog.id, dialog);
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
}
num2 = num4;
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num3 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num3 == null) {
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num3.intValue(), dialog.read_outbox_max_id)));
}
i8++;
num4 = num2;
}
num2 = num4;
i8++;
num4 = num2;
}
ImageLoader.saveMessagesThumbs(this.resetDialogsAll.messages);
for (int i9 = 0; i9 < this.resetDialogsAll.messages.size(); i9++) {
TLRPC.Message message3 = this.resetDialogsAll.messages.get(i9);
if ((message3.action instanceof TLRPC.TL_messageActionChatDeleteUser) && (user = (TLRPC.User) sparseArray.get(message3.action.user_id)) != null && user.bot) {
message3.reply_markup = new TLRPC.TL_replyKeyboardHide();
message3.flags |= 64;
}
if ((message3.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message3.action instanceof TLRPC.TL_messageActionChannelCreate)) {
message3.unread = false;
message3.media_unread = false;
} else {
ConcurrentHashMap<Long, Integer> concurrentHashMap = message3.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
Integer num5 = concurrentHashMap.get(Long.valueOf(message3.dialog_id));
if (num5 == null) {
num5 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message3.out, message3.dialog_id));
concurrentHashMap.put(Long.valueOf(message3.dialog_id), num5);
}
message3.unread = num5.intValue() < message3.id;
}
}
getMessagesStorage().resetDialogs(this.resetDialogsAll, size, i, i2, i3, i4, longSparseArray, longSparseArray2, message, size2);
this.resetDialogsPinned = null;
this.resetDialogsAll = null;
}
public void completeDialogsReset(final TLRPC.messages_Dialogs messages_dialogs, int i, int i2, final int i3, final int i4, final int i5, final LongSparseArray<TLRPC.Dialog> longSparseArray, final LongSparseArray<MessageObject> longSparseArray2, TLRPC.Message message) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$completeDialogsReset$139$MessagesController(i3, i4, i5, messages_dialogs, longSparseArray, longSparseArray2);
}
});
}
public void lambda$completeDialogsReset$139$MessagesController(int i, int i2, int i3, final TLRPC.messages_Dialogs messages_dialogs, final LongSparseArray longSparseArray, final LongSparseArray longSparseArray2) {
this.gettingDifference = false;
getMessagesStorage().setLastPtsValue(i);
getMessagesStorage().setLastDateValue(i2);
getMessagesStorage().setLastQtsValue(i3);
getDifference();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$138$MessagesController(messages_dialogs, longSparseArray, longSparseArray2);
}
});
}
public void lambda$null$138$MessagesController(TLRPC.messages_Dialogs messages_dialogs, LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
this.resetingDialogs = false;
applyDialogsNotificationsSettings(messages_dialogs.dialogs);
if (!getUserConfig().draftsLoaded) {
getMediaDataController().loadDrafts();
}
putUsers(messages_dialogs.users, false);
putChats(messages_dialogs.chats, false);
for (int i = 0; i < this.allDialogs.size(); i++) {
TLRPC.Dialog dialog = this.allDialogs.get(i);
if (!DialogObject.isSecretDialogId(dialog.id)) {
this.dialogs_dict.remove(dialog.id);
MessageObject messageObject = this.dialogMessage.get(dialog.id);
this.dialogMessage.remove(dialog.id);
if (messageObject != null) {
this.dialogMessagesByIds.remove(messageObject.getId());
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject.messageOwner.random_id);
}
}
}
}
for (int i2 = 0; i2 < longSparseArray.size(); i2++) {
long keyAt = longSparseArray.keyAt(i2);
TLRPC.Dialog dialog2 = (TLRPC.Dialog) longSparseArray.valueAt(i2);
if (dialog2.draft instanceof TLRPC.TL_draftMessage) {
getMediaDataController().saveDraft(dialog2.id, dialog2.draft, null, false);
}
this.dialogs_dict.put(keyAt, dialog2);
MessageObject messageObject2 = (MessageObject) longSparseArray2.get(dialog2.id);
this.dialogMessage.put(keyAt, messageObject2);
if (messageObject2 != null && messageObject2.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject2.getId(), messageObject2);
if (messageObject2.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject2.messageOwner.random_id, messageObject2);
}
}
}
this.allDialogs.clear();
int size = this.dialogs_dict.size();
for (int i3 = 0; i3 < size; i3++) {
this.allDialogs.add(this.dialogs_dict.valueAt(i3));
}
sortDialogs(null);
this.dialogsEndReached.put(0, true);
this.serverDialogsEndReached.put(0, false);
this.dialogsEndReached.put(1, true);
this.serverDialogsEndReached.put(1, false);
int totalDialogsCount = getUserConfig().getTotalDialogsCount(0);
int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(0);
if (totalDialogsCount < 400 && dialogLoadOffsets[0] != -1 && dialogLoadOffsets[0] != Integer.MAX_VALUE) {
loadDialogs(0, 100, 0, false);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
private void migrateDialogs(final int i, int i2, int i3, int i4, int i5, long j) {
if (this.migratingDialogs || i == -1) {
return;
}
this.migratingDialogs = true;
TLRPC.TL_messages_getDialogs tL_messages_getDialogs = new TLRPC.TL_messages_getDialogs();
tL_messages_getDialogs.exclude_pinned = true;
tL_messages_getDialogs.limit = 100;
tL_messages_getDialogs.offset_id = i;
tL_messages_getDialogs.offset_date = i2;
if (i == 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerEmpty();
} else {
if (i5 != 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChannel();
tL_messages_getDialogs.offset_peer.channel_id = i5;
} else if (i3 != 0) {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerUser();
tL_messages_getDialogs.offset_peer.user_id = i3;
} else {
tL_messages_getDialogs.offset_peer = new TLRPC.TL_inputPeerChat();
tL_messages_getDialogs.offset_peer.chat_id = i4;
}
tL_messages_getDialogs.offset_peer.access_hash = j;
}
getConnectionsManager().sendRequest(tL_messages_getDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$migrateDialogs$143$MessagesController(i, tLObject, tL_error);
}
});
}
public void lambda$migrateDialogs$143$MessagesController(final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
final TLRPC.messages_Dialogs messages_dialogs = (TLRPC.messages_Dialogs) tLObject;
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$141$MessagesController(messages_dialogs, i);
}
});
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$142$MessagesController();
}
});
}
}
public void lambda$null$141$MessagesController(TLRPC.messages_Dialogs messages_dialogs, int i) {
int i2;
int i3;
TLRPC.Message message;
int i4 = i;
try {
getUserConfig().setTotalDialogsCount(0, getUserConfig().getTotalDialogsCount(0) + messages_dialogs.dialogs.size());
TLRPC.Message message2 = null;
for (int i5 = 0; i5 < messages_dialogs.messages.size(); i5++) {
TLRPC.Message message3 = messages_dialogs.messages.get(i5);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("search migrate id " + message3.id + " date " + LocaleController.getInstance().formatterStats.format(message3.date * 1000));
}
if (message2 == null || message3.date < message2.date) {
message2 = message3;
}
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("migrate step with id " + message2.id + " date " + LocaleController.getInstance().formatterStats.format(message2.date * 1000));
}
int i6 = 2;
int i7 = -1;
if (messages_dialogs.dialogs.size() >= 100) {
i2 = message2.id;
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("migrate stop due to not 100 dialogs");
}
for (int i8 = 0; i8 < 2; i8++) {
getUserConfig().setDialogsLoadOffset(i8, Integer.MAX_VALUE, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
}
i2 = -1;
}
StringBuilder sb = new StringBuilder(messages_dialogs.dialogs.size() * 12);
LongSparseArray longSparseArray = new LongSparseArray();
for (int i9 = 0; i9 < messages_dialogs.dialogs.size(); i9++) {
TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i9);
DialogObject.initDialog(dialog);
if (sb.length() > 0) {
sb.append(",");
}
sb.append(dialog.id);
longSparseArray.put(dialog.id, dialog);
}
SQLiteCursor queryFinalized = getMessagesStorage().getDatabase().queryFinalized(String.format(Locale.US, "SELECT did, folder_id FROM dialogs WHERE did IN (%s)", sb.toString()), new Object[0]);
while (queryFinalized.next()) {
long longValue = queryFinalized.longValue(0);
int intValue = queryFinalized.intValue(1);
TLRPC.Dialog dialog2 = (TLRPC.Dialog) longSparseArray.get(longValue);
if (dialog2.folder_id == intValue) {
longSparseArray.remove(longValue);
if (dialog2 != null) {
messages_dialogs.dialogs.remove(dialog2);
int i10 = 0;
while (true) {
if (i10 < messages_dialogs.messages.size()) {
TLRPC.Message message4 = messages_dialogs.messages.get(i10);
if (MessageObject.getDialogId(message4) == longValue) {
messages_dialogs.messages.remove(i10);
i10--;
if (message4.id == dialog2.top_message) {
dialog2.top_message = 0;
break;
}
}
i10++;
}
}
}
}
}
queryFinalized.dispose();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("migrate found missing dialogs " + messages_dialogs.dialogs.size());
}
SQLiteCursor queryFinalized2 = getMessagesStorage().getDatabase().queryFinalized("SELECT min(date) FROM dialogs WHERE date != 0 AND did >> 32 IN (0, -1)", new Object[0]);
if (queryFinalized2.next()) {
int max = Math.max(1441062000, queryFinalized2.intValue(0));
int i11 = 0;
while (i11 < messages_dialogs.messages.size()) {
TLRPC.Message message5 = messages_dialogs.messages.get(i11);
if (message5.date < max) {
if (i4 != i7) {
int i12 = 0;
while (i12 < i6) {
getUserConfig().setDialogsLoadOffset(i12, getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
i12++;
message2 = message2;
i6 = 2;
}
message = message2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format(max * 1000));
}
i2 = -1;
} else {
message = message2;
}
messages_dialogs.messages.remove(i11);
i11--;
long dialogId = MessageObject.getDialogId(message5);
TLRPC.Dialog dialog3 = (TLRPC.Dialog) longSparseArray.get(dialogId);
longSparseArray.remove(dialogId);
if (dialog3 != null) {
messages_dialogs.dialogs.remove(dialog3);
}
} else {
message = message2;
}
i11++;
i4 = i;
message2 = message;
i6 = 2;
i7 = -1;
}
TLRPC.Message message6 = message2;
if (message6 != null) {
message2 = message6;
if (message2.date < max && i != -1) {
for (int i13 = 0; i13 < 2; i13++) {
getUserConfig().setDialogsLoadOffset(i13, getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("migrate stop due to reached loaded dialogs " + LocaleController.getInstance().formatterStats.format(max * 1000));
}
i3 = -1;
queryFinalized2.dispose();
getUserConfig().migrateOffsetDate = message2.date;
if (message2.to_id.channel_id == 0) {
getUserConfig().migrateOffsetChannelId = message2.to_id.channel_id;
getUserConfig().migrateOffsetChatId = 0;
getUserConfig().migrateOffsetUserId = 0;
int i14 = 0;
while (true) {
if (i14 >= messages_dialogs.chats.size()) {
break;
}
TLRPC.Chat chat = messages_dialogs.chats.get(i14);
if (chat.id == getUserConfig().migrateOffsetChannelId) {
getUserConfig().migrateOffsetAccess = chat.access_hash;
break;
}
i14++;
}
} else if (message2.to_id.chat_id != 0) {
getUserConfig().migrateOffsetChatId = message2.to_id.chat_id;
getUserConfig().migrateOffsetChannelId = 0;
getUserConfig().migrateOffsetUserId = 0;
int i15 = 0;
while (true) {
if (i15 >= messages_dialogs.chats.size()) {
break;
}
TLRPC.Chat chat2 = messages_dialogs.chats.get(i15);
if (chat2.id == getUserConfig().migrateOffsetChatId) {
getUserConfig().migrateOffsetAccess = chat2.access_hash;
break;
}
i15++;
}
} else if (message2.to_id.user_id != 0) {
getUserConfig().migrateOffsetUserId = message2.to_id.user_id;
getUserConfig().migrateOffsetChatId = 0;
getUserConfig().migrateOffsetChannelId = 0;
int i16 = 0;
while (true) {
if (i16 >= messages_dialogs.users.size()) {
break;
}
TLRPC.User user = messages_dialogs.users.get(i16);
if (user.id == getUserConfig().migrateOffsetUserId) {
getUserConfig().migrateOffsetAccess = user.access_hash;
break;
}
i16++;
}
}
processLoadedDialogs(messages_dialogs, null, 0, i3, 0, 0, false, true, false);
}
} else {
message2 = message6;
}
}
i3 = i2;
queryFinalized2.dispose();
getUserConfig().migrateOffsetDate = message2.date;
if (message2.to_id.channel_id == 0) {
}
processLoadedDialogs(messages_dialogs, null, 0, i3, 0, 0, false, true, false);
} catch (Exception e) {
FileLog.e(e);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$140$MessagesController();
}
});
}
}
public void lambda$null$140$MessagesController() {
this.migratingDialogs = false;
}
public void lambda$null$142$MessagesController() {
this.migratingDialogs = false;
}
public void processLoadedDialogs(final TLRPC.messages_Dialogs messages_dialogs, final ArrayList<TLRPC.EncryptedChat> arrayList, final int i, final int i2, final int i3, final int i4, final boolean z, final boolean z2, final boolean z3) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processLoadedDialogs$146$MessagesController(i, i4, messages_dialogs, z, i3, arrayList, i2, z3, z2);
}
});
}
public void lambda$processLoadedDialogs$146$MessagesController(final int i, final int i2, final TLRPC.messages_Dialogs messages_dialogs, final boolean z, final int i3, final ArrayList arrayList, final int i4, final boolean z2, final boolean z3) {
SparseArray sparseArray;
final SparseArray sparseArray2;
SparseArray sparseArray3;
LongSparseArray longSparseArray;
LongSparseArray longSparseArray2;
int i5;
SparseArray sparseArray4;
SparseArray sparseArray5;
boolean z4;
TLRPC.Chat chat;
Integer num;
Integer num2;
MessageObject messageObject;
int i6;
long j;
int i7;
int i8;
int i9;
int i10;
int i11;
long j2;
long j3;
long j4;
SparseArray sparseArray6;
TLRPC.Chat chat2;
if (!this.firstGettingTask) {
getNewDeleteTask(null, 0);
this.firstGettingTask = true;
}
final int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i);
if (i2 == this.DIALOGS_LOAD_TYPE_CACHE && messages_dialogs.dialogs.size() == 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$144$MessagesController(messages_dialogs, i, z, dialogLoadOffsets, i3);
}
});
return;
}
LongSparseArray longSparseArray3 = new LongSparseArray();
LongSparseArray longSparseArray4 = new LongSparseArray();
SparseArray sparseArray7 = new SparseArray();
SparseArray sparseArray8 = new SparseArray();
for (int i12 = 0; i12 < messages_dialogs.users.size(); i12++) {
TLRPC.User user = messages_dialogs.users.get(i12);
sparseArray7.put(user.id, user);
}
for (int i13 = 0; i13 < messages_dialogs.chats.size(); i13++) {
TLRPC.Chat chat3 = messages_dialogs.chats.get(i13);
sparseArray8.put(chat3.id, chat3);
}
if (arrayList != null) {
SparseArray sparseArray9 = new SparseArray();
int size = arrayList.size();
for (int i14 = 0; i14 < size; i14++) {
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) arrayList.get(i14);
sparseArray9.put(encryptedChat.id, encryptedChat);
}
sparseArray = sparseArray9;
} else {
sparseArray = null;
}
if (i2 == this.DIALOGS_LOAD_TYPE_CACHE) {
this.nextDialogsCacheOffset.put(i, i4 + i3);
}
int i15 = 0;
TLRPC.Message message = null;
while (i15 < messages_dialogs.messages.size()) {
TLRPC.Message message2 = messages_dialogs.messages.get(i15);
if (message == null || message2.date < message.date) {
message = message2;
}
if (message2.to_id.channel_id != 0) {
TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray8.get(message2.to_id.channel_id);
if (chat4 == null || !chat4.left) {
sparseArray6 = sparseArray;
} else {
sparseArray6 = sparseArray;
long j5 = this.proxyDialogId;
if (j5 != 0) {
if (j5 != (-chat4.id)) {
}
}
i15++;
sparseArray = sparseArray6;
}
if (chat4 != null && chat4.megagroup) {
message2.flags |= Integer.MIN_VALUE;
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray7, (SparseArray<TLRPC.Chat>) sparseArray8, false);
longSparseArray4.put(messageObject2.getDialogId(), messageObject2);
i15++;
sparseArray = sparseArray6;
} else {
sparseArray6 = sparseArray;
if (message2.to_id.chat_id != 0 && (chat2 = (TLRPC.Chat) sparseArray8.get(message2.to_id.chat_id)) != null && chat2.migrated_to != null) {
i15++;
sparseArray = sparseArray6;
}
MessageObject messageObject22 = new MessageObject(this.currentAccount, message2, (SparseArray<TLRPC.User>) sparseArray7, (SparseArray<TLRPC.Chat>) sparseArray8, false);
longSparseArray4.put(messageObject22.getDialogId(), messageObject22);
i15++;
sparseArray = sparseArray6;
}
}
SparseArray sparseArray10 = sparseArray;
if (z2 || z3 || dialogLoadOffsets[0] == -1 || i2 != 0) {
sparseArray2 = sparseArray8;
sparseArray3 = sparseArray7;
longSparseArray = longSparseArray3;
longSparseArray2 = longSparseArray4;
} else {
int totalDialogsCount = getUserConfig().getTotalDialogsCount(i);
if (message == null || message.id == dialogLoadOffsets[0]) {
i6 = totalDialogsCount;
j = 0;
i7 = Integer.MAX_VALUE;
i8 = 0;
i9 = 0;
i10 = 0;
i11 = 0;
} else {
int size2 = totalDialogsCount + messages_dialogs.dialogs.size();
int i16 = message.id;
i8 = message.date;
if (message.to_id.channel_id != 0) {
int i17 = message.to_id.channel_id;
int i18 = 0;
while (true) {
if (i18 >= messages_dialogs.chats.size()) {
j4 = 0;
break;
}
TLRPC.Chat chat5 = messages_dialogs.chats.get(i18);
if (chat5.id == i17) {
j4 = chat5.access_hash;
break;
}
i18++;
}
i11 = i17;
j = j4;
i9 = 0;
i10 = 0;
} else if (message.to_id.chat_id != 0) {
int i19 = message.to_id.chat_id;
int i20 = 0;
while (true) {
if (i20 >= messages_dialogs.chats.size()) {
j3 = 0;
break;
}
TLRPC.Chat chat6 = messages_dialogs.chats.get(i20);
if (chat6.id == i19) {
j3 = chat6.access_hash;
break;
}
i20++;
}
j = j3;
i9 = 0;
i11 = 0;
i10 = i19;
} else if (message.to_id.user_id != 0) {
int i21 = message.to_id.user_id;
int i22 = 0;
while (true) {
if (i22 >= messages_dialogs.users.size()) {
j2 = 0;
break;
}
TLRPC.User user2 = messages_dialogs.users.get(i22);
if (user2.id == i21) {
j2 = user2.access_hash;
break;
}
i22++;
}
i9 = i21;
j = j2;
i10 = 0;
i11 = 0;
} else {
i6 = size2;
j = 0;
i9 = 0;
i10 = 0;
i11 = 0;
i7 = i16;
}
i6 = size2;
i7 = i16;
}
sparseArray2 = sparseArray8;
int i23 = i9;
int i24 = i10;
int i25 = i11;
longSparseArray = longSparseArray3;
sparseArray3 = sparseArray7;
longSparseArray2 = longSparseArray4;
getUserConfig().setDialogsLoadOffset(i, i7, i8, i23, i24, i25, j);
getUserConfig().setTotalDialogsCount(i, i6);
getUserConfig().saveConfig(false);
}
final ArrayList arrayList2 = new ArrayList();
int i26 = 0;
while (i26 < messages_dialogs.dialogs.size()) {
TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i26);
DialogObject.initDialog(dialog);
if (dialog.id == 0) {
sparseArray5 = sparseArray10;
} else {
int i27 = (int) dialog.id;
int i28 = (int) (dialog.id >> 32);
if (i27 != 0 || sparseArray10 == null) {
sparseArray5 = sparseArray10;
} else {
sparseArray5 = sparseArray10;
}
long j6 = this.proxyDialogId;
if (j6 != 0 && j6 == dialog.id) {
this.proxyDialog = dialog;
}
if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray2.get(dialog.id)) != null) {
dialog.last_message_date = messageObject.messageOwner.date;
}
if (DialogObject.isChannel(dialog)) {
TLRPC.Chat chat7 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
if (chat7 != null) {
z4 = chat7.megagroup;
if (chat7.left) {
long j7 = this.proxyDialogId;
if (j7 != 0) {
}
}
} else {
z4 = true;
}
this.channelsPts.put(-((int) dialog.id), dialog.pts);
longSparseArray.put(dialog.id, dialog);
if (z4 && i2 == this.DIALOGS_LOAD_TYPE_CACHE && ((dialog.read_outbox_max_id == 0 || dialog.read_inbox_max_id == 0) && dialog.top_message != 0)) {
arrayList2.add(dialog);
}
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
num = 0;
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
num2 = 0;
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
} else if (((int) dialog.id) >= 0 || (chat = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id))) == null || chat.migrated_to == null) {
z4 = true;
longSparseArray.put(dialog.id, dialog);
if (z4) {
arrayList2.add(dialog);
}
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
}
}
i26++;
sparseArray10 = sparseArray5;
}
if (i2 != this.DIALOGS_LOAD_TYPE_CACHE) {
ImageLoader.saveMessagesThumbs(messages_dialogs.messages);
int i29 = 0;
while (i29 < messages_dialogs.messages.size()) {
TLRPC.Message message3 = messages_dialogs.messages.get(i29);
if (message3.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
sparseArray4 = sparseArray3;
TLRPC.User user3 = (TLRPC.User) sparseArray4.get(message3.action.user_id);
if (user3 != null && user3.bot) {
message3.reply_markup = new TLRPC.TL_replyKeyboardHide();
message3.flags |= 64;
}
} else {
sparseArray4 = sparseArray3;
}
if ((message3.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message3.action instanceof TLRPC.TL_messageActionChannelCreate)) {
message3.unread = false;
message3.media_unread = false;
} else {
ConcurrentHashMap<Long, Integer> concurrentHashMap = message3.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
Integer num3 = concurrentHashMap.get(Long.valueOf(message3.dialog_id));
if (num3 == null) {
num3 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message3.out, message3.dialog_id));
concurrentHashMap.put(Long.valueOf(message3.dialog_id), num3);
}
message3.unread = num3.intValue() < message3.id;
}
i29++;
sparseArray3 = sparseArray4;
}
i5 = 0;
getMessagesStorage().putDialogs(messages_dialogs, 0);
} else {
i5 = 0;
}
if (i2 == this.DIALOGS_LOAD_TYPE_CHANNEL) {
TLRPC.Chat chat8 = messages_dialogs.chats.get(i5);
getChannelDifference(chat8.id);
checkChannelInviter(chat8.id);
}
final LongSparseArray longSparseArray5 = longSparseArray;
final LongSparseArray longSparseArray6 = longSparseArray2;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$145$MessagesController(i2, messages_dialogs, arrayList, z3, i, longSparseArray5, longSparseArray6, sparseArray2, i3, z2, i4, arrayList2);
}
});
}
public void lambda$null$144$MessagesController(TLRPC.messages_Dialogs messages_dialogs, int i, boolean z, int[] iArr, int i2) {
putUsers(messages_dialogs.users, true);
this.loadingDialogs.put(i, false);
if (z) {
this.dialogsEndReached.put(i, false);
this.serverDialogsEndReached.put(i, false);
} else if (iArr[0] == Integer.MAX_VALUE) {
this.dialogsEndReached.put(i, true);
this.serverDialogsEndReached.put(i, true);
} else {
loadDialogs(i, 0, i2, false);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void lambda$null$145$MessagesController(int i, TLRPC.messages_Dialogs messages_dialogs, ArrayList arrayList, boolean z, int i2, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, SparseArray sparseArray, int i3, boolean z2, int i4, ArrayList arrayList2) {
int i5;
int i6;
int i7;
int i8;
boolean z3;
LongSparseArray longSparseArray3 = longSparseArray;
if (i != this.DIALOGS_LOAD_TYPE_CACHE) {
applyDialogsNotificationsSettings(messages_dialogs.dialogs);
if (!getUserConfig().draftsLoaded) {
getMediaDataController().loadDrafts();
}
}
putUsers(messages_dialogs.users, i == this.DIALOGS_LOAD_TYPE_CACHE);
putChats(messages_dialogs.chats, i == this.DIALOGS_LOAD_TYPE_CACHE);
if (arrayList != null) {
for (int i9 = 0; i9 < arrayList.size(); i9++) {
TLRPC.EncryptedChat encryptedChat = (TLRPC.EncryptedChat) arrayList.get(i9);
if ((encryptedChat instanceof TLRPC.TL_encryptedChat) && AndroidUtilities.getMyLayerVersion(encryptedChat.layer) < 101) {
getSecretChatHelper().sendNotifyLayerMessage(encryptedChat, null);
}
putEncryptedChat(encryptedChat, true);
}
}
if (!z && i != this.DIALOGS_LOAD_TYPE_UNKNOWN && i != this.DIALOGS_LOAD_TYPE_CHANNEL) {
this.loadingDialogs.put(i2, false);
}
this.dialogsLoaded = true;
if (!z || this.allDialogs.isEmpty()) {
i5 = 0;
} else {
ArrayList<TLRPC.Dialog> arrayList3 = this.allDialogs;
i5 = arrayList3.get(arrayList3.size() - 1).last_message_date;
}
int i10 = 0;
int i11 = 0;
boolean z4 = false;
while (i10 < longSparseArray.size()) {
long keyAt = longSparseArray3.keyAt(i10);
TLRPC.Dialog dialog = (TLRPC.Dialog) longSparseArray3.valueAt(i10);
TLRPC.Dialog dialog2 = i != this.DIALOGS_LOAD_TYPE_UNKNOWN ? this.dialogs_dict.get(keyAt) : null;
if (z && dialog2 != null) {
dialog2.folder_id = dialog.folder_id;
}
if (!z || i5 == 0 || dialog.last_message_date >= i5) {
if (i == this.DIALOGS_LOAD_TYPE_CACHE || !(dialog.draft instanceof TLRPC.TL_draftMessage)) {
i7 = i5;
} else {
i7 = i5;
getMediaDataController().saveDraft(dialog.id, dialog.draft, null, false);
}
if (dialog.folder_id != i2) {
i11++;
}
if (dialog2 == null) {
this.dialogs_dict.put(keyAt, dialog);
MessageObject messageObject = (MessageObject) longSparseArray2.get(dialog.id);
this.dialogMessage.put(keyAt, messageObject);
if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
}
}
z4 = true;
} else {
if (i != this.DIALOGS_LOAD_TYPE_CACHE) {
dialog2.notify_settings = dialog.notify_settings;
}
dialog2.pinned = dialog.pinned;
dialog2.pinnedNum = dialog.pinnedNum;
MessageObject messageObject2 = this.dialogMessage.get(keyAt);
if ((messageObject2 != null && messageObject2.deleted) || messageObject2 == null || dialog2.top_message > 0) {
i8 = i11;
z3 = z4;
if (dialog.top_message >= dialog2.top_message) {
this.dialogs_dict.put(keyAt, dialog);
MessageObject messageObject3 = (MessageObject) longSparseArray2.get(dialog.id);
this.dialogMessage.put(keyAt, messageObject3);
if (messageObject3 != null && messageObject3.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
if (messageObject3 != null && messageObject3.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject3.messageOwner.random_id, messageObject3);
}
}
if (messageObject2 != null) {
this.dialogMessagesByIds.remove(messageObject2.getId());
if (messageObject2.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
}
}
}
} else {
i8 = i11;
z3 = z4;
MessageObject messageObject4 = (MessageObject) longSparseArray2.get(dialog.id);
if (messageObject2.deleted || messageObject4 == null || messageObject4.messageOwner.date > messageObject2.messageOwner.date) {
this.dialogs_dict.put(keyAt, dialog);
this.dialogMessage.put(keyAt, messageObject4);
if (messageObject4 != null && messageObject4.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject4.getId(), messageObject4);
if (messageObject4 != null && messageObject4.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject4.messageOwner.random_id, messageObject4);
}
}
this.dialogMessagesByIds.remove(messageObject2.getId());
if (messageObject2.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
}
}
}
i11 = i8;
z4 = z3;
}
} else {
i7 = i5;
}
i10++;
longSparseArray3 = longSparseArray;
i5 = i7;
}
boolean z5 = z4;
this.allDialogs.clear();
int size = this.dialogs_dict.size();
for (int i12 = 0; i12 < size; i12++) {
this.allDialogs.add(this.dialogs_dict.valueAt(i12));
}
sortDialogs(z ? sparseArray : null);
if (i != this.DIALOGS_LOAD_TYPE_CHANNEL && i != this.DIALOGS_LOAD_TYPE_UNKNOWN && !z) {
this.dialogsEndReached.put(i2, (messages_dialogs.dialogs.size() == 0 || messages_dialogs.dialogs.size() != i3) && i == 0);
if (i11 > 0 && i11 < 20 && i2 == 0) {
this.dialogsEndReached.put(1, true);
if (getUserConfig().getDialogLoadOffsets(i2)[0] == Integer.MAX_VALUE) {
this.serverDialogsEndReached.put(1, true);
}
}
if (!z2) {
this.serverDialogsEndReached.put(i2, (messages_dialogs.dialogs.size() == 0 || messages_dialogs.dialogs.size() != i3) && i == 0);
}
}
int totalDialogsCount = getUserConfig().getTotalDialogsCount(i2);
int[] dialogLoadOffsets = getUserConfig().getDialogLoadOffsets(i2);
if (z2 || z || totalDialogsCount >= 400) {
i6 = 0;
} else {
i6 = 0;
i6 = 0;
i6 = 0;
if (dialogLoadOffsets[0] != -1 && dialogLoadOffsets[0] != Integer.MAX_VALUE) {
loadDialogs(0, 100, i2, false);
}
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[i6]);
if (z) {
getUserConfig().migrateOffsetId = i4;
getUserConfig().saveConfig(i6);
this.migratingDialogs = i6;
getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch, new Object[i6]);
} else {
generateUpdateMessage();
if (!z5 && i == this.DIALOGS_LOAD_TYPE_CACHE) {
loadDialogs(i2, i6, i3, i6);
}
}
migrateDialogs(getUserConfig().migrateOffsetId, getUserConfig().migrateOffsetDate, getUserConfig().migrateOffsetUserId, getUserConfig().migrateOffsetChatId, getUserConfig().migrateOffsetChannelId, getUserConfig().migrateOffsetAccess);
if (!arrayList2.isEmpty()) {
reloadDialogsReadValue(arrayList2, 0L);
}
loadUnreadDialogs();
}
private void applyDialogNotificationsSettings(long j, TLRPC.PeerNotifySettings peerNotifySettings) {
int i;
if (peerNotifySettings == null) {
return;
}
int i2 = this.notificationsPreferences.getInt("notify2_" + j, -1);
int i3 = this.notificationsPreferences.getInt("notifyuntil_" + j, 0);
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog != null) {
dialog.notify_settings = peerNotifySettings;
}
if ((peerNotifySettings.flags & 2) != 0) {
edit.putBoolean("silent_" + j, peerNotifySettings.silent);
} else {
edit.remove("silent_" + j);
}
boolean z = true;
if ((peerNotifySettings.flags & 4) != 0) {
if (peerNotifySettings.mute_until > getConnectionsManager().getCurrentTime()) {
if (peerNotifySettings.mute_until <= getConnectionsManager().getCurrentTime() + 31536000) {
if (i2 == 3 && i3 == peerNotifySettings.mute_until) {
z = false;
} else {
edit.putInt("notify2_" + j, 3);
edit.putInt("notifyuntil_" + j, peerNotifySettings.mute_until);
if (dialog != null) {
dialog.notify_settings.mute_until = 0;
}
}
i = peerNotifySettings.mute_until;
} else if (i2 != 2) {
edit.putInt("notify2_" + j, 2);
if (dialog != null) {
dialog.notify_settings.mute_until = Integer.MAX_VALUE;
}
i = 0;
} else {
i = 0;
z = false;
}
getMessagesStorage().setDialogFlags(j, (i << 32) | 1);
getNotificationsController().removeNotificationsForDialog(j);
} else {
if (i2 == 0 || i2 == 1) {
z = false;
} else {
if (dialog != null) {
dialog.notify_settings.mute_until = 0;
}
edit.putInt("notify2_" + j, 0);
}
getMessagesStorage().setDialogFlags(j, 0L);
}
} else {
if (i2 != -1) {
if (dialog != null) {
dialog.notify_settings.mute_until = 0;
}
edit.remove("notify2_" + j);
} else {
z = false;
}
getMessagesStorage().setDialogFlags(j, 0L);
}
edit.commit();
if (z) {
getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
}
}
private void applyDialogsNotificationsSettings(ArrayList<TLRPC.Dialog> arrayList) {
int i;
int i2;
SharedPreferences.Editor editor = null;
for (int i3 = 0; i3 < arrayList.size(); i3++) {
TLRPC.Dialog dialog = arrayList.get(i3);
if (dialog.peer != null && (dialog.notify_settings instanceof TLRPC.TL_peerNotifySettings)) {
if (editor == null) {
editor = this.notificationsPreferences.edit();
}
if (dialog.peer.user_id != 0) {
i2 = dialog.peer.user_id;
} else {
if (dialog.peer.chat_id != 0) {
i = dialog.peer.chat_id;
} else {
i = dialog.peer.channel_id;
}
i2 = -i;
}
if ((dialog.notify_settings.flags & 2) != 0) {
editor.putBoolean("silent_" + i2, dialog.notify_settings.silent);
} else {
editor.remove("silent_" + i2);
}
if ((dialog.notify_settings.flags & 4) == 0) {
editor.remove("notify2_" + i2);
} else if (dialog.notify_settings.mute_until <= getConnectionsManager().getCurrentTime()) {
editor.putInt("notify2_" + i2, 0);
} else if (dialog.notify_settings.mute_until > getConnectionsManager().getCurrentTime() + 31536000) {
editor.putInt("notify2_" + i2, 2);
dialog.notify_settings.mute_until = Integer.MAX_VALUE;
} else {
editor.putInt("notify2_" + i2, 3);
editor.putInt("notifyuntil_" + i2, dialog.notify_settings.mute_until);
}
}
}
if (editor != null) {
editor.commit();
}
}
public void reloadMentionsCountForChannels(final ArrayList<Integer> arrayList) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$reloadMentionsCountForChannels$149$MessagesController(arrayList);
}
});
}
public void lambda$reloadMentionsCountForChannels$149$MessagesController(ArrayList arrayList) {
for (int i = 0; i < arrayList.size(); i++) {
final long j = -((Integer) arrayList.get(i)).intValue();
TLRPC.TL_messages_getUnreadMentions tL_messages_getUnreadMentions = new TLRPC.TL_messages_getUnreadMentions();
tL_messages_getUnreadMentions.peer = getInputPeer((int) j);
tL_messages_getUnreadMentions.limit = 1;
getConnectionsManager().sendRequest(tL_messages_getUnreadMentions, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$null$148$MessagesController(j, tLObject, tL_error);
}
});
}
}
public void lambda$null$148$MessagesController(final long j, final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$147$MessagesController(tLObject, j);
}
});
}
public void lambda$null$147$MessagesController(TLObject tLObject, long j) {
int size;
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
if (messages_messages != null) {
if (messages_messages.count != 0) {
size = messages_messages.count;
} else {
size = messages_messages.messages.size();
}
getMessagesStorage().resetMentionsCount(j, size);
}
}
public void processDialogsUpdateRead(final LongSparseArray<Integer> longSparseArray, final LongSparseArray<Integer> longSparseArray2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processDialogsUpdateRead$150$MessagesController(longSparseArray, longSparseArray2);
}
});
}
public void lambda$processDialogsUpdateRead$150$MessagesController(LongSparseArray longSparseArray, LongSparseArray longSparseArray2) {
if (longSparseArray != null) {
for (int i = 0; i < longSparseArray.size(); i++) {
long keyAt = longSparseArray.keyAt(i);
TLRPC.Dialog dialog = this.dialogs_dict.get(keyAt);
if (dialog != null) {
int i2 = dialog.unread_count;
dialog.unread_count = ((Integer) longSparseArray.valueAt(i)).intValue();
if (i2 != 0 && dialog.unread_count == 0 && !isDialogMuted(keyAt)) {
this.unreadUnmutedDialogs--;
} else if (i2 == 0 && !dialog.unread_mark && dialog.unread_count != 0) {
this.dialogsUnreadOnly.add(dialog);
if (!isDialogMuted(keyAt)) {
this.unreadUnmutedDialogs++;
}
}
}
}
}
if (longSparseArray2 != null) {
for (int i3 = 0; i3 < longSparseArray2.size(); i3++) {
TLRPC.Dialog dialog2 = this.dialogs_dict.get(longSparseArray2.keyAt(i3));
if (dialog2 != null) {
dialog2.unread_mentions_count = ((Integer) longSparseArray2.valueAt(i3)).intValue();
if (this.createdDialogMainThreadIds.contains(Long.valueOf(dialog2.id))) {
getNotificationCenter().postNotificationName(NotificationCenter.updateMentionsCount, Long.valueOf(dialog2.id), Integer.valueOf(dialog2.unread_mentions_count));
}
}
}
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
if (longSparseArray != null) {
getNotificationsController().processDialogsUpdateRead(longSparseArray);
}
}
public void checkLastDialogMessage(final TLRPC.Dialog dialog, TLRPC.InputPeer inputPeer, long j) {
NativeByteBuffer nativeByteBuffer;
final int i = (int) dialog.id;
if (i == 0 || this.checkingLastMessagesDialogs.indexOfKey(i) >= 0) {
return;
}
TLRPC.TL_messages_getHistory tL_messages_getHistory = new TLRPC.TL_messages_getHistory();
tL_messages_getHistory.peer = inputPeer == null ? getInputPeer(i) : inputPeer;
if (tL_messages_getHistory.peer == null) {
return;
}
tL_messages_getHistory.limit = 1;
this.checkingLastMessagesDialogs.put(i, true);
if (j == 0) {
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(tL_messages_getHistory.peer.getObjectSize() + 60);
} catch (Exception e) {
e = e;
}
try {
nativeByteBuffer.writeInt32(14);
nativeByteBuffer.writeInt64(dialog.id);
nativeByteBuffer.writeInt32(dialog.top_message);
nativeByteBuffer.writeInt32(dialog.read_inbox_max_id);
nativeByteBuffer.writeInt32(dialog.read_outbox_max_id);
nativeByteBuffer.writeInt32(dialog.unread_count);
nativeByteBuffer.writeInt32(dialog.last_message_date);
nativeByteBuffer.writeInt32(dialog.pts);
nativeByteBuffer.writeInt32(dialog.flags);
nativeByteBuffer.writeBool(dialog.pinned);
nativeByteBuffer.writeInt32(dialog.pinnedNum);
nativeByteBuffer.writeInt32(dialog.unread_mentions_count);
nativeByteBuffer.writeBool(dialog.unread_mark);
nativeByteBuffer.writeInt32(dialog.folder_id);
inputPeer.serializeToStream(nativeByteBuffer);
} catch (Exception e2) {
e = e2;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
final long j2 = j;
getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$checkLastDialogMessage$153$MessagesController(i, dialog, j2, tLObject, tL_error);
}
});
}
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
final long j22 = j;
getConnectionsManager().sendRequest(tL_messages_getHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$checkLastDialogMessage$153$MessagesController(i, dialog, j22, tLObject, tL_error);
}
});
}
public void lambda$checkLastDialogMessage$153$MessagesController(final int i, final TLRPC.Dialog dialog, long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
removeDeletedMessagesFromArray(i, messages_messages.messages);
if (!messages_messages.messages.isEmpty()) {
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
TLRPC.Message message = messages_messages.messages.get(0);
TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
tL_dialog.flags = dialog.flags;
tL_dialog.top_message = message.id;
tL_dialog.last_message_date = message.date;
tL_dialog.notify_settings = dialog.notify_settings;
tL_dialog.pts = dialog.pts;
tL_dialog.unread_count = dialog.unread_count;
tL_dialog.unread_mark = dialog.unread_mark;
tL_dialog.unread_mentions_count = dialog.unread_mentions_count;
tL_dialog.read_inbox_max_id = dialog.read_inbox_max_id;
tL_dialog.read_outbox_max_id = dialog.read_outbox_max_id;
tL_dialog.pinned = dialog.pinned;
tL_dialog.pinnedNum = dialog.pinnedNum;
tL_dialog.folder_id = dialog.folder_id;
long j2 = dialog.id;
tL_dialog.id = j2;
message.dialog_id = j2;
tL_messages_dialogs.users.addAll(messages_messages.users);
tL_messages_dialogs.chats.addAll(messages_messages.chats);
tL_messages_dialogs.dialogs.add(tL_dialog);
tL_messages_dialogs.messages.addAll(messages_messages.messages);
tL_messages_dialogs.count = 1;
processDialogsUpdate(tL_messages_dialogs, null);
getMessagesStorage().putMessages(messages_messages.messages, true, true, false, getDownloadController().getAutodownloadMask(), true);
} else {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$151$MessagesController(dialog);
}
});
}
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$152$MessagesController(i);
}
});
}
public void lambda$null$151$MessagesController(TLRPC.Dialog dialog) {
TLRPC.Dialog dialog2 = this.dialogs_dict.get(dialog.id);
if (dialog2 == null || dialog2.top_message != 0) {
return;
}
deleteDialog(dialog.id, 3);
}
public void lambda$null$152$MessagesController(int i) {
this.checkingLastMessagesDialogs.delete(i);
}
public void processDialogsUpdate(final TLRPC.messages_Dialogs messages_dialogs, ArrayList<TLRPC.EncryptedChat> arrayList) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processDialogsUpdate$155$MessagesController(messages_dialogs);
}
});
}
public void lambda$processDialogsUpdate$155$MessagesController(final TLRPC.messages_Dialogs messages_dialogs) {
int i;
long j;
TLRPC.Chat chat;
MessageObject messageObject;
TLRPC.Chat chat2;
final LongSparseArray longSparseArray = new LongSparseArray();
final LongSparseArray longSparseArray2 = new LongSparseArray();
SparseArray sparseArray = new SparseArray(messages_dialogs.users.size());
SparseArray sparseArray2 = new SparseArray(messages_dialogs.chats.size());
final LongSparseArray longSparseArray3 = new LongSparseArray();
int i2 = 0;
for (int i3 = 0; i3 < messages_dialogs.users.size(); i3++) {
TLRPC.User user = messages_dialogs.users.get(i3);
sparseArray.put(user.id, user);
}
for (int i4 = 0; i4 < messages_dialogs.chats.size(); i4++) {
TLRPC.Chat chat3 = messages_dialogs.chats.get(i4);
sparseArray2.put(chat3.id, chat3);
}
while (true) {
j = 0;
if (i >= messages_dialogs.messages.size()) {
break;
}
TLRPC.Message message = messages_dialogs.messages.get(i);
long j2 = this.proxyDialogId;
if (j2 == 0 || j2 != message.dialog_id) {
if (message.to_id.channel_id != 0) {
TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(message.to_id.channel_id);
i = (chat4 != null && chat4.left) ? i + 1 : 0;
} else if (message.to_id.chat_id != 0 && (chat2 = (TLRPC.Chat) sparseArray2.get(message.to_id.chat_id)) != null && chat2.migrated_to != null) {
}
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
longSparseArray2.put(messageObject2.getDialogId(), messageObject2);
}
while (i2 < messages_dialogs.dialogs.size()) {
TLRPC.Dialog dialog = messages_dialogs.dialogs.get(i2);
DialogObject.initDialog(dialog);
long j3 = this.proxyDialogId;
if (j3 == j || j3 != dialog.id) {
if (DialogObject.isChannel(dialog)) {
TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
if (chat5 != null && chat5.left) {
i2++;
j = 0;
}
} else if (((int) dialog.id) < 0 && (chat = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id))) != null && chat.migrated_to != null) {
i2++;
j = 0;
}
}
if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray2.get(dialog.id)) != null) {
dialog.last_message_date = messageObject.messageOwner.date;
}
longSparseArray.put(dialog.id, dialog);
longSparseArray3.put(dialog.id, Integer.valueOf(dialog.unread_count));
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
num = 0;
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
num2 = 0;
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
i2++;
j = 0;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$154$MessagesController(messages_dialogs, longSparseArray, longSparseArray2, longSparseArray3);
}
});
}
public void lambda$null$154$MessagesController(TLRPC.messages_Dialogs messages_dialogs, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, LongSparseArray longSparseArray3) {
long j;
putUsers(messages_dialogs.users, true);
putChats(messages_dialogs.chats, true);
for (int i = 0; i < longSparseArray.size(); i++) {
long keyAt = longSparseArray.keyAt(i);
TLRPC.Dialog dialog = (TLRPC.Dialog) longSparseArray.valueAt(i);
TLRPC.Dialog dialog2 = this.dialogs_dict.get(keyAt);
if (dialog2 == null) {
this.nextDialogsCacheOffset.put(dialog.folder_id, this.nextDialogsCacheOffset.get(dialog.folder_id, 0) + 1);
this.dialogs_dict.put(keyAt, dialog);
MessageObject messageObject = (MessageObject) longSparseArray2.get(dialog.id);
this.dialogMessage.put(keyAt, messageObject);
if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
}
}
} else {
dialog2.unread_count = dialog.unread_count;
if (dialog2.unread_mentions_count != dialog.unread_mentions_count) {
dialog2.unread_mentions_count = dialog.unread_mentions_count;
if (this.createdDialogMainThreadIds.contains(Long.valueOf(dialog2.id))) {
getNotificationCenter().postNotificationName(NotificationCenter.updateMentionsCount, Long.valueOf(dialog2.id), Integer.valueOf(dialog2.unread_mentions_count));
}
}
MessageObject messageObject2 = this.dialogMessage.get(keyAt);
if (messageObject2 == null || dialog2.top_message > 0) {
if ((messageObject2 != null && messageObject2.deleted) || dialog.top_message > dialog2.top_message) {
this.dialogs_dict.put(keyAt, dialog);
MessageObject messageObject3 = (MessageObject) longSparseArray2.get(dialog.id);
this.dialogMessage.put(keyAt, messageObject3);
if (messageObject3 != null && messageObject3.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject3.getId(), messageObject3);
if (messageObject3.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject3.messageOwner.random_id, messageObject3);
}
}
if (messageObject2 != null) {
this.dialogMessagesByIds.remove(messageObject2.getId());
j = 0;
if (messageObject2.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
}
} else {
j = 0;
}
if (messageObject3 == null) {
checkLastDialogMessage(dialog, null, j);
}
}
} else {
MessageObject messageObject4 = (MessageObject) longSparseArray2.get(dialog.id);
if (messageObject2.deleted || messageObject4 == null || messageObject4.messageOwner.date > messageObject2.messageOwner.date) {
this.dialogs_dict.put(keyAt, dialog);
this.dialogMessage.put(keyAt, messageObject4);
if (messageObject4 != null && messageObject4.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject4.getId(), messageObject4);
if (messageObject4.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject4.messageOwner.random_id, messageObject4);
}
}
this.dialogMessagesByIds.remove(messageObject2.getId());
if (messageObject2.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject2.messageOwner.random_id);
}
}
}
}
}
this.allDialogs.clear();
int size = this.dialogs_dict.size();
for (int i2 = 0; i2 < size; i2++) {
this.allDialogs.add(this.dialogs_dict.valueAt(i2));
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
getNotificationsController().processDialogsUpdateRead(longSparseArray3);
}
public void addToViewsQueue(final MessageObject messageObject) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$addToViewsQueue$156$MessagesController(messageObject);
}
});
}
public void lambda$addToViewsQueue$156$MessagesController(MessageObject messageObject) {
int dialogId = (int) messageObject.getDialogId();
int id = messageObject.getId();
ArrayList<Integer> arrayList = this.channelViewsToSend.get(dialogId);
if (arrayList == null) {
arrayList = new ArrayList<>();
this.channelViewsToSend.put(dialogId, arrayList);
}
if (arrayList.contains(Integer.valueOf(id))) {
return;
}
arrayList.add(Integer.valueOf(id));
}
public void addToPollsQueue(long j, ArrayList<MessageObject> arrayList) {
SparseArray<MessageObject> sparseArray = this.pollsToCheck.get(j);
if (sparseArray == null) {
sparseArray = new SparseArray<>();
this.pollsToCheck.put(j, sparseArray);
this.pollsToCheckSize++;
}
int size = sparseArray.size();
for (int i = 0; i < size; i++) {
sparseArray.valueAt(i).pollVisibleOnScreen = false;
}
int size2 = arrayList.size();
for (int i2 = 0; i2 < size2; i2++) {
MessageObject messageObject = arrayList.get(i2);
if (messageObject.type == 17) {
int id = messageObject.getId();
MessageObject messageObject2 = sparseArray.get(id);
if (messageObject2 != null) {
messageObject2.pollVisibleOnScreen = true;
} else {
sparseArray.put(id, messageObject);
}
}
}
}
public void markMessageContentAsRead(MessageObject messageObject) {
if (messageObject.scheduled) {
return;
}
ArrayList<Long> arrayList = new ArrayList<>();
long id = messageObject.getId();
if (messageObject.messageOwner.to_id.channel_id != 0) {
id |= messageObject.messageOwner.to_id.channel_id << 32;
}
if (messageObject.messageOwner.mentioned) {
getMessagesStorage().markMentionMessageAsRead(messageObject.getId(), messageObject.messageOwner.to_id.channel_id, messageObject.getDialogId());
}
arrayList.add(Long.valueOf(id));
getMessagesStorage().markMessagesContentAsRead(arrayList, 0);
getNotificationCenter().postNotificationName(NotificationCenter.messagesReadContent, arrayList);
if (messageObject.getId() < 0) {
markMessageAsRead(messageObject.getDialogId(), messageObject.messageOwner.random_id, Integer.MIN_VALUE);
return;
}
if (messageObject.messageOwner.to_id.channel_id != 0) {
TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
tL_channels_readMessageContents.channel = getInputChannel(messageObject.messageOwner.to_id.channel_id);
if (tL_channels_readMessageContents.channel == null) {
return;
}
tL_channels_readMessageContents.id.add(Integer.valueOf(messageObject.getId()));
getConnectionsManager().sendRequest(tL_channels_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$markMessageContentAsRead$157(tLObject, tL_error);
}
});
return;
}
TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
tL_messages_readMessageContents.id.add(Integer.valueOf(messageObject.getId()));
getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markMessageContentAsRead$158$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$markMessageContentAsRead$158$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
}
}
public void markMentionMessageAsRead(int i, int i2, long j) {
getMessagesStorage().markMentionMessageAsRead(i, i2, j);
if (i2 != 0) {
TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
tL_channels_readMessageContents.channel = getInputChannel(i2);
if (tL_channels_readMessageContents.channel == null) {
return;
}
tL_channels_readMessageContents.id.add(Integer.valueOf(i));
getConnectionsManager().sendRequest(tL_channels_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$markMentionMessageAsRead$159(tLObject, tL_error);
}
});
return;
}
TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
tL_messages_readMessageContents.id.add(Integer.valueOf(i));
getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markMentionMessageAsRead$160$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$markMentionMessageAsRead$160$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
}
}
public void markMessageAsRead(int i, int i2, TLRPC.InputChannel inputChannel, int i3, final long j) {
NativeByteBuffer nativeByteBuffer;
if (i == 0 || i3 <= 0) {
return;
}
if (i2 != 0 && inputChannel == null && (inputChannel = getInputChannel(i2)) == null) {
return;
}
if (j == 0) {
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(16 + (inputChannel != null ? inputChannel.getObjectSize() : 0));
try {
nativeByteBuffer.writeInt32(11);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeInt32(i2);
nativeByteBuffer.writeInt32(i3);
if (i2 != 0) {
inputChannel.serializeToStream(nativeByteBuffer);
}
} catch (Exception e) {
e = e;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
int currentTime = getConnectionsManager().getCurrentTime();
getMessagesStorage().createTaskForMid(i, i2, currentTime, currentTime, i3, false);
if (i2 == 0) {
}
}
} catch (Exception e2) {
e = e2;
}
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
int currentTime2 = getConnectionsManager().getCurrentTime();
getMessagesStorage().createTaskForMid(i, i2, currentTime2, currentTime2, i3, false);
if (i2 == 0) {
TLRPC.TL_channels_readMessageContents tL_channels_readMessageContents = new TLRPC.TL_channels_readMessageContents();
tL_channels_readMessageContents.channel = inputChannel;
tL_channels_readMessageContents.id.add(Integer.valueOf(i));
getConnectionsManager().sendRequest(tL_channels_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markMessageAsRead$161$MessagesController(j, tLObject, tL_error);
}
});
return;
}
TLRPC.TL_messages_readMessageContents tL_messages_readMessageContents = new TLRPC.TL_messages_readMessageContents();
tL_messages_readMessageContents.id.add(Integer.valueOf(i));
getConnectionsManager().sendRequest(tL_messages_readMessageContents, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markMessageAsRead$162$MessagesController(j, tLObject, tL_error);
}
});
}
public void lambda$markMessageAsRead$161$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void lambda$markMessageAsRead$162$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void markMessageAsRead(long j, long j2, int i) {
TLRPC.EncryptedChat encryptedChat;
if (j2 == 0 || j == 0) {
return;
}
if (i > 0 || i == Integer.MIN_VALUE) {
int i2 = (int) (j >> 32);
if (((int) j) == 0 && (encryptedChat = getEncryptedChat(Integer.valueOf(i2))) != null) {
ArrayList<Long> arrayList = new ArrayList<>();
arrayList.add(Long.valueOf(j2));
getSecretChatHelper().sendMessagesReadMessage(encryptedChat, arrayList, null);
if (i > 0) {
int currentTime = getConnectionsManager().getCurrentTime();
getMessagesStorage().createTaskForSecretChat(encryptedChat.id, currentTime, currentTime, 0, arrayList);
}
}
}
}
private void completeReadTask(ReadTask readTask) {
TLRPC.TL_messages_readHistory tL_messages_readHistory;
int i = (int) readTask.dialogId;
int i2 = (int) (readTask.dialogId >> 32);
if (i != 0) {
TLRPC.InputPeer inputPeer = getInputPeer(i);
if (inputPeer instanceof TLRPC.TL_inputPeerChannel) {
TLRPC.TL_channels_readHistory tL_channels_readHistory = new TLRPC.TL_channels_readHistory();
tL_channels_readHistory.channel = getInputChannel(-i);
tL_channels_readHistory.max_id = readTask.maxId;
tL_messages_readHistory = tL_channels_readHistory;
} else {
TLRPC.TL_messages_readHistory tL_messages_readHistory2 = new TLRPC.TL_messages_readHistory();
tL_messages_readHistory2.peer = inputPeer;
tL_messages_readHistory2.max_id = readTask.maxId;
tL_messages_readHistory = tL_messages_readHistory2;
}
getConnectionsManager().sendRequest(tL_messages_readHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$completeReadTask$163$MessagesController(tLObject, tL_error);
}
});
return;
}
TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i2));
if (encryptedChat.auth_key == null || encryptedChat.auth_key.length <= 1 || !(encryptedChat instanceof TLRPC.TL_encryptedChat)) {
return;
}
TLRPC.TL_messages_readEncryptedHistory tL_messages_readEncryptedHistory = new TLRPC.TL_messages_readEncryptedHistory();
tL_messages_readEncryptedHistory.peer = new TLRPC.TL_inputEncryptedChat();
tL_messages_readEncryptedHistory.peer.chat_id = encryptedChat.id;
tL_messages_readEncryptedHistory.peer.access_hash = encryptedChat.access_hash;
tL_messages_readEncryptedHistory.max_date = readTask.maxDate;
getConnectionsManager().sendRequest(tL_messages_readEncryptedHistory, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$completeReadTask$164(tLObject, tL_error);
}
});
}
public void lambda$completeReadTask$163$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null && (tLObject instanceof TLRPC.TL_messages_affectedMessages)) {
TLRPC.TL_messages_affectedMessages tL_messages_affectedMessages = (TLRPC.TL_messages_affectedMessages) tLObject;
processNewDifferenceParams(-1, tL_messages_affectedMessages.pts, -1, tL_messages_affectedMessages.pts_count);
}
}
private void checkReadTasks() {
long elapsedRealtime = SystemClock.elapsedRealtime();
int size = this.readTasks.size();
int i = 0;
while (i < size) {
ReadTask readTask = this.readTasks.get(i);
if (readTask.sendRequestTime <= elapsedRealtime) {
completeReadTask(readTask);
this.readTasks.remove(i);
this.readTasksMap.remove(readTask.dialogId);
i--;
size--;
}
i++;
}
}
public void markDialogAsReadNow(final long j) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$markDialogAsReadNow$165$MessagesController(j);
}
});
}
public void lambda$markDialogAsReadNow$165$MessagesController(long j) {
ReadTask readTask = this.readTasksMap.get(j);
if (readTask == null) {
return;
}
completeReadTask(readTask);
this.readTasks.remove(readTask);
this.readTasksMap.remove(j);
}
public void markMentionsAsRead(long j) {
int i = (int) j;
if (i == 0) {
return;
}
getMessagesStorage().resetMentionsCount(j, 0);
TLRPC.TL_messages_readMentions tL_messages_readMentions = new TLRPC.TL_messages_readMentions();
tL_messages_readMentions.peer = getInputPeer(i);
getConnectionsManager().sendRequest(tL_messages_readMentions, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$markMentionsAsRead$166(tLObject, tL_error);
}
});
}
public void markDialogAsRead(final long j, final int i, final int i2, final int i3, final boolean z, final int i4, final boolean z2, int i5) {
long j2;
boolean z3;
long j3;
Integer num;
int i6 = (int) j;
int i7 = (int) (j >> 32);
final boolean z4 = getNotificationsController().showBadgeMessages;
boolean z5 = true;
if (i6 != 0) {
if (i == 0) {
return;
}
long j4 = i;
long j5 = i2;
if (i6 < 0) {
int i8 = -i6;
if (ChatObject.isChannel(getChat(Integer.valueOf(i8)))) {
long j6 = i8 << 32;
j2 = j6 | j5;
j3 = j4 | j6;
z3 = true;
num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
if (num == null) {
num = 0;
}
this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(num.intValue(), i)));
getMessagesStorage().processPendingRead(j, j3, j2, z3, i5);
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$markDialogAsRead$168$MessagesController(j, i4, i, z4, z);
}
});
if (i == Integer.MAX_VALUE) {
z5 = false;
}
}
}
j2 = j5;
z3 = false;
j3 = j4;
num = this.dialogs_read_inbox_max.get(Long.valueOf(j));
if (num == null) {
}
this.dialogs_read_inbox_max.put(Long.valueOf(j), Integer.valueOf(Math.max(num.intValue(), i)));
getMessagesStorage().processPendingRead(j, j3, j2, z3, i5);
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$markDialogAsRead$168$MessagesController(j, i4, i, z4, z);
}
});
if (i == Integer.MAX_VALUE) {
}
} else {
if (i3 == 0) {
return;
}
TLRPC.EncryptedChat encryptedChat = getEncryptedChat(Integer.valueOf(i7));
getMessagesStorage().processPendingRead(j, i, i2, false, i5);
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$markDialogAsRead$170$MessagesController(j, i3, z, i4, i2, z4);
}
});
if (encryptedChat != null && encryptedChat.ttl > 0) {
int max = Math.max(getConnectionsManager().getCurrentTime(), i3);
getMessagesStorage().createTaskForSecretChat(encryptedChat.id, max, max, 0, null);
}
}
if (z5) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$markDialogAsRead$171$MessagesController(j, z2, i3, i);
}
});
}
}
public void lambda$markDialogAsRead$168$MessagesController(final long j, final int i, final int i2, final boolean z, final boolean z2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$167$MessagesController(j, i, i2, z, z2);
}
});
}
public void lambda$null$167$MessagesController(long j, int i, int i2, boolean z, boolean z2) {
TLRPC.Dialog dialog;
TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
if (dialog2 != null) {
int i3 = dialog2.unread_count;
if (i == 0 || i2 >= dialog2.top_message) {
dialog2.unread_count = 0;
} else {
dialog2.unread_count = Math.max(dialog2.unread_count - i, 0);
if (i2 != Integer.MIN_VALUE && dialog2.unread_count > dialog2.top_message - i2) {
dialog2.unread_count = dialog2.top_message - i2;
}
}
if (dialog2.folder_id != 0 && (dialog = this.dialogs_dict.get(DialogObject.makeFolderDialogId(dialog2.folder_id))) != null) {
if (z) {
if (isDialogMuted(dialog2.id)) {
dialog.unread_count -= i3 - dialog2.unread_count;
} else {
dialog.unread_mentions_count -= i3 - dialog2.unread_count;
}
} else if (dialog2.unread_count == 0) {
if (isDialogMuted(dialog2.id)) {
dialog.unread_count--;
} else {
dialog.unread_mentions_count--;
}
}
}
if ((i3 != 0 || dialog2.unread_mark) && dialog2.unread_count == 0 && !isDialogMuted(j)) {
this.unreadUnmutedDialogs--;
}
if (dialog2.unread_mark) {
dialog2.unread_mark = false;
getMessagesStorage().setDialogUnread(dialog2.id, false);
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
}
if (!z2) {
getNotificationsController().processReadMessages(null, j, 0, i2, false);
LongSparseArray<Integer> longSparseArray = new LongSparseArray<>(1);
longSparseArray.put(j, 0);
getNotificationsController().processDialogsUpdateRead(longSparseArray);
return;
}
getNotificationsController().processReadMessages(null, j, 0, i2, true);
LongSparseArray<Integer> longSparseArray2 = new LongSparseArray<>(1);
longSparseArray2.put(j, -1);
getNotificationsController().processDialogsUpdateRead(longSparseArray2);
}
public void lambda$markDialogAsRead$170$MessagesController(final long j, final int i, final boolean z, final int i2, final int i3, final boolean z2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$169$MessagesController(j, i, z, i2, i3, z2);
}
});
}
public void lambda$null$169$MessagesController(long j, int i, boolean z, int i2, int i3, boolean z2) {
TLRPC.Dialog dialog;
getNotificationsController().processReadMessages(null, j, i, 0, z);
TLRPC.Dialog dialog2 = this.dialogs_dict.get(j);
if (dialog2 != null) {
int i4 = dialog2.unread_count;
if (i2 == 0 || i3 <= dialog2.top_message) {
dialog2.unread_count = 0;
} else {
dialog2.unread_count = Math.max(dialog2.unread_count - i2, 0);
if (i3 != Integer.MAX_VALUE && dialog2.unread_count > i3 - dialog2.top_message) {
dialog2.unread_count = i3 - dialog2.top_message;
}
}
if (dialog2.folder_id != 0 && (dialog = this.dialogs_dict.get(DialogObject.makeFolderDialogId(dialog2.folder_id))) != null) {
if (z2) {
if (isDialogMuted(dialog2.id)) {
dialog.unread_count -= i4 - dialog2.unread_count;
} else {
dialog.unread_mentions_count -= i4 - dialog2.unread_count;
}
} else if (dialog2.unread_count == 0) {
if (isDialogMuted(dialog2.id)) {
dialog.unread_count--;
} else {
dialog.unread_mentions_count--;
}
}
}
if ((i4 != 0 || dialog2.unread_mark) && dialog2.unread_count == 0 && !isDialogMuted(j)) {
this.unreadUnmutedDialogs--;
}
if (dialog2.unread_mark) {
dialog2.unread_mark = false;
getMessagesStorage().setDialogUnread(dialog2.id, false);
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
}
LongSparseArray<Integer> longSparseArray = new LongSparseArray<>(1);
longSparseArray.put(j, 0);
getNotificationsController().processDialogsUpdateRead(longSparseArray);
}
public void lambda$markDialogAsRead$171$MessagesController(long j, boolean z, int i, int i2) {
ReadTask readTask = this.readTasksMap.get(j);
if (readTask == null) {
readTask = new ReadTask();
readTask.dialogId = j;
readTask.sendRequestTime = SystemClock.elapsedRealtime() + DefaultRenderersFactory.DEFAULT_ALLOWED_VIDEO_JOINING_TIME_MS;
if (!z) {
this.readTasksMap.put(j, readTask);
this.readTasks.add(readTask);
}
}
readTask.maxDate = i;
readTask.maxId = i2;
if (z) {
completeReadTask(readTask);
}
}
public int createChat(String str, ArrayList<Integer> arrayList, String str2, int i, BDLocation bDLocation, String str3, final BaseFragment baseFragment) {
if (i == 0) {
final TLRPC.TL_messages_createChat tL_messages_createChat = new TLRPC.TL_messages_createChat();
tL_messages_createChat.title = str;
for (int i2 = 0; i2 < arrayList.size(); i2++) {
TLRPC.User user = getUser(arrayList.get(i2));
if (user != null) {
tL_messages_createChat.users.add(getInputUser(user));
}
}
return getConnectionsManager().sendRequest(tL_messages_createChat, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$createChat$174$MessagesController(baseFragment, tL_messages_createChat, tLObject, tL_error);
}
}, 2);
}
if (i != 2 && i != 4) {
return 0;
}
final TLRPC.TL_channels_createChannel tL_channels_createChannel = new TLRPC.TL_channels_createChannel();
tL_channels_createChannel.title = str;
if (str2 == null) {
str2 = "";
}
tL_channels_createChannel.about = str2;
if (i == 4) {
tL_channels_createChannel.megagroup = true;
} else {
tL_channels_createChannel.broadcast = true;
}
if (bDLocation != null) {
tL_channels_createChannel.geo_point = new TLRPC.TL_inputGeoPoint();
tL_channels_createChannel.geo_point.lat = bDLocation.getLatitude();
tL_channels_createChannel.geo_point._long = bDLocation.getLongitude();
tL_channels_createChannel.address = str3;
tL_channels_createChannel.flags |= 4;
}
return getConnectionsManager().sendRequest(tL_channels_createChannel, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$createChat$177$MessagesController(baseFragment, tL_channels_createChannel, tLObject, tL_error);
}
}, 2);
}
public void lambda$createChat$174$MessagesController(final BaseFragment baseFragment, final TLRPC.TL_messages_createChat tL_messages_createChat, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$172$MessagesController(tL_error, baseFragment, tL_messages_createChat);
}
});
return;
}
final TLRPC.Updates updates = (TLRPC.Updates) tLObject;
processUpdates(updates, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$173$MessagesController(updates);
}
});
}
public void lambda$null$172$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_createChat tL_messages_createChat) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_createChat, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
public void lambda$null$173$MessagesController(TLRPC.Updates updates) {
putUsers(updates.users, false);
putChats(updates.chats, false);
if (updates.chats != null && !updates.chats.isEmpty()) {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
} else {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
}
public void lambda$createChat$177$MessagesController(final BaseFragment baseFragment, final TLRPC.TL_channels_createChannel tL_channels_createChannel, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$175$MessagesController(tL_error, baseFragment, tL_channels_createChannel);
}
});
return;
}
final TLRPC.Updates updates = (TLRPC.Updates) tLObject;
processUpdates(updates, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$176$MessagesController(updates);
}
});
}
public void lambda$null$175$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_createChannel tL_channels_createChannel) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_createChannel, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
public void lambda$null$176$MessagesController(TLRPC.Updates updates) {
putUsers(updates.users, false);
putChats(updates.chats, false);
if (updates.chats != null && !updates.chats.isEmpty()) {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
} else {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
}
public int createMegaGroup(String str, final ArrayList<Integer> arrayList, String str2, int i, BDLocation bDLocation, String str3, final BaseFragment baseFragment, boolean z) {
if (i != 2 && i != 4) {
return 0;
}
final TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1 = new TLRPCChats.TL_channels_createChannel_v1();
tL_channels_createChannel_v1.title = str;
if (str2 == null) {
str2 = "";
}
tL_channels_createChannel_v1.about = str2;
tL_channels_createChannel_v1.ban_add_contact = z;
if (i == 4) {
tL_channels_createChannel_v1.megagroup = true;
} else {
tL_channels_createChannel_v1.broadcast = true;
}
if (bDLocation != null) {
tL_channels_createChannel_v1.geo_point = new TLRPC.TL_inputGeoPoint();
tL_channels_createChannel_v1.geo_point.lat = bDLocation.getLatitude();
tL_channels_createChannel_v1.geo_point._long = bDLocation.getLongitude();
tL_channels_createChannel_v1.address = str3;
tL_channels_createChannel_v1.flags |= 4;
}
return getConnectionsManager().sendRequest(tL_channels_createChannel_v1, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$createMegaGroup$180$MessagesController(baseFragment, tL_channels_createChannel_v1, arrayList, tLObject, tL_error);
}
}, 2);
}
public void lambda$createMegaGroup$180$MessagesController(final BaseFragment baseFragment, final TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1, ArrayList arrayList, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$178$MessagesController(tL_error, baseFragment, tL_channels_createChannel_v1);
}
});
return;
}
final TLRPC.Updates updates = (TLRPC.Updates) tLObject;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$179$MessagesController(updates);
}
});
ArrayList<TLRPC.InputUser> arrayList2 = new ArrayList<>();
for (int i = 0; i < arrayList.size(); i++) {
TLRPC.InputUser inputUser = getInstance(this.currentAccount).getInputUser(getInstance(this.currentAccount).getUser((Integer) arrayList.get(i)));
if (inputUser != null) {
arrayList2.add(inputUser);
}
}
getInstance(this.currentAccount).addUsersToChannelWithCreate(updates.chats.get(0), arrayList2, null);
processUpdates(updates, false);
}
public void lambda$null$178$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPCChats.TL_channels_createChannel_v1 tL_channels_createChannel_v1) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_createChannel_v1, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
public void lambda$null$179$MessagesController(TLRPC.Updates updates) {
putUsers(updates.users, false);
putChats(updates.chats, false);
if (updates.chats != null && !updates.chats.isEmpty()) {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidCreated, Integer.valueOf(updates.chats.get(0).id));
} else {
getNotificationCenter().postNotificationName(NotificationCenter.chatDidFailCreate, new Object[0]);
}
}
public void addUsersToChannelWithCreate(TLRPC.Chat chat, ArrayList<TLRPC.InputUser> arrayList, final BaseFragment baseFragment) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
final TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
tL_channels_inviteToChannel.channel = getInputChannel(chat);
tL_channels_inviteToChannel.users = arrayList;
getConnectionsManager().sendRequest(tL_channels_inviteToChannel, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$addUsersToChannelWithCreate$182$MessagesController(baseFragment, tL_channels_inviteToChannel, tLObject, tL_error);
}
});
}
public void lambda$addUsersToChannelWithCreate$182$MessagesController(final BaseFragment baseFragment, final TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$181$MessagesController(tL_error, baseFragment, tL_channels_inviteToChannel);
}
});
} else {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void lambda$null$181$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_inviteToChannel, true);
}
public void convertToMegaGroup(final Context context, int i, final BaseFragment baseFragment, final MessagesStorage.IntCallback intCallback) {
final TLRPC.TL_messages_migrateChat tL_messages_migrateChat = new TLRPC.TL_messages_migrateChat();
tL_messages_migrateChat.chat_id = i;
final AlertDialog alertDialog = new AlertDialog(context, 3);
final int sendRequest = getConnectionsManager().sendRequest(tL_messages_migrateChat, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$convertToMegaGroup$186$MessagesController(context, alertDialog, intCallback, baseFragment, tL_messages_migrateChat, tLObject, tL_error);
}
});
alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
MessagesController.this.lambda$convertToMegaGroup$187$MessagesController(sendRequest, dialogInterface);
}
});
try {
alertDialog.show();
} catch (Exception unused) {
}
}
public void lambda$convertToMegaGroup$186$MessagesController(final Context context, final AlertDialog alertDialog, final MessagesStorage.IntCallback intCallback, final BaseFragment baseFragment, final TLRPC.TL_messages_migrateChat tL_messages_migrateChat, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error == null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.lambda$null$183(context, alertDialog);
}
});
final TLRPC.Updates updates = (TLRPC.Updates) tLObject;
processUpdates(updates, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.lambda$null$184(MessagesStorage.IntCallback.this, updates);
}
});
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$185$MessagesController(intCallback, context, alertDialog, tL_error, baseFragment, tL_messages_migrateChat);
}
});
}
public static void lambda$null$183(Context context, AlertDialog alertDialog) {
if (((Activity) context).isFinishing()) {
return;
}
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
}
public static void lambda$null$184(MessagesStorage.IntCallback intCallback, TLRPC.Updates updates) {
if (intCallback != null) {
for (int i = 0; i < updates.chats.size(); i++) {
TLRPC.Chat chat = updates.chats.get(i);
if (ChatObject.isChannel(chat)) {
intCallback.run(chat.id);
return;
}
}
}
}
public void lambda$null$185$MessagesController(MessagesStorage.IntCallback intCallback, Context context, AlertDialog alertDialog, TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_messages_migrateChat tL_messages_migrateChat) {
if (intCallback != null) {
intCallback.run(0);
}
if (((Activity) context).isFinishing()) {
return;
}
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_messages_migrateChat, false);
}
public void lambda$convertToMegaGroup$187$MessagesController(int i, DialogInterface dialogInterface) {
getConnectionsManager().cancelRequest(i, true);
}
public void addUsersToChannel(int i, ArrayList<TLRPC.InputUser> arrayList, final BaseFragment baseFragment) {
if (arrayList == null || arrayList.isEmpty()) {
return;
}
final TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
tL_channels_inviteToChannel.channel = getInputChannel(i);
tL_channels_inviteToChannel.users = arrayList;
getConnectionsManager().sendRequest(tL_channels_inviteToChannel, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$addUsersToChannel$189$MessagesController(baseFragment, tL_channels_inviteToChannel, tLObject, tL_error);
}
});
}
public void lambda$addUsersToChannel$189$MessagesController(final BaseFragment baseFragment, final TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel, TLObject tLObject, final TLRPC.TL_error tL_error) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$188$MessagesController(tL_error, baseFragment, tL_channels_inviteToChannel);
}
});
} else {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void lambda$null$188$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel) {
AlertsCreator.processError(this.currentAccount, tL_error, baseFragment, tL_channels_inviteToChannel, true);
}
public void toogleChannelSignatures(int i, boolean z) {
TLRPC.TL_channels_toggleSignatures tL_channels_toggleSignatures = new TLRPC.TL_channels_toggleSignatures();
tL_channels_toggleSignatures.channel = getInputChannel(i);
tL_channels_toggleSignatures.enabled = z;
getConnectionsManager().sendRequest(tL_channels_toggleSignatures, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$toogleChannelSignatures$191$MessagesController(tLObject, tL_error);
}
}, 64);
}
public void lambda$toogleChannelSignatures$191$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$190$MessagesController();
}
});
}
}
public void lambda$null$190$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
}
public void toogleChannelInvitesHistory(int i, boolean z) {
TLRPC.TL_channels_togglePreHistoryHidden tL_channels_togglePreHistoryHidden = new TLRPC.TL_channels_togglePreHistoryHidden();
tL_channels_togglePreHistoryHidden.channel = getInputChannel(i);
tL_channels_togglePreHistoryHidden.enabled = z;
getConnectionsManager().sendRequest(tL_channels_togglePreHistoryHidden, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$toogleChannelInvitesHistory$193$MessagesController(tLObject, tL_error);
}
}, 64);
}
public void lambda$toogleChannelInvitesHistory$193$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
processUpdates((TLRPC.Updates) tLObject, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$192$MessagesController();
}
});
}
}
public void lambda$null$192$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
}
public void updateChatAbout(int i, final String str, final TLRPC.ChatFull chatFull) {
if (chatFull == null) {
return;
}
TLRPC.TL_messages_editChatAbout tL_messages_editChatAbout = new TLRPC.TL_messages_editChatAbout();
tL_messages_editChatAbout.peer = getInputPeer(-i);
tL_messages_editChatAbout.about = str;
getConnectionsManager().sendRequest(tL_messages_editChatAbout, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateChatAbout$195$MessagesController(chatFull, str, tLObject, tL_error);
}
}, 64);
}
public void lambda$updateChatAbout$195$MessagesController(final TLRPC.ChatFull chatFull, final String str, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_boolTrue) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$194$MessagesController(chatFull, str);
}
});
}
}
public void lambda$null$194$MessagesController(TLRPC.ChatFull chatFull, String str) {
chatFull.about = str;
getMessagesStorage().updateChatInfo(chatFull, false);
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, null);
}
public void updateChannelUserName(final int i, final String str) {
TLRPC.TL_channels_updateUsername tL_channels_updateUsername = new TLRPC.TL_channels_updateUsername();
tL_channels_updateUsername.channel = getInputChannel(i);
tL_channels_updateUsername.username = str;
getConnectionsManager().sendRequest(tL_channels_updateUsername, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$updateChannelUserName$197$MessagesController(i, str, tLObject, tL_error);
}
}, 64);
}
public void lambda$updateChannelUserName$197$MessagesController(final int i, final String str, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_boolTrue) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$196$MessagesController(i, str);
}
});
}
}
public void lambda$null$196$MessagesController(int i, String str) {
TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (str.length() != 0) {
chat.flags |= 64;
} else {
chat.flags &= -65;
}
chat.username = str;
ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
arrayList.add(chat);
getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
}
public void sendBotStart(TLRPC.User user, String str) {
if (user == null) {
return;
}
TLRPC.TL_messages_startBot tL_messages_startBot = new TLRPC.TL_messages_startBot();
tL_messages_startBot.bot = getInputUser(user);
tL_messages_startBot.peer = getInputPeer(user.id);
tL_messages_startBot.start_param = str;
tL_messages_startBot.random_id = Utilities.random.nextLong();
getConnectionsManager().sendRequest(tL_messages_startBot, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$sendBotStart$198$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$sendBotStart$198$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error != null) {
return;
}
processUpdates((TLRPC.Updates) tLObject, false);
}
public boolean isJoiningChannel(int i) {
return this.joiningToChannels.contains(Integer.valueOf(i));
}
public void addUserToChat(final int i, TLRPC.User user, TLRPC.ChatFull chatFull, int i2, String str, final BaseFragment baseFragment, final Runnable runnable) {
TLRPC.TL_messages_addChatUser tL_messages_addChatUser;
if (user == null) {
return;
}
if (i > 0) {
final boolean isChannel = ChatObject.isChannel(i, this.currentAccount);
final boolean z = isChannel && getChat(Integer.valueOf(i)).megagroup;
final TLRPC.InputUser inputUser = getInputUser(user);
if (str != null && (!isChannel || z)) {
TLRPC.TL_messages_startBot tL_messages_startBot = new TLRPC.TL_messages_startBot();
tL_messages_startBot.bot = inputUser;
if (isChannel) {
tL_messages_startBot.peer = getInputPeer(-i);
} else {
tL_messages_startBot.peer = new TLRPC.TL_inputPeerChat();
tL_messages_startBot.peer.chat_id = i;
}
tL_messages_startBot.start_param = str;
tL_messages_startBot.random_id = Utilities.random.nextLong();
tL_messages_addChatUser = tL_messages_startBot;
} else if (isChannel) {
if (inputUser instanceof TLRPC.TL_inputUserSelf) {
if (this.joiningToChannels.contains(Integer.valueOf(i))) {
return;
}
TLRPC.TL_channels_joinChannel tL_channels_joinChannel = new TLRPC.TL_channels_joinChannel();
tL_channels_joinChannel.channel = getInputChannel(i);
this.joiningToChannels.add(Integer.valueOf(i));
tL_messages_addChatUser = tL_channels_joinChannel;
} else {
TLRPC.TL_channels_inviteToChannel tL_channels_inviteToChannel = new TLRPC.TL_channels_inviteToChannel();
tL_channels_inviteToChannel.channel = getInputChannel(i);
tL_channels_inviteToChannel.users.add(inputUser);
tL_messages_addChatUser = tL_channels_inviteToChannel;
}
} else {
TLRPC.TL_messages_addChatUser tL_messages_addChatUser2 = new TLRPC.TL_messages_addChatUser();
tL_messages_addChatUser2.chat_id = i;
tL_messages_addChatUser2.fwd_limit = i2;
tL_messages_addChatUser2.user_id = inputUser;
tL_messages_addChatUser = tL_messages_addChatUser2;
}
final TLRPC.TL_messages_addChatUser tL_messages_addChatUser3 = tL_messages_addChatUser;
getConnectionsManager().sendRequest(tL_messages_addChatUser3, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$addUserToChat$202$MessagesController(isChannel, inputUser, i, baseFragment, tL_messages_addChatUser3, z, runnable, tLObject, tL_error);
}
});
return;
}
if (chatFull instanceof TLRPC.TL_chatFull) {
for (int i3 = 0; i3 < chatFull.participants.participants.size(); i3++) {
if (chatFull.participants.participants.get(i3).user_id == user.id) {
return;
}
}
TLRPC.Chat chat = getChat(Integer.valueOf(i));
chat.participants_count++;
ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
arrayList.add(chat);
getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
TLRPC.TL_chatParticipant tL_chatParticipant = new TLRPC.TL_chatParticipant();
tL_chatParticipant.user_id = user.id;
tL_chatParticipant.inviter_id = getUserConfig().getClientUserId();
tL_chatParticipant.date = getConnectionsManager().getCurrentTime();
chatFull.participants.participants.add(0, tL_chatParticipant);
getMessagesStorage().updateChatInfo(chatFull, true);
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, null);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 32);
}
}
public void lambda$addUserToChat$202$MessagesController(final boolean z, final TLRPC.InputUser inputUser, final int i, final BaseFragment baseFragment, final TLObject tLObject, final boolean z2, Runnable runnable, TLObject tLObject2, final TLRPC.TL_error tL_error) {
boolean z3;
if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$199$MessagesController(i);
}
});
}
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$200$MessagesController(tL_error, baseFragment, tLObject, z, z2, inputUser);
}
});
return;
}
TLRPC.Updates updates = (TLRPC.Updates) tLObject2;
int i2 = 0;
while (true) {
if (i2 >= updates.updates.size()) {
z3 = false;
break;
}
TLRPC.Update update = updates.updates.get(i2);
if ((update instanceof TLRPC.TL_updateNewChannelMessage) && (((TLRPC.TL_updateNewChannelMessage) update).message.action instanceof TLRPC.TL_messageActionChatAddUser)) {
z3 = true;
break;
}
i2++;
}
processUpdates(updates, false);
if (z) {
if (!z3 && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
generateJoinMessage(i, true);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$201$MessagesController(i);
}
}, 1000L);
}
if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
getMessagesStorage().updateDialogsWithDeletedMessages(new ArrayList<>(), null, true, i);
}
if (runnable != null) {
AndroidUtilities.runOnUIThread(runnable);
}
}
public void lambda$null$199$MessagesController(int i) {
this.joiningToChannels.remove(Integer.valueOf(i));
}
public void lambda$null$200$MessagesController(TLRPC.TL_error tL_error, BaseFragment baseFragment, TLObject tLObject, boolean z, boolean z2, TLRPC.InputUser inputUser) {
int i = this.currentAccount;
Object[] objArr = new Object[1];
objArr[0] = Boolean.valueOf(z && !z2);
AlertsCreator.processError(i, tL_error, baseFragment, tLObject, objArr);
if (z && (inputUser instanceof TLRPC.TL_inputUserSelf)) {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 8192);
}
}
public void lambda$null$201$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void deleteUserFromChat(int i, TLRPC.User user, TLRPC.ChatFull chatFull) {
deleteUserFromChat(i, user, chatFull, false, false);
}
public void deleteUserFromChat(final int i, TLRPC.User user, TLRPC.ChatFull chatFull, boolean z, boolean z2) {
boolean z3;
TLRPC.TL_messages_deleteChatUser tL_messages_deleteChatUser;
if (user == null) {
return;
}
if (i > 0) {
final TLRPC.InputUser inputUser = getInputUser(user);
TLRPC.Chat chat = getChat(Integer.valueOf(i));
final boolean isChannel = ChatObject.isChannel(chat);
if (isChannel) {
if (inputUser instanceof TLRPC.TL_inputUserSelf) {
if (chat.creator && z) {
TLRPC.TL_channels_deleteChannel tL_channels_deleteChannel = new TLRPC.TL_channels_deleteChannel();
tL_channels_deleteChannel.channel = getInputChannel(chat);
tL_messages_deleteChatUser = tL_channels_deleteChannel;
} else {
TLRPC.TL_channels_leaveChannel tL_channels_leaveChannel = new TLRPC.TL_channels_leaveChannel();
tL_channels_leaveChannel.channel = getInputChannel(chat);
tL_messages_deleteChatUser = tL_channels_leaveChannel;
}
} else {
TLRPC.TL_channels_editBanned tL_channels_editBanned = new TLRPC.TL_channels_editBanned();
tL_channels_editBanned.channel = getInputChannel(chat);
tL_channels_editBanned.user_id = inputUser;
tL_channels_editBanned.banned_rights = new TLRPC.TL_chatBannedRights();
tL_channels_editBanned.banned_rights.view_messages = true;
tL_channels_editBanned.banned_rights.send_media = true;
tL_channels_editBanned.banned_rights.send_messages = true;
tL_channels_editBanned.banned_rights.send_stickers = true;
tL_channels_editBanned.banned_rights.send_gifs = true;
tL_channels_editBanned.banned_rights.send_games = true;
tL_channels_editBanned.banned_rights.send_inline = true;
tL_channels_editBanned.banned_rights.embed_links = true;
tL_channels_editBanned.banned_rights.pin_messages = true;
tL_channels_editBanned.banned_rights.send_polls = true;
tL_channels_editBanned.banned_rights.invite_users = true;
tL_channels_editBanned.banned_rights.change_info = true;
tL_messages_deleteChatUser = tL_channels_editBanned;
}
} else {
TLRPC.TL_messages_deleteChatUser tL_messages_deleteChatUser2 = new TLRPC.TL_messages_deleteChatUser();
tL_messages_deleteChatUser2.chat_id = i;
tL_messages_deleteChatUser2.user_id = getInputUser(user);
tL_messages_deleteChatUser = tL_messages_deleteChatUser2;
}
if (user.id == getUserConfig().getClientUserId()) {
deleteDialog(-i, 0, z2);
}
getConnectionsManager().sendRequest(tL_messages_deleteChatUser, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$deleteUserFromChat$204$MessagesController(isChannel, inputUser, i, tLObject, tL_error);
}
}, 64);
return;
}
if (chatFull instanceof TLRPC.TL_chatFull) {
TLRPC.Chat chat2 = getChat(Integer.valueOf(i));
chat2.participants_count--;
ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
arrayList.add(chat2);
getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
int i2 = 0;
while (true) {
if (i2 >= chatFull.participants.participants.size()) {
z3 = false;
break;
} else {
if (chatFull.participants.participants.get(i2).user_id == user.id) {
chatFull.participants.participants.remove(i2);
z3 = true;
break;
}
i2++;
}
}
if (z3) {
getMessagesStorage().updateChatInfo(chatFull, true);
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoDidLoad, chatFull, 0, false, null);
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 32);
}
}
public void lambda$deleteUserFromChat$204$MessagesController(boolean z, TLRPC.InputUser inputUser, final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error != null) {
return;
}
processUpdates((TLRPC.Updates) tLObject, false);
if (!z || (inputUser instanceof TLRPC.TL_inputUserSelf)) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$203$MessagesController(i);
}
}, 1000L);
}
public void lambda$null$203$MessagesController(int i) {
loadFullChat(i, 0, true);
}
public void changeChatTitle(int i, String str) {
TLRPC.TL_messages_editChatTitle tL_messages_editChatTitle;
if (i > 0) {
if (ChatObject.isChannel(i, this.currentAccount)) {
TLRPC.TL_channels_editTitle tL_channels_editTitle = new TLRPC.TL_channels_editTitle();
tL_channels_editTitle.channel = getInputChannel(i);
tL_channels_editTitle.title = str;
tL_messages_editChatTitle = tL_channels_editTitle;
} else {
TLRPC.TL_messages_editChatTitle tL_messages_editChatTitle2 = new TLRPC.TL_messages_editChatTitle();
tL_messages_editChatTitle2.chat_id = i;
tL_messages_editChatTitle2.title = str;
tL_messages_editChatTitle = tL_messages_editChatTitle2;
}
getConnectionsManager().sendRequest(tL_messages_editChatTitle, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$changeChatTitle$205$MessagesController(tLObject, tL_error);
}
}, 64);
return;
}
TLRPC.Chat chat = getChat(Integer.valueOf(i));
chat.title = str;
ArrayList<TLRPC.Chat> arrayList = new ArrayList<>();
arrayList.add(chat);
getMessagesStorage().putUsersAndChats(null, arrayList, true, true);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 16);
}
public void lambda$changeChatTitle$205$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error != null) {
return;
}
processUpdates((TLRPC.Updates) tLObject, false);
}
public void changeChatAvatar(int i, TLRPC.InputFile inputFile, final TLRPC.FileLocation fileLocation, final TLRPC.FileLocation fileLocation2) {
TLRPC.TL_messages_editChatPhoto tL_messages_editChatPhoto;
if (ChatObject.isChannel(i, this.currentAccount)) {
TLRPC.TL_channels_editPhoto tL_channels_editPhoto = new TLRPC.TL_channels_editPhoto();
tL_channels_editPhoto.channel = getInputChannel(i);
if (inputFile != null) {
tL_channels_editPhoto.photo = new TLRPC.TL_inputChatUploadedPhoto();
tL_channels_editPhoto.photo.file = inputFile;
tL_messages_editChatPhoto = tL_channels_editPhoto;
} else {
tL_channels_editPhoto.photo = new TLRPC.TL_inputChatPhotoEmpty();
tL_messages_editChatPhoto = tL_channels_editPhoto;
}
} else {
TLRPC.TL_messages_editChatPhoto tL_messages_editChatPhoto2 = new TLRPC.TL_messages_editChatPhoto();
tL_messages_editChatPhoto2.chat_id = i;
if (inputFile != null) {
tL_messages_editChatPhoto2.photo = new TLRPC.TL_inputChatUploadedPhoto();
tL_messages_editChatPhoto2.photo.file = inputFile;
tL_messages_editChatPhoto = tL_messages_editChatPhoto2;
} else {
tL_messages_editChatPhoto2.photo = new TLRPC.TL_inputChatPhotoEmpty();
tL_messages_editChatPhoto = tL_messages_editChatPhoto2;
}
}
getConnectionsManager().sendRequest(tL_messages_editChatPhoto, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$changeChatAvatar$206$MessagesController(fileLocation, fileLocation2, tLObject, tL_error);
}
}, 64);
}
public void lambda$changeChatAvatar$206$MessagesController(TLRPC.FileLocation fileLocation, TLRPC.FileLocation fileLocation2, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error != null) {
return;
}
TLRPC.Updates updates = (TLRPC.Updates) tLObject;
TLRPC.Photo photo = null;
int size = updates.updates.size();
int i = 0;
while (true) {
if (i >= size) {
break;
}
TLRPC.Update update = updates.updates.get(i);
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
TLRPC.Message message = ((TLRPC.TL_updateNewChannelMessage) update).message;
if ((message.action instanceof TLRPC.TL_messageActionChatEditPhoto) && (message.action.photo instanceof TLRPC.TL_photo)) {
photo = message.action.photo;
break;
}
i++;
} else {
if (update instanceof TLRPC.TL_updateNewMessage) {
TLRPC.Message message2 = ((TLRPC.TL_updateNewMessage) update).message;
if ((message2.action instanceof TLRPC.TL_messageActionChatEditPhoto) && (message2.action.photo instanceof TLRPC.TL_photo)) {
photo = message2.action.photo;
break;
}
} else {
continue;
}
i++;
}
}
if (photo != null) {
TLRPC.PhotoSize closestPhotoSizeWithSize = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, 150);
if (closestPhotoSizeWithSize != null && fileLocation != null) {
FileLoader.getPathToAttach(fileLocation, true).renameTo(FileLoader.getPathToAttach(closestPhotoSizeWithSize, true));
ImageLoader.getInstance().replaceImageInCache(fileLocation.volume_id + "_" + fileLocation.local_id + "@50_50", closestPhotoSizeWithSize.location.volume_id + "_" + closestPhotoSizeWithSize.location.local_id + "@50_50", ImageLocation.getForPhoto(closestPhotoSizeWithSize, photo), true);
}
TLRPC.PhotoSize closestPhotoSizeWithSize2 = FileLoader.getClosestPhotoSizeWithSize(photo.sizes, CodeUtils.DEFAULT_REQ_HEIGHT);
if (closestPhotoSizeWithSize2 != null && fileLocation2 != null) {
FileLoader.getPathToAttach(fileLocation2, true).renameTo(FileLoader.getPathToAttach(closestPhotoSizeWithSize2, true));
}
}
processUpdates(updates, false);
}
public void unregistedPush() {
if (getUserConfig().registeredForPush && SharedConfig.pushString.length() == 0) {
TLRPC.TL_account_unregisterDevice tL_account_unregisterDevice = new TLRPC.TL_account_unregisterDevice();
tL_account_unregisterDevice.token = SharedConfig.pushString;
tL_account_unregisterDevice.token_type = 2;
for (int i = 0; i < 3; i++) {
UserConfig userConfig = UserConfig.getInstance(i);
if (i != this.currentAccount && userConfig.isClientActivated()) {
tL_account_unregisterDevice.other_uids.add(Integer.valueOf(userConfig.getClientUserId()));
}
}
getConnectionsManager().sendRequest(tL_account_unregisterDevice, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$unregistedPush$207(tLObject, tL_error);
}
});
}
}
public void generateUpdateMessage() {
if (BuildVars.DEBUG_VERSION || SharedConfig.lastUpdateVersion == null || SharedConfig.lastUpdateVersion.equals(BuildVars.BUILD_VERSION_STRING)) {
return;
}
TLRPC.TL_help_getAppChangelog tL_help_getAppChangelog = new TLRPC.TL_help_getAppChangelog();
tL_help_getAppChangelog.prev_app_version = SharedConfig.lastUpdateVersion;
getConnectionsManager().sendRequest(tL_help_getAppChangelog, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$generateUpdateMessage$208$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$generateUpdateMessage$208$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tL_error == null) {
SharedConfig.lastUpdateVersion = BuildVars.BUILD_VERSION_STRING;
SharedConfig.saveConfig();
}
if (tLObject instanceof TLRPC.Updates) {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void performLogout(int i) {
if (i == 1) {
unregistedPush();
getConnectionsManager().sendRequest(new TLRPC.TL_auth_logOut(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$performLogout$209$MessagesController(tLObject, tL_error);
}
});
} else {
getConnectionsManager().cleanup(i == 2);
}
getUserConfig().clearConfig();
getNotificationCenter().postNotificationName(NotificationCenter.appDidLogout, new Object[0]);
getMessagesStorage().cleanup(false);
cleanup();
getContactsController().deleteUnknownAppAccounts();
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
GcmPushListenerService.sendUPushRegistrationToServer("");
}
});
}
public void lambda$performLogout$209$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
getConnectionsManager().cleanup(false);
}
public void registerForPush(final String str) {
if (TextUtils.isEmpty(str) || this.registeringForPush || getUserConfig().getClientUserId() == 0) {
return;
}
if (getUserConfig().registeredForPush && str.equals(SharedConfig.pushString)) {
return;
}
this.registeringForPush = true;
this.lastPushRegisterSendTime = SystemClock.elapsedRealtime();
if (SharedConfig.pushAuthKey == null) {
SharedConfig.pushAuthKey = new byte[256];
Utilities.random.nextBytes(SharedConfig.pushAuthKey);
SharedConfig.saveConfig();
}
TLRPC.TL_account_registerDevice tL_account_registerDevice = new TLRPC.TL_account_registerDevice();
tL_account_registerDevice.token_type = 2;
tL_account_registerDevice.token = str;
tL_account_registerDevice.no_muted = false;
tL_account_registerDevice.secret = SharedConfig.pushAuthKey;
for (int i = 0; i < 3; i++) {
UserConfig userConfig = UserConfig.getInstance(i);
if (i != this.currentAccount && userConfig.isClientActivated()) {
tL_account_registerDevice.other_uids.add(Integer.valueOf(userConfig.getClientUserId()));
}
}
getConnectionsManager().sendRequest(tL_account_registerDevice, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$registerForPush$212$MessagesController(str, tLObject, tL_error);
}
});
}
public void lambda$registerForPush$212$MessagesController(String str, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_boolTrue) {
getUserConfig().registeredForPush = true;
SharedConfig.pushString = str;
getUserConfig().saveConfig(false);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$211$MessagesController();
}
});
}
public void lambda$null$211$MessagesController() {
this.registeringForPush = false;
}
public void registerForUPush(final String str) {
if (TextUtils.isEmpty(str) || this.registeringForPush || getUserConfig().getClientUserId() == 0) {
return;
}
if (getUserConfig().registeredForPush && str.equals(SharedConfig.pushString)) {
return;
}
this.registeringForPush = true;
this.lastPushRegisterSendTime = SystemClock.elapsedRealtime();
if (SharedConfig.pushAuthKey == null) {
SharedConfig.pushAuthKey = new byte[256];
Utilities.random.nextBytes(SharedConfig.pushAuthKey);
SharedConfig.saveConfig();
}
TLRPC.TL_account_registerDevice tL_account_registerDevice = new TLRPC.TL_account_registerDevice();
tL_account_registerDevice.token_type = getPushDeviceType();
tL_account_registerDevice.token = str;
tL_account_registerDevice.no_muted = false;
tL_account_registerDevice.secret = SharedConfig.pushAuthKey;
for (int i = 0; i < 3; i++) {
UserConfig userConfig = UserConfig.getInstance(i);
if (i != this.currentAccount && userConfig.isClientActivated()) {
int clientUserId = userConfig.getClientUserId();
tL_account_registerDevice.other_uids.add(Integer.valueOf(clientUserId));
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add other uid = " + clientUserId + " for account " + this.currentAccount);
}
}
}
getConnectionsManager().sendRequest(tL_account_registerDevice, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$registerForUPush$214$MessagesController(str, tLObject, tL_error);
}
});
}
public void lambda$registerForUPush$214$MessagesController(String str, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject instanceof TLRPC.TL_boolTrue) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("account " + this.currentAccount + " registered for push");
}
getUserConfig().registeredForPush = true;
SharedConfig.pushString = str;
getUserConfig().saveConfig(false);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$213$MessagesController();
}
});
}
public void lambda$null$213$MessagesController() {
this.registeringForPush = false;
}
private int getPushDeviceType() {
if (MryDeviceHelper.isHuawei()) {
return 5;
}
if (MryDeviceHelper.isXiaomi()) {
return 6;
}
return MryDeviceHelper.isOppo() ? 7 : 8;
}
public void loadCurrentState() {
if (this.updatingState) {
return;
}
this.updatingState = true;
getConnectionsManager().sendRequest(new TLRPC.TL_updates_getState(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadCurrentState$215$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$loadCurrentState$215$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
this.updatingState = false;
if (tL_error == null) {
TLRPC.TL_updates_state tL_updates_state = (TLRPC.TL_updates_state) tLObject;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("loadCurrentState ===> response = " + tL_updates_state.toString());
}
getMessagesStorage().setLastDateValue(tL_updates_state.date);
getMessagesStorage().setLastPtsValue(tL_updates_state.pts);
getMessagesStorage().setLastSeqValue(tL_updates_state.seq);
getMessagesStorage().setLastQtsValue(tL_updates_state.qts);
for (int i = 0; i < 3; i++) {
processUpdatesQueue(i, 2);
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
return;
}
if (tL_error.code != 401) {
loadCurrentState();
}
}
private int getUpdateSeq(TLRPC.Updates updates) {
if (updates instanceof TLRPC.TL_updatesCombined) {
return updates.seq_start;
}
return updates.seq;
}
private void setUpdatesStartTime(int i, long j) {
if (i == 0) {
this.updatesStartWaitTimeSeq = j;
} else if (i == 1) {
this.updatesStartWaitTimePts = j;
} else if (i == 2) {
this.updatesStartWaitTimeQts = j;
}
}
public long getUpdatesStartTime(int i) {
if (i == 0) {
return this.updatesStartWaitTimeSeq;
}
if (i == 1) {
return this.updatesStartWaitTimePts;
}
if (i == 2) {
return this.updatesStartWaitTimeQts;
}
return 0L;
}
private int isValidUpdate(TLRPC.Updates updates, int i) {
if (i == 0) {
int updateSeq = getUpdateSeq(updates);
if (getMessagesStorage().getLastSeqValue() + 1 == updateSeq || getMessagesStorage().getLastSeqValue() == updateSeq) {
return 0;
}
return getMessagesStorage().getLastSeqValue() < updateSeq ? 1 : 2;
}
if (i == 1) {
if (updates.pts <= getMessagesStorage().getLastPtsValue()) {
return 2;
}
return getMessagesStorage().getLastPtsValue() + updates.pts_count == updates.pts ? 0 : 1;
}
if (i != 2) {
return 0;
}
if (updates.pts <= getMessagesStorage().getLastQtsValue()) {
return 2;
}
return getMessagesStorage().getLastQtsValue() + updates.updates.size() == updates.pts ? 0 : 1;
}
private void processChannelsUpdatesQueue(int i, int i2) {
char c;
ArrayList<TLRPC.Updates> arrayList = this.updatesQueueChannels.get(i);
if (arrayList == null) {
return;
}
int i3 = this.channelsPts.get(i);
if (arrayList.isEmpty() || i3 == 0) {
this.updatesQueueChannels.remove(i);
return;
}
Collections.sort(arrayList, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int compare;
compare = AndroidUtilities.compare(((TLRPC.Updates) obj).pts, ((TLRPC.Updates) obj2).pts);
return compare;
}
});
if (i2 == 2) {
this.channelsPts.put(i, arrayList.get(0).pts);
}
boolean z = false;
while (arrayList.size() > 0) {
TLRPC.Updates updates = arrayList.get(0);
if (updates.pts <= i3) {
c = 2;
} else {
c = updates.pts_count + i3 == updates.pts ? (char) 0 : (char) 1;
}
if (c == 0) {
processUpdates(updates, true);
arrayList.remove(0);
z = true;
} else {
if (c == 1) {
long j = this.updatesStartWaitTimeChannels.get(i);
if (j != 0 && (z || Math.abs(System.currentTimeMillis() - j) <= 1500)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN CHANNEL " + i + " UPDATES QUEUE - will wait more time");
}
if (z) {
this.updatesStartWaitTimeChannels.put(i, System.currentTimeMillis());
return;
}
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN CHANNEL " + i + " UPDATES QUEUE - getChannelDifference ");
}
this.updatesStartWaitTimeChannels.delete(i);
this.updatesQueueChannels.remove(i);
getChannelDifference(i);
return;
}
arrayList.remove(0);
}
}
this.updatesQueueChannels.remove(i);
this.updatesStartWaitTimeChannels.delete(i);
if (BuildVars.LOGS_ENABLED) {
FileLog.d("UPDATES CHANNEL " + i + " QUEUE PROCEED - OK");
}
}
private void processUpdatesQueue(int i, int i2) {
ArrayList<TLRPC.Updates> arrayList;
if (i == 0) {
arrayList = this.updatesQueueSeq;
Collections.sort(arrayList, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
return MessagesController.this.lambda$processUpdatesQueue$217$MessagesController((TLRPC.Updates) obj, (TLRPC.Updates) obj2);
}
});
} else if (i == 1) {
arrayList = this.updatesQueuePts;
Collections.sort(arrayList, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int compare;
compare = AndroidUtilities.compare(((TLRPC.Updates) obj).pts, ((TLRPC.Updates) obj2).pts);
return compare;
}
});
} else if (i == 2) {
arrayList = this.updatesQueueQts;
Collections.sort(arrayList, new Comparator() {
@Override
public final int compare(Object obj, Object obj2) {
int compare;
compare = AndroidUtilities.compare(((TLRPC.Updates) obj).pts, ((TLRPC.Updates) obj2).pts);
return compare;
}
});
} else {
arrayList = null;
}
if (arrayList != null && !arrayList.isEmpty()) {
if (i2 == 2) {
TLRPC.Updates updates = arrayList.get(0);
if (i == 0) {
getMessagesStorage().setLastSeqValue(getUpdateSeq(updates));
} else if (i == 1) {
getMessagesStorage().setLastPtsValue(updates.pts);
} else {
getMessagesStorage().setLastQtsValue(updates.pts);
}
}
boolean z = false;
while (arrayList.size() > 0) {
TLRPC.Updates updates2 = arrayList.get(0);
int isValidUpdate = isValidUpdate(updates2, i);
if (isValidUpdate == 0) {
processUpdates(updates2, true);
arrayList.remove(0);
z = true;
} else {
if (isValidUpdate == 1) {
if (getUpdatesStartTime(i) != 0 && (z || Math.abs(System.currentTimeMillis() - getUpdatesStartTime(i)) <= 1500)) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN UPDATES QUEUE - will wait more time");
}
if (z) {
setUpdatesStartTime(i, System.currentTimeMillis());
return;
}
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("HOLE IN UPDATES QUEUE - getDifference");
}
setUpdatesStartTime(i, 0L);
arrayList.clear();
getDifference();
return;
}
arrayList.remove(0);
}
}
arrayList.clear();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("UPDATES QUEUE PROCEED - OK");
}
}
setUpdatesStartTime(i, 0L);
}
public int lambda$processUpdatesQueue$217$MessagesController(TLRPC.Updates updates, TLRPC.Updates updates2) {
return AndroidUtilities.compare(getUpdateSeq(updates), getUpdateSeq(updates2));
}
public void loadUnknownChannel(final TLRPC.Chat chat, final long j) {
NativeByteBuffer nativeByteBuffer;
Exception e;
if (!(chat instanceof TLRPC.TL_channel) || this.gettingUnknownChannels.indexOfKey(chat.id) >= 0) {
return;
}
if (chat.access_hash == 0) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
return;
}
return;
}
TLRPC.TL_inputPeerChannel tL_inputPeerChannel = new TLRPC.TL_inputPeerChannel();
tL_inputPeerChannel.channel_id = chat.id;
tL_inputPeerChannel.access_hash = chat.access_hash;
this.gettingUnknownChannels.put(chat.id, true);
TLRPC.TL_messages_getPeerDialogs tL_messages_getPeerDialogs = new TLRPC.TL_messages_getPeerDialogs();
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = tL_inputPeerChannel;
tL_messages_getPeerDialogs.peers.add(tL_inputDialogPeer);
if (j == 0) {
try {
nativeByteBuffer = new NativeByteBuffer(chat.getObjectSize() + 4);
} catch (Exception e2) {
nativeByteBuffer = null;
e = e2;
}
try {
nativeByteBuffer.writeInt32(0);
chat.serializeToStream(nativeByteBuffer);
} catch (Exception e3) {
e = e3;
FileLog.e(e);
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUnknownChannel$220$MessagesController(j, chat, tLObject, tL_error);
}
});
}
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
getConnectionsManager().sendRequest(tL_messages_getPeerDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUnknownChannel$220$MessagesController(j, chat, tLObject, tL_error);
}
});
}
public void lambda$loadUnknownChannel$220$MessagesController(long j, TLRPC.Chat chat, TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
if (!tL_messages_peerDialogs.dialogs.isEmpty() && !tL_messages_peerDialogs.chats.isEmpty() && !(tL_messages_peerDialogs.dialogs.get(0) instanceof TLRPC.TL_dialogFolder)) {
TLRPC.TL_dialog tL_dialog = (TLRPC.TL_dialog) tL_messages_peerDialogs.dialogs.get(0);
TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
processLoadedDialogs(tL_messages_dialogs, null, tL_dialog.folder_id, 0, 1, this.DIALOGS_LOAD_TYPE_CHANNEL, false, false, false);
}
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
this.gettingUnknownChannels.delete(chat.id);
}
public void startShortPoll(final TLRPC.Chat chat, final boolean z) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$startShortPoll$221$MessagesController(z, chat);
}
});
}
public void lambda$startShortPoll$221$MessagesController(boolean z, TLRPC.Chat chat) {
if (z) {
this.needShortPollChannels.delete(chat.id);
if (chat.megagroup) {
this.needShortPollOnlines.delete(chat.id);
return;
}
return;
}
this.needShortPollChannels.put(chat.id, 0);
if (this.shortPollChannels.indexOfKey(chat.id) < 0) {
getChannelDifference(chat.id, 3, 0L, null);
}
if (chat.megagroup) {
this.needShortPollOnlines.put(chat.id, 0);
if (this.shortPollOnlines.indexOfKey(chat.id) < 0) {
this.shortPollOnlines.put(chat.id, 0);
}
}
}
private void getChannelDifference(int i) {
getChannelDifference(i, 0, 0L, null);
}
public static boolean isSupportUser(TLRPC.User user) {
return user != null && (user.support || user.id == 777000 || user.id == 333000 || user.id == 4240000 || user.id == 4244000 || user.id == 4245000 || user.id == 4246000 || user.id == 410000 || user.id == 420000 || user.id == 431000 || user.id == 431415000 || user.id == 434000 || user.id == 4243000 || user.id == 439000 || user.id == 449000 || user.id == 450000 || user.id == 452000 || user.id == 454000 || user.id == 4254000 || user.id == 455000 || user.id == 460000 || user.id == 470000 || user.id == 479000 || user.id == 796000 || user.id == 482000 || user.id == 490000 || user.id == 496000 || user.id == 497000 || user.id == 498000 || user.id == 4298000);
}
public void getChannelDifference(final int i, final int i2, long j, TLRPC.InputChannel inputChannel) {
int i3;
TLRPC.InputChannel inputChannel2;
NativeByteBuffer nativeByteBuffer;
long j2 = j;
if (this.gettingDifferenceChannels.get(i)) {
return;
}
int i4 = 100;
if (i2 == 1) {
if (this.channelsPts.get(i) != 0) {
return;
}
i4 = 1;
i3 = 1;
} else {
i3 = this.channelsPts.get(i);
if (i3 == 0) {
i3 = getMessagesStorage().getChannelPtsSync(i);
if (i3 != 0) {
this.channelsPts.put(i, i3);
}
if (i3 == 0 && (i2 == 2 || i2 == 3)) {
return;
}
}
if (i3 == 0) {
return;
}
}
if (inputChannel == null) {
TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (chat == null && (chat = getMessagesStorage().getChatSync(i)) != null) {
putChat(chat, true);
}
inputChannel2 = getInputChannel(chat);
} else {
inputChannel2 = inputChannel;
}
if (inputChannel2 == null || inputChannel2.access_hash == 0) {
if (j2 != 0) {
getMessagesStorage().removePendingTask(j2);
return;
}
return;
}
if (j2 == 0) {
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(inputChannel2.getObjectSize() + 12);
} catch (Exception e) {
e = e;
}
try {
nativeByteBuffer.writeInt32(6);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeInt32(i2);
inputChannel2.serializeToStream(nativeByteBuffer);
} catch (Exception e2) {
e = e2;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
final long j3 = j2;
this.gettingDifferenceChannels.put(i, true);
TLRPC.TL_updates_getChannelDifference tL_updates_getChannelDifference = new TLRPC.TL_updates_getChannelDifference();
tL_updates_getChannelDifference.channel = inputChannel2;
tL_updates_getChannelDifference.filter = new TLRPC.TL_channelMessagesFilterEmpty();
tL_updates_getChannelDifference.pts = i3;
tL_updates_getChannelDifference.limit = i4;
tL_updates_getChannelDifference.force = i2 != 3;
getConnectionsManager().sendRequest(tL_updates_getChannelDifference, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$getChannelDifference$230$MessagesController(i, i2, j3, tLObject, tL_error);
}
});
}
j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
final long j32 = j2;
this.gettingDifferenceChannels.put(i, true);
TLRPC.TL_updates_getChannelDifference tL_updates_getChannelDifference2 = new TLRPC.TL_updates_getChannelDifference();
tL_updates_getChannelDifference2.channel = inputChannel2;
tL_updates_getChannelDifference2.filter = new TLRPC.TL_channelMessagesFilterEmpty();
tL_updates_getChannelDifference2.pts = i3;
tL_updates_getChannelDifference2.limit = i4;
tL_updates_getChannelDifference2.force = i2 != 3;
getConnectionsManager().sendRequest(tL_updates_getChannelDifference2, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$getChannelDifference$230$MessagesController(i, i2, j32, tLObject, tL_error);
}
});
}
public void lambda$getChannelDifference$230$MessagesController(final int i, final int i2, final long j, TLObject tLObject, final TLRPC.TL_error tL_error) {
final TLRPC.Chat chat;
if (tLObject == null) {
if (tL_error != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$229$MessagesController(tL_error, i);
}
});
this.gettingDifferenceChannels.delete(i);
if (j != 0) {
getMessagesStorage().removePendingTask(j);
return;
}
return;
}
return;
}
final TLRPC.updates_ChannelDifference updates_channeldifference = (TLRPC.updates_ChannelDifference) tLObject;
final SparseArray sparseArray = new SparseArray();
int i3 = 0;
for (int i4 = 0; i4 < updates_channeldifference.users.size(); i4++) {
TLRPC.User user = updates_channeldifference.users.get(i4);
sparseArray.put(user.id, user);
}
int i5 = 0;
while (true) {
if (i5 >= updates_channeldifference.chats.size()) {
chat = null;
break;
}
chat = updates_channeldifference.chats.get(i5);
if (chat.id == i) {
break;
} else {
i5++;
}
}
final ArrayList arrayList = new ArrayList();
if (!updates_channeldifference.other_updates.isEmpty()) {
while (i3 < updates_channeldifference.other_updates.size()) {
TLRPC.Update update = updates_channeldifference.other_updates.get(i3);
if (update instanceof TLRPC.TL_updateMessageID) {
arrayList.add((TLRPC.TL_updateMessageID) update);
updates_channeldifference.other_updates.remove(i3);
i3--;
}
i3++;
}
}
getMessagesStorage().putUsersAndChats(updates_channeldifference.users, updates_channeldifference.chats, true, true);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$222$MessagesController(updates_channeldifference);
}
});
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$228$MessagesController(arrayList, i, updates_channeldifference, chat, sparseArray, i2, j);
}
});
}
public void lambda$null$222$MessagesController(TLRPC.updates_ChannelDifference updates_channeldifference) {
putUsers(updates_channeldifference.users, false);
putChats(updates_channeldifference.chats, false);
}
public void lambda$null$228$MessagesController(ArrayList arrayList, final int i, final TLRPC.updates_ChannelDifference updates_channeldifference, final TLRPC.Chat chat, final SparseArray sparseArray, final int i2, final long j) {
if (!arrayList.isEmpty()) {
final SparseArray sparseArray2 = new SparseArray();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
TLRPC.TL_updateMessageID tL_updateMessageID = (TLRPC.TL_updateMessageID) it.next();
long[] updateMessageStateAndId = getMessagesStorage().updateMessageStateAndId(tL_updateMessageID.random_id, null, tL_updateMessageID.id, 0, false, i, -1);
if (updateMessageStateAndId != null) {
sparseArray2.put(tL_updateMessageID.id, updateMessageStateAndId);
}
}
if (sparseArray2.size() != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$223$MessagesController(sparseArray2);
}
});
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$227$MessagesController(updates_channeldifference, i, chat, sparseArray, i2, j);
}
});
}
}
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$227$MessagesController(updates_channeldifference, i, chat, sparseArray, i2, j);
}
});
}
public void lambda$null$223$MessagesController(SparseArray sparseArray) {
for (int i = 0; i < sparseArray.size(); i++) {
int keyAt = sparseArray.keyAt(i);
long[] jArr = (long[]) sparseArray.valueAt(i);
int i2 = (int) jArr[1];
getSendMessagesHelper().processSentMessage(i2);
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, Integer.valueOf(i2), Integer.valueOf(keyAt), null, Long.valueOf(jArr[0]), 0L, -1, false);
}
}
public void lambda$null$227$MessagesController(final TLRPC.updates_ChannelDifference updates_channeldifference, int i, TLRPC.Chat chat, SparseArray sparseArray, int i2, long j) {
boolean z;
MessageObject messageObject;
ArrayList arrayList;
boolean z2;
TLRPC.Chat chat2 = chat;
if ((updates_channeldifference instanceof TLRPC.TL_updates_channelDifference) || (updates_channeldifference instanceof TLRPC.TL_updates_channelDifferenceEmpty)) {
if (!updates_channeldifference.new_messages.isEmpty()) {
final LongSparseArray longSparseArray = new LongSparseArray();
ImageLoader.saveMessagesThumbs(updates_channeldifference.new_messages);
final ArrayList arrayList2 = new ArrayList();
long j2 = -i;
Integer num = this.dialogs_read_inbox_max.get(Long.valueOf(j2));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j2));
this.dialogs_read_inbox_max.put(Long.valueOf(j2), num);
}
Integer num2 = this.dialogs_read_outbox_max.get(Long.valueOf(j2));
if (num2 == null) {
num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j2));
this.dialogs_read_outbox_max.put(Long.valueOf(j2), num2);
}
int i3 = 0;
while (i3 < updates_channeldifference.new_messages.size()) {
TLRPC.Message message = updates_channeldifference.new_messages.get(i3);
if (chat2 == null || !chat2.left) {
if ((message.out ? num2 : num).intValue() < message.id && !(message.action instanceof TLRPC.TL_messageActionChannelCreate)) {
z = true;
message.unread = z;
if (chat2 == null && chat2.megagroup) {
message.flags |= Integer.MIN_VALUE;
}
Integer num3 = num;
messageObject = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, this.createdDialogIds.contains(Long.valueOf(j2)));
if ((messageObject.isOut() || messageObject.messageOwner.from_scheduled) && messageObject.isUnread()) {
arrayList2.add(messageObject);
}
arrayList = (ArrayList) longSparseArray.get(j2);
if (arrayList != null) {
arrayList = new ArrayList();
longSparseArray.put(j2, arrayList);
}
arrayList.add(messageObject);
i3++;
chat2 = chat;
num = num3;
}
}
z = false;
message.unread = z;
if (chat2 == null) {
}
Integer num32 = num;
messageObject = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, this.createdDialogIds.contains(Long.valueOf(j2)));
if (messageObject.isOut()) {
}
arrayList2.add(messageObject);
arrayList = (ArrayList) longSparseArray.get(j2);
if (arrayList != null) {
}
arrayList.add(messageObject);
i3++;
chat2 = chat;
num = num32;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$224$MessagesController(longSparseArray);
}
});
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$226$MessagesController(arrayList2, updates_channeldifference);
}
});
}
if (!updates_channeldifference.other_updates.isEmpty()) {
processUpdateArray(updates_channeldifference.other_updates, updates_channeldifference.users, updates_channeldifference.chats, true, 0);
}
processChannelsUpdatesQueue(i, 1);
getMessagesStorage().saveChannelPts(i, updates_channeldifference.pts);
} else if (updates_channeldifference instanceof TLRPC.TL_updates_channelDifferenceTooLong) {
long j3 = -i;
Integer num4 = this.dialogs_read_inbox_max.get(Long.valueOf(j3));
if (num4 == null) {
num4 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j3));
this.dialogs_read_inbox_max.put(Long.valueOf(j3), num4);
}
Integer num5 = this.dialogs_read_outbox_max.get(Long.valueOf(j3));
if (num5 == null) {
num5 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j3));
this.dialogs_read_outbox_max.put(Long.valueOf(j3), num5);
}
for (int i4 = 0; i4 < updates_channeldifference.messages.size(); i4++) {
TLRPC.Message message2 = updates_channeldifference.messages.get(i4);
message2.dialog_id = j3;
if (!(message2.action instanceof TLRPC.TL_messageActionChannelCreate) && (chat2 == null || !chat2.left)) {
if ((message2.out ? num5 : num4).intValue() < message2.id) {
z2 = true;
message2.unread = z2;
if (chat2 != null && chat2.megagroup) {
message2.flags |= Integer.MIN_VALUE;
}
}
}
z2 = false;
message2.unread = z2;
if (chat2 != null) {
message2.flags |= Integer.MIN_VALUE;
}
}
getMessagesStorage().overwriteChannel(i, (TLRPC.TL_updates_channelDifferenceTooLong) updates_channeldifference, i2);
}
this.gettingDifferenceChannels.delete(i);
this.channelsPts.put(i, updates_channeldifference.pts);
if ((updates_channeldifference.flags & 2) != 0) {
this.shortPollChannels.put(i, ((int) (System.currentTimeMillis() / 1000)) + updates_channeldifference.timeout);
}
if (!updates_channeldifference.isFinal) {
getChannelDifference(i);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("received channel difference with pts = " + updates_channeldifference.pts + " channelId = " + i);
}
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void lambda$null$224$MessagesController(LongSparseArray longSparseArray) {
for (int i = 0; i < longSparseArray.size(); i++) {
updateInterfaceWithMessages(longSparseArray.keyAt(i), (ArrayList) longSparseArray.valueAt(i), false);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void lambda$null$226$MessagesController(final ArrayList arrayList, TLRPC.updates_ChannelDifference updates_channeldifference) {
if (!arrayList.isEmpty()) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$225$MessagesController(arrayList);
}
});
}
getMessagesStorage().putMessages(updates_channeldifference.new_messages, true, true, false, getDownloadController().getAutodownloadMask(), false);
}
public void lambda$null$225$MessagesController(ArrayList arrayList) {
getNotificationsController().processNewMessages(arrayList, true, false, null);
}
public void lambda$null$229$MessagesController(TLRPC.TL_error tL_error, int i) {
checkChannelError(tL_error.text, i);
}
private void checkChannelError(String str, int i) {
char c;
int hashCode = str.hashCode();
if (hashCode == -1809401834) {
if (str.equals("USER_BANNED_IN_CHANNEL")) {
c = 2;
}
c = 65535;
} else if (hashCode != -795226617) {
if (hashCode == -471086771 && str.equals("CHANNEL_PUBLIC_GROUP_NA")) {
c = 1;
}
c = 65535;
} else {
if (str.equals("CHANNEL_PRIVATE")) {
c = 0;
}
c = 65535;
}
if (c == 0) {
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 0);
} else if (c == 1) {
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 1);
} else {
if (c != 2) {
return;
}
getNotificationCenter().postNotificationName(NotificationCenter.chatInfoCantLoad, Integer.valueOf(i), 2);
}
}
public void getDifference() {
getDifference(getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue(), false);
}
public void getDifference(int i, final int i2, final int i3, boolean z) {
registerForPush(SharedConfig.pushString);
if (getMessagesStorage().getLastPtsValue() == 0) {
loadCurrentState();
return;
}
if (z || !this.gettingDifference) {
this.gettingDifference = true;
TLRPC.TL_updates_getDifference tL_updates_getDifference = new TLRPC.TL_updates_getDifference();
tL_updates_getDifference.pts = i;
tL_updates_getDifference.date = i2;
tL_updates_getDifference.qts = i3;
if (this.getDifferenceFirstSync) {
tL_updates_getDifference.flags |= 1;
if (ApplicationLoader.isConnectedOrConnectingToWiFi()) {
tL_updates_getDifference.pts_total_limit = 5000;
} else {
tL_updates_getDifference.pts_total_limit = 1000;
}
this.getDifferenceFirstSync = false;
}
if (tL_updates_getDifference.date == 0) {
tL_updates_getDifference.date = getConnectionsManager().getCurrentTime();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("getDiff start ===> act=" + this.currentAccount + " ,date=" + i2 + " ,pts=" + i + " ,qts=" + i3);
}
getConnectionsManager().setIsUpdating(true);
getConnectionsManager().sendRequest(tL_updates_getDifference, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$getDifference$239$MessagesController(i2, i3, tLObject, tL_error);
}
});
}
}
public void lambda$getDifference$239$MessagesController(final int i, final int i2, TLObject tLObject, TLRPC.TL_error tL_error) {
int i3 = 0;
if (tL_error == null) {
final TLRPC.updates_Difference updates_difference = (TLRPC.updates_Difference) tLObject;
if (BuildVars.DEBUG_VERSION) {
FileLog.d("getDiff success ===> act=" + this.currentAccount + " ,date=" + i + " ,res=" + updates_difference.toString());
}
if (updates_difference instanceof TLRPC.TL_updates_differenceTooLong) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$231$MessagesController(updates_difference, i, i2);
}
});
return;
}
if (updates_difference instanceof TLRPC.TL_updates_differenceSlice) {
getDifference(updates_difference.intermediate_state.pts, updates_difference.intermediate_state.date, updates_difference.intermediate_state.qts, true);
}
final SparseArray sparseArray = new SparseArray();
final SparseArray sparseArray2 = new SparseArray();
for (int i4 = 0; i4 < updates_difference.users.size(); i4++) {
TLRPC.User user = updates_difference.users.get(i4);
sparseArray.put(user.id, user);
}
for (int i5 = 0; i5 < updates_difference.chats.size(); i5++) {
TLRPC.Chat chat = updates_difference.chats.get(i5);
sparseArray2.put(chat.id, chat);
}
final ArrayList arrayList = new ArrayList();
if (!updates_difference.other_updates.isEmpty()) {
while (i3 < updates_difference.other_updates.size()) {
TLRPC.Update update = updates_difference.other_updates.get(i3);
if (update instanceof TLRPC.TL_updateMessageID) {
arrayList.add((TLRPC.TL_updateMessageID) update);
updates_difference.other_updates.remove(i3);
} else {
if (getUpdateType(update) == 2) {
int updateChannelId = getUpdateChannelId(update);
int i6 = this.channelsPts.get(updateChannelId);
if (i6 == 0 && (i6 = getMessagesStorage().getChannelPtsSync(updateChannelId)) != 0) {
this.channelsPts.put(updateChannelId, i6);
}
if (i6 != 0 && getUpdatePts(update) <= i6) {
updates_difference.other_updates.remove(i3);
}
}
i3++;
}
i3--;
i3++;
}
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$232$MessagesController(updates_difference);
}
});
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$238$MessagesController(updates_difference, arrayList, sparseArray, sparseArray2);
}
});
return;
}
this.gettingDifference = false;
getConnectionsManager().setIsUpdating(false);
}
public void lambda$null$231$MessagesController(TLRPC.updates_Difference updates_difference, int i, int i2) {
this.loadedFullUsers.clear();
this.loadedFullChats.clear();
resetDialogs(true, getMessagesStorage().getLastSeqValue(), updates_difference.pts, i, i2);
}
public void lambda$null$232$MessagesController(TLRPC.updates_Difference updates_difference) {
this.loadedFullUsers.clear();
this.loadedFullChats.clear();
putUsers(updates_difference.users, false);
putChats(updates_difference.chats, false);
}
public void lambda$null$238$MessagesController(final TLRPC.updates_Difference updates_difference, ArrayList arrayList, final SparseArray sparseArray, final SparseArray sparseArray2) {
getMessagesStorage().putUsersAndChats(updates_difference.users, updates_difference.chats, true, false);
if (!arrayList.isEmpty()) {
final SparseArray sparseArray3 = new SparseArray();
for (int i = 0; i < arrayList.size(); i++) {
TLRPC.TL_updateMessageID tL_updateMessageID = (TLRPC.TL_updateMessageID) arrayList.get(i);
long[] updateMessageStateAndId = getMessagesStorage().updateMessageStateAndId(tL_updateMessageID.random_id, null, tL_updateMessageID.id, 0, false, 0, -1);
if (updateMessageStateAndId != null) {
sparseArray3.put(tL_updateMessageID.id, updateMessageStateAndId);
}
}
if (sparseArray3.size() != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$233$MessagesController(sparseArray3);
}
});
}
}
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$237$MessagesController(updates_difference, sparseArray, sparseArray2);
}
});
}
public void lambda$null$233$MessagesController(SparseArray sparseArray) {
for (int i = 0; i < sparseArray.size(); i++) {
int keyAt = sparseArray.keyAt(i);
long[] jArr = (long[]) sparseArray.valueAt(i);
int i2 = (int) jArr[1];
getSendMessagesHelper().processSentMessage(i2);
getNotificationCenter().postNotificationName(NotificationCenter.messageReceivedByServer, Integer.valueOf(i2), Integer.valueOf(keyAt), null, Long.valueOf(jArr[0]), 0L, -1, false);
}
}
public void lambda$null$237$MessagesController(final TLRPC.updates_Difference updates_difference, SparseArray sparseArray, SparseArray sparseArray2) {
TLRPC.User user;
int i = 0;
if (!updates_difference.new_messages.isEmpty() || !updates_difference.new_encrypted_messages.isEmpty()) {
final LongSparseArray longSparseArray = new LongSparseArray();
for (int i2 = 0; i2 < updates_difference.new_encrypted_messages.size(); i2++) {
ArrayList<TLRPC.Message> decryptMessage = getSecretChatHelper().decryptMessage(updates_difference.new_encrypted_messages.get(i2));
if (decryptMessage != null && !decryptMessage.isEmpty()) {
updates_difference.new_messages.addAll(decryptMessage);
}
}
ImageLoader.saveMessagesThumbs(updates_difference.new_messages);
final ArrayList arrayList = new ArrayList();
int clientUserId = getUserConfig().getClientUserId();
for (int i3 = 0; i3 < updates_difference.new_messages.size(); i3++) {
TLRPC.Message message = updates_difference.new_messages.get(i3);
if (message.dialog_id == 0) {
if (message.to_id.chat_id != 0) {
message.dialog_id = -message.to_id.chat_id;
} else {
if (message.to_id.user_id == getUserConfig().getClientUserId()) {
message.to_id.user_id = message.from_id;
}
message.dialog_id = message.to_id.user_id;
}
}
if (((int) message.dialog_id) != 0) {
if ((message.action instanceof TLRPC.TL_messageActionChatDeleteUser) && (user = (TLRPC.User) sparseArray.get(message.action.user_id)) != null && user.bot) {
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
message.flags |= 64;
}
if ((message.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message.action instanceof TLRPC.TL_messageActionChannelCreate)) {
message.unread = false;
message.media_unread = false;
} else {
ConcurrentHashMap<Long, Integer> concurrentHashMap = message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
Integer num = concurrentHashMap.get(Long.valueOf(message.dialog_id));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(message.out, message.dialog_id));
concurrentHashMap.put(Long.valueOf(message.dialog_id), num);
}
message.unread = num.intValue() < message.id;
}
}
if (message.dialog_id == clientUserId) {
message.unread = false;
message.media_unread = false;
message.out = true;
}
MessageObject messageObject = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, this.createdDialogIds.contains(Long.valueOf(message.dialog_id)));
if ((!messageObject.isOut() || messageObject.messageOwner.from_scheduled) && messageObject.isUnread()) {
arrayList.add(messageObject);
}
ArrayList arrayList2 = (ArrayList) longSparseArray.get(message.dialog_id);
if (arrayList2 == null) {
arrayList2 = new ArrayList();
longSparseArray.put(message.dialog_id, arrayList2);
}
arrayList2.add(messageObject);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$234$MessagesController(longSparseArray);
}
});
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$236$MessagesController(arrayList, updates_difference);
}
});
getSecretChatHelper().processPendingEncMessages();
}
if (!updates_difference.other_updates.isEmpty()) {
processUpdateArray(updates_difference.other_updates, updates_difference.users, updates_difference.chats, true, 0);
}
if (updates_difference instanceof TLRPC.TL_updates_difference) {
this.gettingDifference = false;
getMessagesStorage().setLastSeqValue(updates_difference.state.seq);
getMessagesStorage().setLastDateValue(updates_difference.state.date);
getMessagesStorage().setLastPtsValue(updates_difference.state.pts);
getMessagesStorage().setLastQtsValue(updates_difference.state.qts);
getConnectionsManager().setIsUpdating(false);
while (i < 3) {
processUpdatesQueue(i, 1);
i++;
}
} else if (updates_difference instanceof TLRPC.TL_updates_differenceSlice) {
getMessagesStorage().setLastDateValue(updates_difference.intermediate_state.date);
getMessagesStorage().setLastPtsValue(updates_difference.intermediate_state.pts);
getMessagesStorage().setLastQtsValue(updates_difference.intermediate_state.qts);
} else if (updates_difference instanceof TLRPC.TL_updates_differenceEmpty) {
this.gettingDifference = false;
getMessagesStorage().setLastSeqValue(updates_difference.seq);
getMessagesStorage().setLastDateValue(updates_difference.date);
getConnectionsManager().setIsUpdating(false);
while (i < 3) {
processUpdatesQueue(i, 1);
i++;
}
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
if (BuildVars.LOGS_ENABLED) {
FileLog.d("getDiff save last diff value ===> act=" + this.currentAccount + " ,date=" + getMessagesStorage().getLastDateValue() + " ,pts=" + getMessagesStorage().getLastPtsValue() + " ,seq=" + getMessagesStorage().getLastSeqValue() + " ,qts=" + getMessagesStorage().getLastQtsValue());
}
}
public void lambda$null$234$MessagesController(LongSparseArray longSparseArray) {
for (int i = 0; i < longSparseArray.size(); i++) {
updateInterfaceWithMessages(longSparseArray.keyAt(i), (ArrayList) longSparseArray.valueAt(i), false);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void lambda$null$236$MessagesController(final ArrayList arrayList, final TLRPC.updates_Difference updates_difference) {
if (!arrayList.isEmpty()) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$235$MessagesController(arrayList, updates_difference);
}
});
}
getMessagesStorage().putMessages(updates_difference.new_messages, true, true, false, getDownloadController().getAutodownloadMask(), false);
}
public void lambda$null$235$MessagesController(ArrayList arrayList, TLRPC.updates_Difference updates_difference) {
getNotificationsController().processNewMessages(arrayList, !(updates_difference instanceof TLRPC.TL_updates_differenceSlice), false, null);
}
public void markDialogAsUnread(long j, TLRPC.InputPeer inputPeer, final long j2) {
NativeByteBuffer nativeByteBuffer;
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog != null) {
dialog.unread_mark = true;
if (dialog.unread_count == 0) {
this.dialogsUnreadOnly.add(dialog);
if (!isDialogMuted(j)) {
this.unreadUnmutedDialogs++;
}
}
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
getMessagesStorage().setDialogUnread(j, true);
}
int i = (int) j;
if (i != 0) {
TLRPC.TL_messages_markDialogUnread tL_messages_markDialogUnread = new TLRPC.TL_messages_markDialogUnread();
tL_messages_markDialogUnread.unread = true;
if (inputPeer == null) {
inputPeer = getInputPeer(i);
}
if (inputPeer instanceof TLRPC.TL_inputPeerEmpty) {
return;
}
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer;
tL_messages_markDialogUnread.peer = tL_inputDialogPeer;
if (j2 == 0) {
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(inputPeer.getObjectSize() + 12);
} catch (Exception e) {
e = e;
}
try {
nativeByteBuffer.writeInt32(9);
nativeByteBuffer.writeInt64(j);
inputPeer.serializeToStream(nativeByteBuffer);
} catch (Exception e2) {
e = e2;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
getConnectionsManager().sendRequest(tL_messages_markDialogUnread, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markDialogAsUnread$240$MessagesController(j2, tLObject, tL_error);
}
});
}
j2 = getMessagesStorage().createPendingTask(nativeByteBuffer);
}
getConnectionsManager().sendRequest(tL_messages_markDialogUnread, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$markDialogAsUnread$240$MessagesController(j2, tLObject, tL_error);
}
});
}
}
public void lambda$markDialogAsUnread$240$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void loadUnreadDialogs() {
if (this.loadingUnreadDialogs || getUserConfig().unreadDialogsLoaded) {
return;
}
this.loadingUnreadDialogs = true;
getConnectionsManager().sendRequest(new TLRPC.TL_messages_getDialogUnreadMarks(), new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadUnreadDialogs$242$MessagesController(tLObject, tL_error);
}
});
}
public void lambda$loadUnreadDialogs$242$MessagesController(final TLObject tLObject, TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$241$MessagesController(tLObject);
}
});
}
public void lambda$null$241$MessagesController(TLObject tLObject) {
long j;
int i;
int i2;
if (tLObject != null) {
TLRPC.Vector vector = (TLRPC.Vector) tLObject;
int size = vector.objects.size();
for (int i3 = 0; i3 < size; i3++) {
TLRPC.DialogPeer dialogPeer = (TLRPC.DialogPeer) vector.objects.get(i3);
if (dialogPeer instanceof TLRPC.TL_dialogPeer) {
TLRPC.TL_dialogPeer tL_dialogPeer = (TLRPC.TL_dialogPeer) dialogPeer;
if (tL_dialogPeer.peer.user_id != 0) {
if (tL_dialogPeer.peer.user_id != 0) {
i2 = tL_dialogPeer.peer.user_id;
} else {
if (tL_dialogPeer.peer.chat_id != 0) {
i = tL_dialogPeer.peer.chat_id;
} else {
i = tL_dialogPeer.peer.channel_id;
}
i2 = -i;
}
j = i2;
} else {
j = 0;
}
getMessagesStorage().setDialogUnread(j, true);
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog != null && !dialog.unread_mark) {
dialog.unread_mark = true;
if (dialog.unread_count == 0) {
this.dialogsUnreadOnly.add(dialog);
if (!isDialogMuted(j)) {
this.unreadUnmutedDialogs++;
}
}
}
}
}
getUserConfig().unreadDialogsLoaded = true;
getUserConfig().saveConfig(false);
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 256);
this.loadingUnreadDialogs = false;
}
}
public void reorderPinnedDialogs(int i, ArrayList<TLRPC.InputDialogPeer> arrayList, final long j) {
NativeByteBuffer nativeByteBuffer;
TLRPC.TL_messages_reorderPinnedDialogs tL_messages_reorderPinnedDialogs = new TLRPC.TL_messages_reorderPinnedDialogs();
tL_messages_reorderPinnedDialogs.folder_id = i;
tL_messages_reorderPinnedDialogs.force = true;
if (j == 0) {
ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
if (dialogs.isEmpty()) {
return;
}
int size = dialogs.size();
int i2 = 0;
for (int i3 = 0; i3 < size; i3++) {
TLRPC.Dialog dialog = dialogs.get(i3);
if (!(dialog instanceof TLRPC.TL_dialogFolder)) {
if (!dialog.pinned) {
break;
}
getMessagesStorage().setDialogPinned(dialog.id, dialog.pinnedNum);
if (((int) dialog.id) != 0) {
TLRPC.InputPeer inputPeer = getInputPeer((int) dialogs.get(i3).id);
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer;
tL_messages_reorderPinnedDialogs.order.add(tL_inputDialogPeer);
i2 += tL_inputDialogPeer.getObjectSize();
}
}
}
NativeByteBuffer nativeByteBuffer2 = null;
try {
nativeByteBuffer = new NativeByteBuffer(i2 + 12);
} catch (Exception e) {
e = e;
}
try {
nativeByteBuffer.writeInt32(16);
nativeByteBuffer.writeInt32(i);
nativeByteBuffer.writeInt32(tL_messages_reorderPinnedDialogs.order.size());
int size2 = tL_messages_reorderPinnedDialogs.order.size();
for (int i4 = 0; i4 < size2; i4++) {
tL_messages_reorderPinnedDialogs.order.get(i4).serializeToStream(nativeByteBuffer);
}
} catch (Exception e2) {
e = e2;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
getConnectionsManager().sendRequest(tL_messages_reorderPinnedDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$reorderPinnedDialogs$243$MessagesController(j, tLObject, tL_error);
}
});
}
j = getMessagesStorage().createPendingTask(nativeByteBuffer);
} else {
tL_messages_reorderPinnedDialogs.order = arrayList;
}
getConnectionsManager().sendRequest(tL_messages_reorderPinnedDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$reorderPinnedDialogs$243$MessagesController(j, tLObject, tL_error);
}
});
}
public void lambda$reorderPinnedDialogs$243$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public boolean pinDialog(long j, boolean z, TLRPC.InputPeer inputPeer, long j2) {
NativeByteBuffer nativeByteBuffer;
final long createPendingTask;
int i = (int) j;
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog == null || dialog.pinned == z) {
return dialog != null;
}
int i2 = dialog.folder_id;
ArrayList<TLRPC.Dialog> dialogs = getDialogs(i2);
dialog.pinned = z;
if (z) {
int i3 = 0;
for (int i4 = 0; i4 < dialogs.size(); i4++) {
TLRPC.Dialog dialog2 = dialogs.get(i4);
if (!(dialog2 instanceof TLRPC.TL_dialogFolder)) {
if (!dialog2.pinned) {
break;
}
i3 = Math.max(dialog2.pinnedNum, i3);
}
}
dialog.pinnedNum = i3 + 1;
} else {
dialog.pinnedNum = 0;
}
NativeByteBuffer nativeByteBuffer2 = null;
sortDialogs(null);
if (!z && dialogs.get(dialogs.size() - 1) == dialog && !this.dialogsEndReached.get(i2)) {
dialogs.remove(dialogs.size() - 1);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
if (i != 0 && j2 != -1) {
TLRPC.TL_messages_toggleDialogPin tL_messages_toggleDialogPin = new TLRPC.TL_messages_toggleDialogPin();
tL_messages_toggleDialogPin.pinned = z;
TLRPC.InputPeer inputPeer2 = inputPeer == null ? getInputPeer(i) : inputPeer;
if (inputPeer2 instanceof TLRPC.TL_inputPeerEmpty) {
return false;
}
TLRPC.TL_inputDialogPeer tL_inputDialogPeer = new TLRPC.TL_inputDialogPeer();
tL_inputDialogPeer.peer = inputPeer2;
tL_messages_toggleDialogPin.peer = tL_inputDialogPeer;
if (j2 == 0) {
try {
nativeByteBuffer = new NativeByteBuffer(inputPeer2.getObjectSize() + 16);
} catch (Exception e) {
e = e;
}
try {
nativeByteBuffer.writeInt32(4);
nativeByteBuffer.writeInt64(j);
nativeByteBuffer.writeBool(z);
inputPeer2.serializeToStream(nativeByteBuffer);
} catch (Exception e2) {
e = e2;
nativeByteBuffer2 = nativeByteBuffer;
FileLog.e(e);
nativeByteBuffer = nativeByteBuffer2;
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
getConnectionsManager().sendRequest(tL_messages_toggleDialogPin, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$pinDialog$244$MessagesController(createPendingTask, tLObject, tL_error);
}
});
getMessagesStorage().setDialogPinned(j, dialog.pinnedNum);
return true;
}
createPendingTask = getMessagesStorage().createPendingTask(nativeByteBuffer);
} else {
createPendingTask = j2;
}
getConnectionsManager().sendRequest(tL_messages_toggleDialogPin, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$pinDialog$244$MessagesController(createPendingTask, tLObject, tL_error);
}
});
}
getMessagesStorage().setDialogPinned(j, dialog.pinnedNum);
return true;
}
public void lambda$pinDialog$244$MessagesController(long j, TLObject tLObject, TLRPC.TL_error tL_error) {
if (j != 0) {
getMessagesStorage().removePendingTask(j);
}
}
public void loadPinnedDialogs(final int i, long j, ArrayList<Long> arrayList) {
if (this.loadingPinnedDialogs.indexOfKey(i) >= 0 || getUserConfig().isPinnedDialogsLoaded(i)) {
return;
}
this.loadingPinnedDialogs.put(i, 1);
TLRPC.TL_messages_getPinnedDialogs tL_messages_getPinnedDialogs = new TLRPC.TL_messages_getPinnedDialogs();
tL_messages_getPinnedDialogs.folder_id = i;
getConnectionsManager().sendRequest(tL_messages_getPinnedDialogs, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$loadPinnedDialogs$247$MessagesController(i, tLObject, tL_error);
}
});
}
public void lambda$loadPinnedDialogs$247$MessagesController(final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
TLRPC.Chat chat;
Integer num;
Integer num2;
MessageObject messageObject;
TLRPC.Chat chat2;
if (tLObject != null) {
final TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs = (TLRPC.TL_messages_peerDialogs) tLObject;
final ArrayList arrayList = new ArrayList(tL_messages_peerDialogs.dialogs);
fetchFolderInLoadedPinnedDialogs(tL_messages_peerDialogs);
final TLRPC.TL_messages_dialogs tL_messages_dialogs = new TLRPC.TL_messages_dialogs();
tL_messages_dialogs.users.addAll(tL_messages_peerDialogs.users);
tL_messages_dialogs.chats.addAll(tL_messages_peerDialogs.chats);
tL_messages_dialogs.dialogs.addAll(tL_messages_peerDialogs.dialogs);
tL_messages_dialogs.messages.addAll(tL_messages_peerDialogs.messages);
final LongSparseArray longSparseArray = new LongSparseArray();
SparseArray sparseArray = new SparseArray();
SparseArray sparseArray2 = new SparseArray();
for (int i2 = 0; i2 < tL_messages_peerDialogs.users.size(); i2++) {
TLRPC.User user = tL_messages_peerDialogs.users.get(i2);
sparseArray.put(user.id, user);
}
for (int i3 = 0; i3 < tL_messages_peerDialogs.chats.size(); i3++) {
TLRPC.Chat chat3 = tL_messages_peerDialogs.chats.get(i3);
sparseArray2.put(chat3.id, chat3);
}
for (int i4 = 0; i4 < tL_messages_peerDialogs.messages.size(); i4++) {
TLRPC.Message message = tL_messages_peerDialogs.messages.get(i4);
if (message.to_id.channel_id != 0) {
TLRPC.Chat chat4 = (TLRPC.Chat) sparseArray2.get(message.to_id.channel_id);
if (chat4 != null && chat4.left) {
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
longSparseArray.put(messageObject2.getDialogId(), messageObject2);
} else {
if (message.to_id.chat_id != 0 && (chat2 = (TLRPC.Chat) sparseArray2.get(message.to_id.chat_id)) != null && chat2.migrated_to != null) {
}
MessageObject messageObject22 = new MessageObject(this.currentAccount, message, (SparseArray<TLRPC.User>) sparseArray, (SparseArray<TLRPC.Chat>) sparseArray2, false);
longSparseArray.put(messageObject22.getDialogId(), messageObject22);
}
}
boolean z = !arrayList.isEmpty() && (arrayList.get(0) instanceof TLRPC.TL_dialogFolder);
int size = arrayList.size();
for (int i5 = 0; i5 < size; i5++) {
TLRPC.Dialog dialog = (TLRPC.Dialog) arrayList.get(i5);
dialog.pinned = true;
DialogObject.initDialog(dialog);
if (DialogObject.isChannel(dialog)) {
TLRPC.Chat chat5 = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id));
if (chat5 != null && chat5.left) {
}
if (dialog.last_message_date == 0 && (messageObject = (MessageObject) longSparseArray.get(dialog.id)) != null) {
dialog.last_message_date = messageObject.messageOwner.date;
}
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
num = 0;
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
num2 = 0;
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
} else {
if (((int) dialog.id) < 0 && (chat = (TLRPC.Chat) sparseArray2.get(-((int) dialog.id))) != null && chat.migrated_to != null) {
}
if (dialog.last_message_date == 0) {
dialog.last_message_date = messageObject.messageOwner.date;
}
num = this.dialogs_read_inbox_max.get(Long.valueOf(dialog.id));
if (num == null) {
}
this.dialogs_read_inbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num.intValue(), dialog.read_inbox_max_id)));
num2 = this.dialogs_read_outbox_max.get(Long.valueOf(dialog.id));
if (num2 == null) {
}
this.dialogs_read_outbox_max.put(Long.valueOf(dialog.id), Integer.valueOf(Math.max(num2.intValue(), dialog.read_outbox_max_id)));
}
}
final boolean z2 = z;
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$246$MessagesController(i, arrayList, z2, tL_messages_peerDialogs, longSparseArray, tL_messages_dialogs);
}
});
}
}
public void lambda$null$246$MessagesController(final int i, final ArrayList arrayList, final boolean z, final TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, final LongSparseArray longSparseArray, final TLRPC.TL_messages_dialogs tL_messages_dialogs) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$245$MessagesController(i, arrayList, z, tL_messages_peerDialogs, longSparseArray, tL_messages_dialogs);
}
});
}
public void lambda$null$245$MessagesController(int i, ArrayList arrayList, boolean z, TLRPC.TL_messages_peerDialogs tL_messages_peerDialogs, LongSparseArray longSparseArray, TLRPC.TL_messages_dialogs tL_messages_dialogs) {
boolean z2;
this.loadingPinnedDialogs.delete(i);
applyDialogsNotificationsSettings(arrayList);
ArrayList<TLRPC.Dialog> dialogs = getDialogs(i);
int i2 = z ? 1 : 0;
int i3 = 0;
boolean z3 = false;
for (int i4 = 0; i4 < dialogs.size(); i4++) {
TLRPC.Dialog dialog = dialogs.get(i4);
if (!(dialog instanceof TLRPC.TL_dialogFolder)) {
if (((int) dialog.id) == 0) {
if (i2 < arrayList.size()) {
arrayList.add(i2, dialog);
} else {
arrayList.add(dialog);
}
i2++;
} else {
if (!dialog.pinned) {
break;
}
i3 = Math.max(dialog.pinnedNum, i3);
dialog.pinned = false;
dialog.pinnedNum = 0;
i2++;
z3 = true;
}
}
}
ArrayList<Long> arrayList2 = new ArrayList<>();
if (arrayList.isEmpty()) {
z2 = false;
} else {
putUsers(tL_messages_peerDialogs.users, false);
putChats(tL_messages_peerDialogs.chats, false);
int size = arrayList.size();
int i5 = 0;
z2 = false;
while (i5 < size) {
TLRPC.Dialog dialog2 = (TLRPC.Dialog) arrayList.get(i5);
dialog2.pinnedNum = (size - i5) + i3;
arrayList2.add(Long.valueOf(dialog2.id));
TLRPC.Dialog dialog3 = this.dialogs_dict.get(dialog2.id);
if (dialog3 != null) {
dialog3.pinned = true;
dialog3.pinnedNum = dialog2.pinnedNum;
getMessagesStorage().setDialogPinned(dialog2.id, dialog2.pinnedNum);
} else {
this.dialogs_dict.put(dialog2.id, dialog2);
MessageObject messageObject = (MessageObject) longSparseArray.get(dialog2.id);
this.dialogMessage.put(dialog2.id, messageObject);
if (messageObject != null && messageObject.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
}
}
z2 = true;
}
i5++;
z3 = true;
}
}
if (z3) {
if (z2) {
this.allDialogs.clear();
int size2 = this.dialogs_dict.size();
for (int i6 = 0; i6 < size2; i6++) {
this.allDialogs.add(this.dialogs_dict.valueAt(i6));
}
}
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
getMessagesStorage().unpinAllDialogsExceptNew(arrayList2, i);
getMessagesStorage().putDialogs(tL_messages_dialogs, 1);
getUserConfig().setPinnedDialogsLoaded(i, true);
getUserConfig().saveConfig(false);
}
public void generateJoinMessage(final int i, boolean z) {
TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (chat == null || !ChatObject.isChannel(i, this.currentAccount)) {
return;
}
if ((chat.left || chat.kicked) && !z) {
return;
}
TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
tL_messageService.flags = 256;
int newMessageId = getUserConfig().getNewMessageId();
tL_messageService.id = newMessageId;
tL_messageService.local_id = newMessageId;
tL_messageService.date = getConnectionsManager().getCurrentTime();
tL_messageService.from_id = getUserConfig().getClientUserId();
tL_messageService.to_id = new TLRPC.TL_peerChannel();
tL_messageService.to_id.channel_id = i;
tL_messageService.dialog_id = -i;
tL_messageService.post = true;
tL_messageService.action = new TLRPC.TL_messageActionChatAddUser();
tL_messageService.action.users.add(Integer.valueOf(getUserConfig().getClientUserId()));
if (chat.megagroup) {
tL_messageService.flags |= Integer.MIN_VALUE;
}
getUserConfig().saveConfig(false);
final ArrayList arrayList = new ArrayList();
ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
arrayList2.add(tL_messageService);
arrayList.add(new MessageObject(this.currentAccount, tL_messageService, true));
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$generateJoinMessage$249$MessagesController(arrayList);
}
});
getMessagesStorage().putMessages(arrayList2, true, true, false, 0, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$generateJoinMessage$250$MessagesController(i, arrayList);
}
});
}
public void lambda$generateJoinMessage$249$MessagesController(final ArrayList arrayList) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$248$MessagesController(arrayList);
}
});
}
public void lambda$null$248$MessagesController(ArrayList arrayList) {
getNotificationsController().processNewMessages(arrayList, true, false, null);
}
public void lambda$generateJoinMessage$250$MessagesController(int i, ArrayList arrayList) {
updateInterfaceWithMessages(-i, arrayList, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void deleteMessagesByPush(final long j, final ArrayList<Integer> arrayList, final int i) {
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$deleteMessagesByPush$252$MessagesController(arrayList, i, j);
}
});
}
public void lambda$deleteMessagesByPush$252$MessagesController(final ArrayList arrayList, final int i, long j) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$251$MessagesController(arrayList, i);
}
});
getMessagesStorage().deletePushMessages(j, arrayList);
getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, getMessagesStorage().markMessagesAsDeleted(arrayList, false, i, true, false), false, i);
}
public void lambda$null$251$MessagesController(ArrayList arrayList, int i) {
int i2 = 0;
getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, arrayList, Integer.valueOf(i), false);
if (i == 0) {
int size = arrayList.size();
while (i2 < size) {
MessageObject messageObject = this.dialogMessagesByIds.get(((Integer) arrayList.get(i2)).intValue());
if (messageObject != null) {
messageObject.deleted = true;
}
i2++;
}
return;
}
MessageObject messageObject2 = this.dialogMessage.get(-i);
if (messageObject2 != null) {
int size2 = arrayList.size();
while (i2 < size2) {
if (messageObject2.getId() == ((Integer) arrayList.get(i2)).intValue()) {
messageObject2.deleted = true;
return;
}
i2++;
}
}
}
public void checkChannelInviter(final int i) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$checkChannelInviter$258$MessagesController(i);
}
});
}
public void lambda$checkChannelInviter$258$MessagesController(final int i) {
final TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (chat == null || !ChatObject.isChannel(i, this.currentAccount) || chat.creator) {
return;
}
TLRPC.TL_channels_getParticipant tL_channels_getParticipant = new TLRPC.TL_channels_getParticipant();
tL_channels_getParticipant.channel = getInputChannel(i);
tL_channels_getParticipant.user_id = new TLRPC.TL_inputUserSelf();
getConnectionsManager().sendRequest(tL_channels_getParticipant, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$null$257$MessagesController(chat, i, tLObject, tL_error);
}
});
}
public void lambda$null$257$MessagesController(TLRPC.Chat chat, final int i, TLObject tLObject, TLRPC.TL_error tL_error) {
final TLRPC.TL_channels_channelParticipant tL_channels_channelParticipant = (TLRPC.TL_channels_channelParticipant) tLObject;
if (tL_channels_channelParticipant == null || !(tL_channels_channelParticipant.participant instanceof TLRPC.TL_channelParticipantSelf) || tL_channels_channelParticipant.participant.inviter_id == getUserConfig().getClientUserId()) {
return;
}
if (chat.megagroup && getMessagesStorage().isMigratedChat(chat.id)) {
return;
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$253$MessagesController(tL_channels_channelParticipant);
}
});
getMessagesStorage().putUsersAndChats(tL_channels_channelParticipant.users, null, true, true);
TLRPC.TL_messageService tL_messageService = new TLRPC.TL_messageService();
tL_messageService.media_unread = true;
tL_messageService.unread = true;
tL_messageService.flags = 256;
tL_messageService.post = true;
if (chat.megagroup) {
tL_messageService.flags |= Integer.MIN_VALUE;
}
int newMessageId = getUserConfig().getNewMessageId();
tL_messageService.id = newMessageId;
tL_messageService.local_id = newMessageId;
tL_messageService.date = tL_channels_channelParticipant.participant.date;
tL_messageService.action = new TLRPC.TL_messageActionChatAddUser();
tL_messageService.from_id = tL_channels_channelParticipant.participant.inviter_id;
tL_messageService.action.users.add(Integer.valueOf(getUserConfig().getClientUserId()));
tL_messageService.to_id = new TLRPC.TL_peerChannel();
tL_messageService.to_id.channel_id = i;
tL_messageService.dialog_id = -i;
getUserConfig().saveConfig(false);
final ArrayList arrayList = new ArrayList();
ArrayList<TLRPC.Message> arrayList2 = new ArrayList<>();
ConcurrentHashMap concurrentHashMap = new ConcurrentHashMap();
for (int i2 = 0; i2 < tL_channels_channelParticipant.users.size(); i2++) {
TLRPC.User user = tL_channels_channelParticipant.users.get(i2);
concurrentHashMap.put(Integer.valueOf(user.id), user);
}
arrayList2.add(tL_messageService);
arrayList.add(new MessageObject(this.currentAccount, (TLRPC.Message) tL_messageService, (AbstractMap<Integer, TLRPC.User>) concurrentHashMap, true));
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$255$MessagesController(arrayList);
}
});
getMessagesStorage().putMessages(arrayList2, true, true, false, 0, false);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$256$MessagesController(i, arrayList);
}
});
}
public void lambda$null$253$MessagesController(TLRPC.TL_channels_channelParticipant tL_channels_channelParticipant) {
putUsers(tL_channels_channelParticipant.users, false);
}
public void lambda$null$254$MessagesController(ArrayList arrayList) {
getNotificationsController().processNewMessages(arrayList, true, false, null);
}
public void lambda$null$255$MessagesController(final ArrayList arrayList) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$254$MessagesController(arrayList);
}
});
}
public void lambda$null$256$MessagesController(int i, ArrayList arrayList) {
updateInterfaceWithMessages(-i, arrayList, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
private int getUpdateType(TLRPC.Update update) {
if ((update instanceof TLRPC.TL_updateNewMessage) || (update instanceof TLRPC.TL_updateReadMessagesContents) || (update instanceof TLRPC.TL_updateReadHistoryInbox) || (update instanceof TLRPC.TL_updateReadHistoryOutbox) || (update instanceof TLRPC.TL_updateDeleteMessages) || (update instanceof TLRPC.TL_updateWebPage) || (update instanceof TLRPC.TL_updateEditMessage) || (update instanceof TLRPC.TL_updateFolderPeers)) {
return 0;
}
if (update instanceof TLRPC.TL_updateNewEncryptedMessage) {
return 1;
}
return ((update instanceof TLRPC.TL_updateNewChannelMessage) || (update instanceof TLRPC.TL_updateDeleteChannelMessages) || (update instanceof TLRPC.TL_updateEditChannelMessage) || (update instanceof TLRPC.TL_updateChannelWebPage)) ? 2 : 3;
}
private static int getUpdatePts(TLRPC.Update update) {
if (update instanceof TLRPC.TL_updateDeleteMessages) {
return ((TLRPC.TL_updateDeleteMessages) update).pts;
}
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
return ((TLRPC.TL_updateNewChannelMessage) update).pts;
}
if (update instanceof TLRPC.TL_updateReadHistoryOutbox) {
return ((TLRPC.TL_updateReadHistoryOutbox) update).pts;
}
if (update instanceof TLRPC.TL_updateNewMessage) {
return ((TLRPC.TL_updateNewMessage) update).pts;
}
if (update instanceof TLRPC.TL_updateEditMessage) {
return ((TLRPC.TL_updateEditMessage) update).pts;
}
if (update instanceof TLRPC.TL_updateWebPage) {
return ((TLRPC.TL_updateWebPage) update).pts;
}
if (update instanceof TLRPC.TL_updateReadHistoryInbox) {
return ((TLRPC.TL_updateReadHistoryInbox) update).pts;
}
if (update instanceof TLRPC.TL_updateChannelWebPage) {
return ((TLRPC.TL_updateChannelWebPage) update).pts;
}
if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
return ((TLRPC.TL_updateDeleteChannelMessages) update).pts;
}
if (update instanceof TLRPC.TL_updateEditChannelMessage) {
return ((TLRPC.TL_updateEditChannelMessage) update).pts;
}
if (update instanceof TLRPC.TL_updateReadMessagesContents) {
return ((TLRPC.TL_updateReadMessagesContents) update).pts;
}
if (update instanceof TLRPC.TL_updateChannelTooLong) {
return ((TLRPC.TL_updateChannelTooLong) update).pts;
}
if (update instanceof TLRPC.TL_updateFolderPeers) {
return ((TLRPC.TL_updateFolderPeers) update).pts;
}
return 0;
}
private static int getUpdatePtsCount(TLRPC.Update update) {
if (update instanceof TLRPC.TL_updateDeleteMessages) {
return ((TLRPC.TL_updateDeleteMessages) update).pts_count;
}
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
return ((TLRPC.TL_updateNewChannelMessage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateReadHistoryOutbox) {
return ((TLRPC.TL_updateReadHistoryOutbox) update).pts_count;
}
if (update instanceof TLRPC.TL_updateNewMessage) {
return ((TLRPC.TL_updateNewMessage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateEditMessage) {
return ((TLRPC.TL_updateEditMessage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateWebPage) {
return ((TLRPC.TL_updateWebPage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateReadHistoryInbox) {
return ((TLRPC.TL_updateReadHistoryInbox) update).pts_count;
}
if (update instanceof TLRPC.TL_updateChannelWebPage) {
return ((TLRPC.TL_updateChannelWebPage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
return ((TLRPC.TL_updateDeleteChannelMessages) update).pts_count;
}
if (update instanceof TLRPC.TL_updateEditChannelMessage) {
return ((TLRPC.TL_updateEditChannelMessage) update).pts_count;
}
if (update instanceof TLRPC.TL_updateReadMessagesContents) {
return ((TLRPC.TL_updateReadMessagesContents) update).pts_count;
}
if (update instanceof TLRPC.TL_updateFolderPeers) {
return ((TLRPC.TL_updateFolderPeers) update).pts_count;
}
return 0;
}
private static int getUpdateQts(TLRPC.Update update) {
if (update instanceof TLRPC.TL_updateNewEncryptedMessage) {
return ((TLRPC.TL_updateNewEncryptedMessage) update).qts;
}
return 0;
}
private static int getUpdateChannelId(TLRPC.Update update) {
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
return ((TLRPC.TL_updateNewChannelMessage) update).message.to_id.channel_id;
}
if (update instanceof TLRPC.TL_updateEditChannelMessage) {
return ((TLRPC.TL_updateEditChannelMessage) update).message.to_id.channel_id;
}
if (update instanceof TLRPC.TL_updateReadChannelOutbox) {
return ((TLRPC.TL_updateReadChannelOutbox) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelMessageViews) {
return ((TLRPC.TL_updateChannelMessageViews) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelTooLong) {
return ((TLRPC.TL_updateChannelTooLong) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelPinnedMessage) {
return ((TLRPC.TL_updateChannelPinnedMessage) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelReadMessagesContents) {
return ((TLRPC.TL_updateChannelReadMessagesContents) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelAvailableMessages) {
return ((TLRPC.TL_updateChannelAvailableMessages) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannel) {
return ((TLRPC.TL_updateChannel) update).channel_id;
}
if (update instanceof TLRPC.TL_updateChannelWebPage) {
return ((TLRPC.TL_updateChannelWebPage) update).channel_id;
}
if (update instanceof TLRPC.TL_updateDeleteChannelMessages) {
return ((TLRPC.TL_updateDeleteChannelMessages) update).channel_id;
}
if (update instanceof TLRPC.TL_updateReadChannelInbox) {
return ((TLRPC.TL_updateReadChannelInbox) update).channel_id;
}
if (!BuildVars.LOGS_ENABLED) {
return 0;
}
FileLog.e("trying to get unknown update channel_id for " + update);
return 0;
}
public void processUpdates(final TLRPC.Updates updates, boolean z) {
TLRPC.User user;
TLRPC.Chat chat;
boolean z2;
TLRPC.User user2;
boolean z3;
boolean z4;
int i;
boolean z5;
boolean z6;
int i2;
boolean z7;
ArrayList arrayList;
boolean z8;
boolean z9;
ArrayList arrayList2 = null;
int i3 = 0;
int i4 = 1;
if (updates instanceof TLRPC.TL_updateShort) {
ArrayList<TLRPC.Update> arrayList3 = new ArrayList<>();
arrayList3.add(updates.update);
processUpdateArray(arrayList3, null, null, false, updates.date);
} else {
boolean z10 = updates instanceof TLRPC.TL_updateShortChatMessage;
long j = 1500;
if (z10 || (updates instanceof TLRPC.TL_updateShortMessage)) {
final int i5 = z10 ? updates.from_id : updates.user_id;
TLRPC.User user3 = getUser(Integer.valueOf(i5));
if (user3 == null || user3.min) {
user3 = getMessagesStorage().getUserSync(i5);
if (user3 != null && user3.min) {
user3 = null;
}
putUser(user3, true);
}
if (updates.fwd_from != null) {
if (updates.fwd_from.from_id != 0) {
user = getUser(Integer.valueOf(updates.fwd_from.from_id));
if (user == null) {
user = getMessagesStorage().getUserSync(updates.fwd_from.from_id);
putUser(user, true);
}
z5 = true;
} else {
user = null;
z5 = false;
}
if (updates.fwd_from.channel_id != 0) {
chat = getChat(Integer.valueOf(updates.fwd_from.channel_id));
if (chat == null) {
chat = getMessagesStorage().getChatSync(updates.fwd_from.channel_id);
putChat(chat, true);
}
z2 = true;
} else {
z2 = z5;
chat = null;
}
} else {
user = null;
chat = null;
z2 = false;
}
if (updates.via_bot_id != 0) {
user2 = getUser(Integer.valueOf(updates.via_bot_id));
if (user2 == null) {
user2 = getMessagesStorage().getUserSync(updates.via_bot_id);
putUser(user2, true);
}
z3 = true;
} else {
user2 = null;
z3 = false;
}
boolean z11 = updates instanceof TLRPC.TL_updateShortMessage;
if (z11) {
if (user3 != null) {
if (z2) {
if (user == null) {
}
}
if (z3) {
}
z4 = false;
}
z4 = true;
} else {
TLRPC.Chat chat2 = getChat(Integer.valueOf(updates.chat_id));
if (chat2 == null) {
chat2 = getMessagesStorage().getChatSync(updates.chat_id);
putChat(chat2, true);
}
if (chat2 != null) {
if (user3 != null) {
if (z2) {
if (user == null) {
}
}
if (z3) {
}
z4 = false;
}
}
z4 = true;
}
if (!z4 && !updates.entities.isEmpty()) {
int i6 = 0;
while (true) {
if (i6 >= updates.entities.size()) {
break;
}
TLRPC.MessageEntity messageEntity = updates.entities.get(i6);
if (messageEntity instanceof TLRPC.TL_messageEntityMentionName) {
int i7 = ((TLRPC.TL_messageEntityMentionName) messageEntity).user_id;
TLRPC.User user4 = getUser(Integer.valueOf(i7));
if (user4 == null || user4.min) {
TLRPC.User userSync = getMessagesStorage().getUserSync(i7);
if (userSync != null && userSync.min) {
userSync = null;
}
if (userSync == null) {
z4 = true;
break;
}
putUser(user3, true);
}
}
i6++;
}
}
if (updates.out || user3 == null || user3.status == null || user3.status.expires > 0 || Math.abs(getConnectionsManager().getCurrentTime() - updates.date) >= 30) {
i = 0;
} else {
this.onlinePrivacy.put(Integer.valueOf(user3.id), Integer.valueOf(updates.date));
i = 1;
}
if (!z4) {
if (getMessagesStorage().getLastPtsValue() + updates.pts_count == updates.pts) {
TLRPC.TL_message tL_message = new TLRPC.TL_message();
tL_message.id = updates.id;
int clientUserId = getUserConfig().getClientUserId();
if (z11) {
if (updates.out) {
tL_message.from_id = clientUserId;
} else {
tL_message.from_id = i5;
}
tL_message.to_id = new TLRPC.TL_peerUser();
tL_message.to_id.user_id = i5;
tL_message.dialog_id = i5;
} else {
tL_message.from_id = i5;
tL_message.to_id = new TLRPC.TL_peerChat();
tL_message.to_id.chat_id = updates.chat_id;
tL_message.dialog_id = -updates.chat_id;
}
tL_message.fwd_from = updates.fwd_from;
tL_message.silent = updates.silent;
tL_message.out = updates.out;
tL_message.mentioned = updates.mentioned;
tL_message.media_unread = updates.media_unread;
tL_message.entities = updates.entities;
tL_message.message = updates.message;
tL_message.date = updates.date;
tL_message.via_bot_id = updates.via_bot_id;
tL_message.flags = updates.flags | 256;
tL_message.reply_to_msg_id = updates.reply_to_msg_id;
tL_message.media = new TLRPC.TL_messageMediaEmpty();
ConcurrentHashMap<Long, Integer> concurrentHashMap = tL_message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
Integer num = concurrentHashMap.get(Long.valueOf(tL_message.dialog_id));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(tL_message.out, tL_message.dialog_id));
concurrentHashMap.put(Long.valueOf(tL_message.dialog_id), num);
}
tL_message.unread = num.intValue() < tL_message.id;
if (tL_message.dialog_id == clientUserId) {
tL_message.unread = false;
tL_message.media_unread = false;
tL_message.out = true;
}
getMessagesStorage().setLastPtsValue(updates.pts);
MessageObject messageObject = new MessageObject(this.currentAccount, tL_message, this.createdDialogIds.contains(Long.valueOf(tL_message.dialog_id)));
final ArrayList<MessageObject> arrayList4 = new ArrayList<>();
arrayList4.add(messageObject);
ArrayList<TLRPC.Message> arrayList5 = new ArrayList<>();
arrayList5.add(tL_message);
if (z11) {
final boolean z12 = !updates.out && updatePrintingUsersWithNewMessages((long) updates.user_id, arrayList4);
if (z12) {
updatePrintingStrings();
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdates$259$MessagesController(z12, i5, arrayList4);
}
});
} else {
final boolean updatePrintingUsersWithNewMessages = updatePrintingUsersWithNewMessages(-updates.chat_id, arrayList4);
if (updatePrintingUsersWithNewMessages) {
updatePrintingStrings();
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdates$260$MessagesController(updatePrintingUsersWithNewMessages, updates, arrayList4);
}
});
}
if (!messageObject.isOut()) {
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdates$262$MessagesController(arrayList4);
}
});
}
getMessagesStorage().putMessages(arrayList5, false, true, false, 0, false);
} else if (getMessagesStorage().getLastPtsValue() != updates.pts) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("need get diff short message, act=" + this.currentAccount + " ,pts: " + getMessagesStorage().getLastPtsValue() + " ,up.pts=" + updates.pts + " ,count=" + updates.pts_count);
}
if (this.gettingDifference || this.updatesStartWaitTimePts == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimePts) <= 1500) {
if (this.updatesStartWaitTimePts == 0) {
this.updatesStartWaitTimePts = System.currentTimeMillis();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add to queue");
}
this.updatesQueuePts.add(updates);
}
}
i4 = 0;
i3 = i;
}
i4 = 1;
i3 = i;
} else {
boolean z13 = updates instanceof TLRPC.TL_updatesCombined;
if (z13 || (updates instanceof TLRPC.TL_updates)) {
SparseArray sparseArray = null;
for (int i8 = 0; i8 < updates.chats.size(); i8++) {
TLRPC.Chat chat3 = updates.chats.get(i8);
if ((chat3 instanceof TLRPC.TL_channel) && chat3.min) {
TLRPC.Chat chat4 = getChat(Integer.valueOf(chat3.id));
if (chat4 == null || chat4.min) {
chat4 = getMessagesStorage().getChatSync(updates.chat_id);
putChat(chat4, true);
}
if (chat4 == null || chat4.min) {
if (sparseArray == null) {
sparseArray = new SparseArray();
}
sparseArray.put(chat3.id, chat3);
}
}
}
if (sparseArray != null) {
for (int i9 = 0; i9 < updates.updates.size(); i9++) {
TLRPC.Update update = updates.updates.get(i9);
if (update instanceof TLRPC.TL_updateNewChannelMessage) {
int i10 = ((TLRPC.TL_updateNewChannelMessage) update).message.to_id.channel_id;
if (sparseArray.indexOfKey(i10) >= 0) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("need get diff because of min channel=" + i10 + " ,act=" + this.currentAccount);
}
i2 = 1;
if (i2 != 0) {
getMessagesStorage().putUsersAndChats(updates.users, updates.chats, true, true);
Collections.sort(updates.updates, this.updatesComparator);
ArrayList arrayList6 = null;
z7 = false;
int i11 = i2;
while (true) {
if (updates.updates.size() <= 0) {
arrayList = arrayList6;
z8 = z13;
break;
}
TLRPC.Update update2 = updates.updates.get(i3);
if (getUpdateType(update2) == 0) {
TLRPC.TL_updates tL_updates = new TLRPC.TL_updates();
tL_updates.updates.add(update2);
tL_updates.pts = getUpdatePts(update2);
tL_updates.pts_count = getUpdatePtsCount(update2);
while (i4 < updates.updates.size()) {
TLRPC.Update update3 = updates.updates.get(i4);
int updatePts = getUpdatePts(update3);
int updatePtsCount = getUpdatePtsCount(update3);
if (getUpdateType(update3) != 0 || tL_updates.pts + updatePtsCount != updatePts) {
break;
}
tL_updates.updates.add(update3);
tL_updates.pts = updatePts;
tL_updates.pts_count += updatePtsCount;
updates.updates.remove(i4);
}
if (getMessagesStorage().getLastPtsValue() + tL_updates.pts_count == tL_updates.pts) {
arrayList = arrayList6;
z8 = z13;
if (processUpdateArray(tL_updates.updates, updates.users, updates.chats, false, updates.date)) {
getMessagesStorage().setLastPtsValue(tL_updates.pts);
arrayList6 = arrayList;
}
i11 = 1;
arrayList6 = arrayList;
} else {
arrayList = arrayList6;
z8 = z13;
if (getMessagesStorage().getLastPtsValue() != tL_updates.pts) {
if (!this.gettingDifference) {
long j2 = this.updatesStartWaitTimePts;
if (j2 != 0) {
if (j2 != 0) {
}
i11 = 1;
}
}
if (this.updatesStartWaitTimePts == 0) {
this.updatesStartWaitTimePts = System.currentTimeMillis();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add to queue");
}
this.updatesQueuePts.add(tL_updates);
}
arrayList6 = arrayList;
}
} else {
arrayList = arrayList6;
z8 = z13;
if (getUpdateType(update2) == 1) {
TLRPC.TL_updates tL_updates2 = new TLRPC.TL_updates();
tL_updates2.updates.add(update2);
tL_updates2.pts = getUpdateQts(update2);
while (1 < updates.updates.size()) {
TLRPC.Update update4 = updates.updates.get(1);
int updateQts = getUpdateQts(update4);
if (getUpdateType(update4) != 1 || tL_updates2.pts + 1 != updateQts) {
break;
}
tL_updates2.updates.add(update4);
tL_updates2.pts = updateQts;
updates.updates.remove(1);
}
if (getMessagesStorage().getLastQtsValue() == 0 || getMessagesStorage().getLastQtsValue() + tL_updates2.updates.size() == tL_updates2.pts) {
processUpdateArray(tL_updates2.updates, updates.users, updates.chats, false, updates.date);
getMessagesStorage().setLastQtsValue(tL_updates2.pts);
z7 = true;
} else if (getMessagesStorage().getLastPtsValue() != tL_updates2.pts) {
if (!this.gettingDifference) {
long j3 = this.updatesStartWaitTimeQts;
if (j3 != 0) {
if (j3 != 0) {
}
i11 = 1;
}
}
if (this.updatesStartWaitTimeQts == 0) {
this.updatesStartWaitTimeQts = System.currentTimeMillis();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add to queue");
}
this.updatesQueueQts.add(tL_updates2);
}
} else {
if (getUpdateType(update2) != 2) {
break;
}
int updateChannelId = getUpdateChannelId(update2);
int i12 = this.channelsPts.get(updateChannelId);
if (i12 == 0) {
i12 = getMessagesStorage().getChannelPtsSync(updateChannelId);
if (i12 == 0) {
for (int i13 = 0; i13 < updates.chats.size(); i13++) {
TLRPC.Chat chat5 = updates.chats.get(i13);
if (chat5.id == updateChannelId) {
loadUnknownChannel(chat5, 0L);
z9 = true;
break;
}
}
} else {
this.channelsPts.put(updateChannelId, i12);
}
}
z9 = false;
TLRPC.TL_updates tL_updates3 = new TLRPC.TL_updates();
tL_updates3.updates.add(update2);
tL_updates3.pts = getUpdatePts(update2);
tL_updates3.pts_count = getUpdatePtsCount(update2);
while (1 < updates.updates.size()) {
TLRPC.Update update5 = updates.updates.get(1);
int updatePts2 = getUpdatePts(update5);
int updatePtsCount2 = getUpdatePtsCount(update5);
if (getUpdateType(update5) != 2 || updateChannelId != getUpdateChannelId(update5) || tL_updates3.pts + updatePtsCount2 != updatePts2) {
break;
}
tL_updates3.updates.add(update5);
tL_updates3.pts = updatePts2;
tL_updates3.pts_count += updatePtsCount2;
updates.updates.remove(1);
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("need load unknown channel = " + updateChannelId);
}
}
arrayList6 = arrayList;
}
updates.updates.remove(0);
z13 = z8;
i3 = 0;
i4 = 1;
j = 1500;
}
if (!z8 ? !(getMessagesStorage().getLastSeqValue() + 1 == updates.seq || updates.seq == 0 || updates.seq == getMessagesStorage().getLastSeqValue()) : !(getMessagesStorage().getLastSeqValue() + 1 == updates.seq_start || getMessagesStorage().getLastSeqValue() == updates.seq_start)) {
processUpdateArray(updates.updates, updates.users, updates.chats, false, updates.date);
if (updates.seq != 0) {
if (updates.date != 0) {
getMessagesStorage().setLastDateValue(updates.date);
}
getMessagesStorage().setLastSeqValue(updates.seq);
}
} else {
if (BuildVars.LOGS_ENABLED) {
if (z8) {
FileLog.d("need get diff TL_updatesCombined, seq=" + getMessagesStorage().getLastSeqValue() + " ,up.seq_start=" + updates.seq_start);
} else {
FileLog.d("need get diff TL_updates, seq=" + getMessagesStorage().getLastSeqValue() + " ,up.seq_start=" + updates.seq);
}
}
if (this.gettingDifference || this.updatesStartWaitTimeSeq == 0 || Math.abs(System.currentTimeMillis() - this.updatesStartWaitTimeSeq) <= 1500) {
if (this.updatesStartWaitTimeSeq == 0) {
this.updatesStartWaitTimeSeq = System.currentTimeMillis();
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("add TL_updates/Combined to queue");
}
this.updatesQueueSeq.add(updates);
} else {
arrayList2 = arrayList;
i4 = 1;
}
}
i4 = i11;
arrayList2 = arrayList;
} else {
i4 = i2;
z7 = false;
}
z6 = z7;
i3 = 0;
getSecretChatHelper().processPendingEncMessages();
if (!z) {
for (int i14 = 0; i14 < this.updatesQueueChannels.size(); i14++) {
int keyAt = this.updatesQueueChannels.keyAt(i14);
if (arrayList2 != null && arrayList2.contains(Integer.valueOf(keyAt))) {
getChannelDifference(keyAt);
} else {
processChannelsUpdatesQueue(keyAt, 0);
}
}
if (i4 != 0) {
getDifference();
} else {
for (int i15 = 0; i15 < 3; i15++) {
processUpdatesQueue(i15, 0);
}
}
}
if (z6) {
TLRPC.TL_messages_receivedQueue tL_messages_receivedQueue = new TLRPC.TL_messages_receivedQueue();
tL_messages_receivedQueue.max_qts = getMessagesStorage().getLastQtsValue();
getConnectionsManager().sendRequest(tL_messages_receivedQueue, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.lambda$processUpdates$263(tLObject, tL_error);
}
});
}
if (i3 != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdates$264$MessagesController();
}
});
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
}
}
}
}
i2 = 0;
if (i2 != 0) {
}
z6 = z7;
i3 = 0;
getSecretChatHelper().processPendingEncMessages();
if (!z) {
}
if (z6) {
}
if (i3 != 0) {
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
}
if (!(updates instanceof TLRPC.TL_updatesTooLong)) {
if (updates instanceof UserActionUpdatesSeq) {
getMessagesStorage().setLastSeqValue(updates.seq);
} else if (updates instanceof UserActionUpdatesPts) {
if (updates.chat_id != 0) {
this.channelsPts.put(updates.chat_id, updates.pts);
getMessagesStorage().saveChannelPts(updates.chat_id, updates.pts);
} else {
getMessagesStorage().setLastPtsValue(updates.pts);
}
}
}
}
z6 = false;
getSecretChatHelper().processPendingEncMessages();
if (!z) {
}
if (z6) {
}
if (i3 != 0) {
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
}
z6 = false;
i4 = 0;
getSecretChatHelper().processPendingEncMessages();
if (!z) {
}
if (z6) {
}
if (i3 != 0) {
}
getMessagesStorage().saveDiffParams(getMessagesStorage().getLastSeqValue(), getMessagesStorage().getLastPtsValue(), getMessagesStorage().getLastDateValue(), getMessagesStorage().getLastQtsValue());
}
public void lambda$processUpdates$259$MessagesController(boolean z, int i, ArrayList arrayList) {
if (z) {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
}
updateInterfaceWithMessages(i, arrayList, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void lambda$processUpdates$260$MessagesController(boolean z, TLRPC.Updates updates, ArrayList arrayList) {
if (z) {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 64);
}
updateInterfaceWithMessages(-updates.chat_id, arrayList, false);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
public void lambda$null$261$MessagesController(ArrayList arrayList) {
getNotificationsController().processNewMessages(arrayList, true, false, null);
}
public void lambda$processUpdates$262$MessagesController(final ArrayList arrayList) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$261$MessagesController(arrayList);
}
});
}
public void lambda$processUpdates$264$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, 4);
}
public void ensureMessagesLoaded(long j, boolean z, int i, Runnable runnable) {
int i2;
SharedPreferences notificationsSettings = getNotificationsSettings(this.currentAccount);
if (i == 0) {
i2 = notificationsSettings.getInt("diditem" + j, 0);
} else {
i2 = i;
}
int generateClassGuid = ConnectionsManager.generateClassGuid();
getNotificationCenter().addObserver(new NotificationCenter.NotificationCenterDelegate() {
final Runnable val$callback;
final int val$classGuid;
final long val$dialog_id;
AnonymousClass1(int generateClassGuid2, long j2, Runnable runnable2) {
r2 = generateClassGuid2;
r3 = j2;
r5 = runnable2;
}
@Override
public void didReceivedNotification(int i3, int i4, Object... objArr) {
if (i3 == NotificationCenter.messagesDidLoad && ((Integer) objArr[10]).intValue() == r2) {
ArrayList arrayList = (ArrayList) objArr[2];
boolean booleanValue = ((Boolean) objArr[3]).booleanValue();
if (arrayList.isEmpty() && booleanValue) {
MessagesController.this.loadMessages(r3, 20, 3, 0, false, 0, r2, 3, 0, false, false, 0);
} else {
MessagesController.this.getNotificationCenter().removeObserver(this, NotificationCenter.didReceiveNewMessages);
r5.run();
}
}
}
}, NotificationCenter.messagesDidLoad);
loadMessages(j2, 1, i2, 0, true, 0, generateClassGuid2, 3, 0, false, false, 0);
}
public class AnonymousClass1 implements NotificationCenter.NotificationCenterDelegate {
final Runnable val$callback;
final int val$classGuid;
final long val$dialog_id;
AnonymousClass1(int generateClassGuid2, long j2, Runnable runnable2) {
r2 = generateClassGuid2;
r3 = j2;
r5 = runnable2;
}
@Override
public void didReceivedNotification(int i3, int i4, Object... objArr) {
if (i3 == NotificationCenter.messagesDidLoad && ((Integer) objArr[10]).intValue() == r2) {
ArrayList arrayList = (ArrayList) objArr[2];
boolean booleanValue = ((Boolean) objArr[3]).booleanValue();
if (arrayList.isEmpty() && booleanValue) {
MessagesController.this.loadMessages(r3, 20, 3, 0, false, 0, r2, 3, 0, false, false, 0);
} else {
MessagesController.this.getNotificationCenter().removeObserver(this, NotificationCenter.didReceiveNewMessages);
r5.run();
}
}
}
}
public boolean processUpdateArray(ArrayList<TLRPC.Update> arrayList, final ArrayList<TLRPC.User> arrayList2, final ArrayList<TLRPC.Chat> arrayList3, boolean z, int i) {
ConcurrentHashMap<Integer, TLRPC.User> concurrentHashMap;
boolean z2;
ConcurrentHashMap<Integer, TLRPC.Chat> concurrentHashMap2;
SparseLongArray sparseLongArray;
ArrayList<Long> arrayList4;
boolean z3;
SparseArray sparseArray;
ArrayList arrayList5;
TLRPC.Message message;
int i2;
int i3;
TLRPC.Chat chat;
long j;
boolean z4;
LongSparseArray<TLRPC.WebPage> longSparseArray;
boolean z5;
long j2;
int i4;
TLRPC.SendMessageAction sendMessageAction;
int i5;
int i6;
long j3;
boolean z6;
int i7;
ArrayList<Integer> arrayList6;
ArrayList<Long> arrayList7;
SparseArray<SparseIntArray> sparseArray2;
ArrayList arrayList8;
LongSparseArray longSparseArray2;
SparseLongArray sparseLongArray2;
SparseLongArray sparseLongArray3;
SparseArray<SparseIntArray> sparseArray3;
SparseIntArray sparseIntArray;
final TLRPC.Message message2;
SparseArray<SparseIntArray> sparseArray4;
SparseIntArray sparseIntArray2;
boolean z7;
Integer num;
ArrayList arrayList9;
HashMap hashMap;
ArrayList arrayList10;
int i8;
int i9;
ArrayList arrayList11;
int i10;
ArrayList arrayList12;
long j4;
boolean z8;
LongSparseArray longSparseArray3;
SparseArray sparseArray5;
ArrayList<TLRPC.Message> arrayList13;
TLRPC.User user;
ArrayList arrayList14;
ArrayList arrayList15;
int i11;
int i12;
int i13;
ArrayList<TLRPC.Update> arrayList16 = arrayList;
if (arrayList.isEmpty()) {
if (arrayList2 != null || arrayList3 != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$265$MessagesController(arrayList2, arrayList3);
}
});
}
return true;
}
long currentTimeMillis = System.currentTimeMillis();
if (arrayList2 != null) {
concurrentHashMap = new ConcurrentHashMap<>();
int size = arrayList2.size();
for (int i14 = 0; i14 < size; i14++) {
TLRPC.User user2 = arrayList2.get(i14);
concurrentHashMap.put(Integer.valueOf(user2.id), user2);
}
z2 = true;
} else {
concurrentHashMap = this.users;
z2 = false;
}
if (arrayList3 != null) {
ConcurrentHashMap<Integer, TLRPC.Chat> concurrentHashMap3 = new ConcurrentHashMap<>();
int size2 = arrayList3.size();
for (int i15 = 0; i15 < size2; i15++) {
TLRPC.Chat chat2 = arrayList3.get(i15);
concurrentHashMap3.put(Integer.valueOf(chat2.id), chat2);
}
concurrentHashMap2 = concurrentHashMap3;
} else {
concurrentHashMap2 = this.chats;
z2 = false;
}
boolean z9 = z ? false : z2;
if (arrayList2 != null || arrayList3 != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$266$MessagesController(arrayList2, arrayList3);
}
});
}
HashMap hashMap2 = new HashMap();
for (int i16 = 0; i16 < arrayList.size(); i16++) {
TLRPC.Update update = arrayList16.get(i16);
if (update instanceof TLRPCCall.TL_UpdateMeetCallRequested) {
hashMap2.put(((TLRPCCall.TL_UpdateMeetCallRequested) update).id, "1");
}
if (update instanceof TLRPCCall.TL_UpdateMeetCallDiscarded) {
TLRPCCall.TL_UpdateMeetCallDiscarded tL_UpdateMeetCallDiscarded = (TLRPCCall.TL_UpdateMeetCallDiscarded) update;
if (hashMap2.get(tL_UpdateMeetCallDiscarded.id) != null) {
hashMap2.remove(tL_UpdateMeetCallDiscarded.id);
}
}
}
int size3 = arrayList.size();
HashMap hashMap3 = hashMap2;
long j5 = currentTimeMillis;
LongSparseArray<TLRPC.WebPage> longSparseArray4 = null;
SparseLongArray sparseLongArray4 = null;
SparseArray sparseArray6 = null;
SparseArray sparseArray7 = null;
SparseArray<SparseIntArray> sparseArray8 = null;
ArrayList<Integer> arrayList17 = null;
LongSparseArray longSparseArray5 = null;
LongSparseArray longSparseArray6 = null;
ArrayList<Long> arrayList18 = null;
SparseLongArray sparseLongArray5 = null;
ArrayList arrayList19 = null;
LongSparseArray longSparseArray7 = null;
ArrayList arrayList20 = null;
ArrayList arrayList21 = null;
ArrayList<TLRPC.Message> arrayList22 = null;
ArrayList<TLRPC.Message> arrayList23 = null;
SparseIntArray sparseIntArray3 = null;
SparseIntArray sparseIntArray4 = null;
ArrayList arrayList24 = null;
int i17 = 0;
int i18 = 0;
boolean z10 = false;
while (i17 < size3) {
final TLRPC.Update update2 = arrayList16.get(i17);
int i19 = size3;
boolean z11 = update2 instanceof TLRPC.TL_updateNewMessage;
int i20 = i17;
if (z11 || (update2 instanceof TLRPC.TL_updateNewChannelMessage) || (update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
sparseArray = sparseArray7;
ArrayList<Integer> arrayList25 = arrayList17;
int i21 = i18;
ArrayList<Long> arrayList26 = arrayList18;
arrayList5 = arrayList21;
SparseIntArray sparseIntArray5 = sparseIntArray4;
SparseLongArray sparseLongArray6 = sparseLongArray4;
LongSparseArray longSparseArray8 = longSparseArray5;
LongSparseArray longSparseArray9 = longSparseArray6;
SparseLongArray sparseLongArray7 = sparseLongArray5;
long j6 = j5;
SparseArray<SparseIntArray> sparseArray9 = sparseArray8;
if (z11) {
message = ((TLRPC.TL_updateNewMessage) update2).message;
} else if (update2 instanceof TLRPC.TL_updateNewScheduledMessage) {
message = ((TLRPC.TL_updateNewScheduledMessage) update2).message;
} else {
message = ((TLRPC.TL_updateNewChannelMessage) update2).message;
if (!message.out && message.from_id == getUserConfig().getClientUserId()) {
message.out = true;
}
}
if (message.to_id.channel_id != 0) {
i2 = message.to_id.channel_id;
} else if (message.to_id.chat_id != 0) {
i2 = message.to_id.chat_id;
} else if (message.to_id.user_id != 0) {
i3 = message.to_id.user_id;
i2 = 0;
if (i2 == 0) {
chat = concurrentHashMap2.get(Integer.valueOf(i2));
if (chat == null) {
chat = getChat(Integer.valueOf(i2));
}
if (chat == null) {
chat = getMessagesStorage().getChatSync(i2);
putChat(chat, true);
}
} else {
chat = null;
}
if (z9) {
if (i2 != 0 && chat == null) {
if (!BuildVars.LOGS_ENABLED) {
return false;
}
FileLog.d("not found chat " + i2);
return false;
}
int size4 = message.entities.size() + 3;
int i22 = 0;
while (i22 < size4) {
SparseArray sparseArray10 = sparseArray6;
if (i22 != 0) {
if (i22 == 1) {
i4 = message.from_id;
if (message.post) {
i3 = i4;
z5 = true;
int i23 = size4;
if (i3 <= 0) {
TLRPC.User user3 = concurrentHashMap.get(Integer.valueOf(i3));
j2 = j6;
if (user3 == null || (!z5 && user3.min)) {
user3 = getUser(Integer.valueOf(i3));
}
if (user3 == null || (!z5 && user3.min)) {
user3 = getMessagesStorage().getUserSync(i3);
if (user3 != null && !z5 && user3.min) {
user3 = null;
}
putUser(user3, true);
}
if (user3 == null) {
if (!BuildVars.LOGS_ENABLED) {
return false;
}
FileLog.d("not found user " + i3);
return false;
}
if (!message.out && i22 == 1 && user3.status != null && user3.status.expires <= 0) {
if (Math.abs(getConnectionsManager().getCurrentTime() - message.date) < 30) {
this.onlinePrivacy.put(Integer.valueOf(i3), Integer.valueOf(message.date));
i21 |= 4;
}
i22++;
size4 = i23;
sparseArray6 = sparseArray10;
j6 = j2;
}
} else {
j2 = j6;
}
i22++;
size4 = i23;
sparseArray6 = sparseArray10;
j6 = j2;
}
} else if (i22 == 2) {
i3 = message.fwd_from != null ? message.fwd_from.from_id : 0;
} else {
TLRPC.MessageEntity messageEntity = message.entities.get(i22 - 3);
i4 = messageEntity instanceof TLRPC.TL_messageEntityMentionName ? ((TLRPC.TL_messageEntityMentionName) messageEntity).user_id : 0;
}
i3 = i4;
}
z5 = false;
int i232 = size4;
if (i3 <= 0) {
}
i22++;
size4 = i232;
sparseArray6 = sparseArray10;
j6 = j2;
}
}
SparseArray sparseArray11 = sparseArray6;
j = j6;
if (chat != null && chat.megagroup) {
message.flags |= Integer.MIN_VALUE;
}
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
TLRPC.User user4 = concurrentHashMap.get(Integer.valueOf(message.action.user_id));
if (user4 != null && user4.bot) {
message.reply_markup = new TLRPC.TL_replyKeyboardHide();
message.flags |= 64;
} else if (message.from_id == getUserConfig().getClientUserId() && message.action.user_id == getUserConfig().getClientUserId()) {
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray8;
longSparseArray6 = longSparseArray9;
sparseArray8 = sparseArray9;
sparseLongArray4 = sparseLongArray6;
sparseLongArray5 = sparseLongArray7;
arrayList18 = arrayList26;
arrayList17 = arrayList25;
sparseIntArray4 = sparseIntArray5;
i18 = i21;
sparseArray6 = sparseArray11;
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
}
}
ImageLoader.saveMessageThumbs(message);
int clientUserId = getUserConfig().getClientUserId();
if (message.to_id.chat_id == 0) {
message.dialog_id = -message.to_id.chat_id;
} else if (message.to_id.channel_id != 0) {
message.dialog_id = -message.to_id.channel_id;
} else {
if (message.to_id.user_id == clientUserId) {
message.to_id.user_id = message.from_id;
}
if (clientUserId == 0) {
message.dialog_id = message.from_id;
} else {
message.dialog_id = message.to_id.user_id;
}
}
if (!(update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
if (arrayList22 == null) {
arrayList22 = new ArrayList<>();
}
ArrayList<TLRPC.Message> arrayList27 = arrayList22;
arrayList27.add(message);
j5 = j;
MessageObject messageObject = new MessageObject(this.currentAccount, message, concurrentHashMap, concurrentHashMap2, this.createdScheduledDialogIds.contains(Long.valueOf(message.dialog_id)));
messageObject.scheduled = true;
if (longSparseArray7 == null) {
longSparseArray7 = new LongSparseArray();
}
LongSparseArray longSparseArray10 = longSparseArray7;
ArrayList arrayList28 = (ArrayList) longSparseArray10.get(message.dialog_id);
if (arrayList28 == null) {
arrayList28 = new ArrayList();
longSparseArray10.put(message.dialog_id, arrayList28);
}
arrayList28.add(messageObject);
arrayList22 = arrayList27;
longSparseArray7 = longSparseArray10;
longSparseArray6 = longSparseArray9;
} else {
j5 = j;
if (arrayList23 == null) {
arrayList23 = new ArrayList<>();
}
ArrayList<TLRPC.Message> arrayList29 = arrayList23;
arrayList29.add(message);
ConcurrentHashMap<Long, Integer> concurrentHashMap4 = message.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
Integer num2 = concurrentHashMap4.get(Long.valueOf(message.dialog_id));
if (num2 == null) {
num2 = Integer.valueOf(getMessagesStorage().getDialogReadMax(message.out, message.dialog_id));
concurrentHashMap4.put(Long.valueOf(message.dialog_id), num2);
}
message.unread = num2.intValue() < message.id && !((chat != null && ChatObject.isNotInChat(chat)) || (message.action instanceof TLRPC.TL_messageActionChatMigrateTo) || (message.action instanceof TLRPC.TL_messageActionChannelCreate));
if (message.dialog_id == clientUserId) {
if (message.from_scheduled) {
z4 = false;
} else {
z4 = false;
message.unread = false;
}
message.media_unread = z4;
message.out = true;
}
MessageObject messageObject2 = new MessageObject(this.currentAccount, message, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message.dialog_id)));
if (messageObject2.type == 11) {
i21 |= 8;
} else if (messageObject2.type == 10) {
i21 |= 16;
}
longSparseArray6 = longSparseArray9 == null ? new LongSparseArray() : longSparseArray9;
ArrayList arrayList30 = (ArrayList) longSparseArray6.get(message.dialog_id);
if (arrayList30 == null) {
arrayList30 = new ArrayList();
longSparseArray6.put(message.dialog_id, arrayList30);
}
arrayList30.add(messageObject2);
if ((!messageObject2.isOut() || messageObject2.messageOwner.from_scheduled) && messageObject2.isUnread()) {
ArrayList arrayList31 = arrayList5 == null ? new ArrayList() : arrayList5;
arrayList31.add(messageObject2);
arrayList23 = arrayList29;
arrayList5 = arrayList31;
} else {
arrayList23 = arrayList29;
}
}
i18 = i21;
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray8;
sparseArray8 = sparseArray9;
sparseLongArray4 = sparseLongArray6;
sparseLongArray5 = sparseLongArray7;
arrayList18 = arrayList26;
arrayList17 = arrayList25;
sparseIntArray4 = sparseIntArray5;
sparseArray6 = sparseArray11;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
} else {
i2 = 0;
}
i3 = 0;
if (i2 == 0) {
}
if (z9) {
}
SparseArray sparseArray112 = sparseArray6;
j = j6;
if (chat != null) {
message.flags |= Integer.MIN_VALUE;
}
if (message.action instanceof TLRPC.TL_messageActionChatDeleteUser) {
}
ImageLoader.saveMessageThumbs(message);
int clientUserId2 = getUserConfig().getClientUserId();
if (message.to_id.chat_id == 0) {
}
if (!(update2 instanceof TLRPC.TL_updateNewScheduledMessage)) {
}
i18 = i21;
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray8;
sparseArray8 = sparseArray9;
sparseLongArray4 = sparseLongArray6;
sparseLongArray5 = sparseLongArray7;
arrayList18 = arrayList26;
arrayList17 = arrayList25;
sparseIntArray4 = sparseIntArray5;
sparseArray6 = sparseArray112;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
} else {
if (update2 instanceof TLRPC.TL_updateReadMessagesContents) {
TLRPC.TL_updateReadMessagesContents tL_updateReadMessagesContents = (TLRPC.TL_updateReadMessagesContents) update2;
if (arrayList18 == null) {
arrayList18 = new ArrayList<>();
}
int size5 = tL_updateReadMessagesContents.messages.size();
int i24 = 0;
while (i24 < size5) {
arrayList18.add(Long.valueOf(tL_updateReadMessagesContents.messages.get(i24).intValue()));
i24++;
size5 = size5;
longSparseArray6 = longSparseArray6;
longSparseArray5 = longSparseArray5;
}
} else {
LongSparseArray longSparseArray11 = longSparseArray5;
LongSparseArray longSparseArray12 = longSparseArray6;
if (update2 instanceof TLRPC.TL_updateChannelReadMessagesContents) {
TLRPC.TL_updateChannelReadMessagesContents tL_updateChannelReadMessagesContents = (TLRPC.TL_updateChannelReadMessagesContents) update2;
if (arrayList18 == null) {
arrayList18 = new ArrayList<>();
}
int size6 = tL_updateChannelReadMessagesContents.messages.size();
int i25 = 0;
while (i25 < size6) {
arrayList18.add(Long.valueOf(tL_updateChannelReadMessagesContents.messages.get(i25).intValue() | (tL_updateChannelReadMessagesContents.channel_id << 32)));
i25++;
sparseArray8 = sparseArray8;
i18 = i18;
}
longSparseArray = longSparseArray4;
longSparseArray6 = longSparseArray12;
longSparseArray5 = longSparseArray11;
} else {
SparseArray<SparseIntArray> sparseArray12 = sparseArray8;
int i26 = i18;
if (update2 instanceof TLRPC.TL_updateReadHistoryInbox) {
TLRPC.TL_updateReadHistoryInbox tL_updateReadHistoryInbox = (TLRPC.TL_updateReadHistoryInbox) update2;
if (sparseLongArray5 == null) {
sparseLongArray5 = new SparseLongArray();
}
if (tL_updateReadHistoryInbox.peer.chat_id != 0) {
sparseLongArray5.put(-tL_updateReadHistoryInbox.peer.chat_id, tL_updateReadHistoryInbox.max_id);
i13 = -tL_updateReadHistoryInbox.peer.chat_id;
} else {
sparseLongArray5.put(tL_updateReadHistoryInbox.peer.user_id, tL_updateReadHistoryInbox.max_id);
i13 = tL_updateReadHistoryInbox.peer.user_id;
}
long j7 = i13;
Integer num3 = this.dialogs_read_inbox_max.get(Long.valueOf(j7));
if (num3 == null) {
num3 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j7));
}
this.dialogs_read_inbox_max.put(Long.valueOf(j7), Integer.valueOf(Math.max(num3.intValue(), tL_updateReadHistoryInbox.max_id)));
} else if (update2 instanceof TLRPC.TL_updateReadHistoryOutbox) {
TLRPC.TL_updateReadHistoryOutbox tL_updateReadHistoryOutbox = (TLRPC.TL_updateReadHistoryOutbox) update2;
if (sparseLongArray4 == null) {
sparseLongArray4 = new SparseLongArray();
}
if (tL_updateReadHistoryOutbox.peer.chat_id != 0) {
sparseLongArray4.put(-tL_updateReadHistoryOutbox.peer.chat_id, tL_updateReadHistoryOutbox.max_id);
i12 = -tL_updateReadHistoryOutbox.peer.chat_id;
} else {
sparseLongArray4.put(tL_updateReadHistoryOutbox.peer.user_id, tL_updateReadHistoryOutbox.max_id);
i12 = tL_updateReadHistoryOutbox.peer.user_id;
}
long j8 = i12;
Integer num4 = this.dialogs_read_outbox_max.get(Long.valueOf(j8));
if (num4 == null) {
num4 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j8));
}
this.dialogs_read_outbox_max.put(Long.valueOf(j8), Integer.valueOf(Math.max(num4.intValue(), tL_updateReadHistoryOutbox.max_id)));
} else if (update2 instanceof TLRPC.TL_updateDeleteMessages) {
TLRPC.TL_updateDeleteMessages tL_updateDeleteMessages = (TLRPC.TL_updateDeleteMessages) update2;
if (sparseArray6 == null) {
sparseArray6 = new SparseArray();
}
ArrayList arrayList32 = (ArrayList) sparseArray6.get(0);
if (arrayList32 == null) {
arrayList32 = new ArrayList();
sparseArray6.put(0, arrayList32);
}
arrayList32.addAll(tL_updateDeleteMessages.messages);
} else if (update2 instanceof TLRPC.TL_updateDeleteScheduledMessages) {
TLRPC.TL_updateDeleteScheduledMessages tL_updateDeleteScheduledMessages = (TLRPC.TL_updateDeleteScheduledMessages) update2;
if (sparseArray7 == null) {
sparseArray7 = new SparseArray();
}
if (tL_updateDeleteScheduledMessages.peer instanceof TLRPC.TL_peerChannel) {
i11 = tL_updateDeleteScheduledMessages.peer.channel_id;
arrayList15 = (ArrayList) sparseArray7.get(i11);
} else {
arrayList15 = (ArrayList) sparseArray7.get(0);
i11 = 0;
}
if (arrayList15 == null) {
arrayList15 = new ArrayList();
sparseArray7.put(i11, arrayList15);
}
arrayList15.addAll(tL_updateDeleteScheduledMessages.messages);
} else {
boolean z12 = update2 instanceof TLRPC.TL_updateUserTyping;
if (z12 || (update2 instanceof TLRPC.TL_updateChatUserTyping)) {
sparseArray = sparseArray7;
ArrayList<Integer> arrayList33 = arrayList17;
ArrayList<Long> arrayList34 = arrayList18;
arrayList5 = arrayList21;
long j9 = j5;
SparseIntArray sparseIntArray6 = sparseIntArray4;
SparseLongArray sparseLongArray8 = sparseLongArray4;
SparseLongArray sparseLongArray9 = sparseLongArray5;
if (z12) {
TLRPC.TL_updateUserTyping tL_updateUserTyping = (TLRPC.TL_updateUserTyping) update2;
i6 = tL_updateUserTyping.user_id;
sendMessageAction = tL_updateUserTyping.action;
i5 = 0;
} else {
TLRPC.TL_updateChatUserTyping tL_updateChatUserTyping = (TLRPC.TL_updateChatUserTyping) update2;
int i27 = tL_updateChatUserTyping.chat_id;
int i28 = tL_updateChatUserTyping.user_id;
sendMessageAction = tL_updateChatUserTyping.action;
i5 = i27;
i6 = i28;
}
if (i6 != getUserConfig().getClientUserId()) {
long j10 = -i5;
if (j10 == 0) {
j10 = i6;
}
ArrayList<PrintingUser> arrayList35 = this.printingUsers.get(Long.valueOf(j10));
if (sendMessageAction instanceof TLRPC.TL_sendMessageCancelAction) {
if (arrayList35 != null) {
int size7 = arrayList35.size();
int i29 = 0;
while (true) {
if (i29 >= size7) {
break;
}
if (arrayList35.get(i29).userId == i6) {
arrayList35.remove(i29);
z10 = true;
break;
}
i29++;
}
if (arrayList35.isEmpty()) {
this.printingUsers.remove(Long.valueOf(j10));
}
}
j3 = j9;
} else {
if (arrayList35 == null) {
arrayList35 = new ArrayList<>();
this.printingUsers.put(Long.valueOf(j10), arrayList35);
}
Iterator<PrintingUser> it = arrayList35.iterator();
while (true) {
if (!it.hasNext()) {
j3 = j9;
z6 = false;
break;
}
PrintingUser next = it.next();
if (next.userId == i6) {
j3 = j9;
next.lastTime = j3;
if (next.action.getClass() != sendMessageAction.getClass()) {
z10 = true;
}
next.action = sendMessageAction;
z6 = true;
}
}
if (!z6) {
PrintingUser printingUser = new PrintingUser();
printingUser.userId = i6;
printingUser.lastTime = j3;
printingUser.action = sendMessageAction;
arrayList35.add(printingUser);
z10 = true;
}
}
if (Math.abs(getConnectionsManager().getCurrentTime() - i) < 30) {
this.onlinePrivacy.put(Integer.valueOf(i6), Integer.valueOf(i));
}
} else {
j3 = j9;
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
j5 = j3;
longSparseArray6 = longSparseArray12;
sparseArray8 = sparseArray12;
sparseLongArray4 = sparseLongArray8;
sparseLongArray5 = sparseLongArray9;
arrayList18 = arrayList34;
arrayList17 = arrayList33;
sparseIntArray4 = sparseIntArray6;
i18 = i26;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
} else {
if (update2 instanceof TLRPC.TL_updateChatParticipants) {
TLRPC.TL_updateChatParticipants tL_updateChatParticipants = (TLRPC.TL_updateChatParticipants) update2;
i18 = i26 | 32;
if (arrayList20 == null) {
arrayList20 = new ArrayList();
}
ArrayList arrayList36 = arrayList20;
arrayList36.add(tL_updateChatParticipants.participants);
longSparseArray = longSparseArray4;
arrayList20 = arrayList36;
} else {
if (update2 instanceof TLRPC.TL_updateUserStatus) {
i18 = i26 | 4;
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList14 = arrayList19;
arrayList14.add(update2);
} else if (update2 instanceof TLRPC.TL_updateUserName) {
i18 = i26 | 1;
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList14 = arrayList19;
arrayList14.add(update2);
} else if (update2 instanceof TLRPC.TL_updateUserPhoto) {
i18 = i26 | 2;
getMessagesStorage().clearUserPhotos(((TLRPC.TL_updateUserPhoto) update2).user_id);
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList14 = arrayList19;
arrayList14.add(update2);
} else if (update2 instanceof TLRPC.TL_updateUserPhone) {
i18 = i26 | 1024;
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList14 = arrayList19;
arrayList14.add(update2);
} else {
int i30 = i26;
if (update2 instanceof TLRPC.TL_updatePeerSettings) {
TLRPC.TL_updatePeerSettings tL_updatePeerSettings = (TLRPC.TL_updatePeerSettings) update2;
if (arrayList17 == null) {
arrayList17 = new ArrayList<>();
}
if ((tL_updatePeerSettings.peer instanceof TLRPC.TL_peerUser) && (user = concurrentHashMap.get(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) != null) {
if (user.contact) {
int indexOf = arrayList17.indexOf(Integer.valueOf(-tL_updatePeerSettings.peer.user_id));
if (indexOf != -1) {
arrayList17.remove(indexOf);
}
if (!arrayList17.contains(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) {
arrayList17.add(Integer.valueOf(tL_updatePeerSettings.peer.user_id));
}
} else {
int indexOf2 = arrayList17.indexOf(Integer.valueOf(tL_updatePeerSettings.peer.user_id));
if (indexOf2 != -1) {
arrayList17.remove(indexOf2);
}
if (!arrayList17.contains(Integer.valueOf(tL_updatePeerSettings.peer.user_id))) {
arrayList17.add(Integer.valueOf(-tL_updatePeerSettings.peer.user_id));
}
}
}
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
ArrayList arrayList37 = arrayList19;
arrayList37.add(update2);
i18 = i30;
arrayList19 = arrayList37;
longSparseArray6 = longSparseArray12;
longSparseArray5 = longSparseArray11;
sparseArray8 = sparseArray12;
} else {
if (update2 instanceof TLRPC.TL_updateNewEncryptedMessage) {
ArrayList<TLRPC.Message> decryptMessage = getSecretChatHelper().decryptMessage(((TLRPC.TL_updateNewEncryptedMessage) update2).message);
if (decryptMessage == null || decryptMessage.isEmpty()) {
i7 = i30;
sparseArray = sparseArray7;
arrayList6 = arrayList17;
arrayList7 = arrayList18;
longSparseArray3 = longSparseArray11;
sparseArray2 = sparseArray12;
longSparseArray6 = longSparseArray12;
} else {
long j11 = r0.message.chat_id << 32;
LongSparseArray longSparseArray13 = longSparseArray12 == null ? new LongSparseArray() : longSparseArray12;
ArrayList arrayList38 = (ArrayList) longSparseArray13.get(j11);
if (arrayList38 == null) {
arrayList38 = new ArrayList();
longSparseArray13.put(j11, arrayList38);
}
ArrayList arrayList39 = arrayList38;
int size8 = decryptMessage.size();
LongSparseArray longSparseArray14 = longSparseArray13;
int i31 = 0;
while (i31 < size8) {
int i32 = i30;
TLRPC.Message message3 = decryptMessage.get(i31);
ImageLoader.saveMessageThumbs(message3);
if (arrayList23 == null) {
sparseArray5 = sparseArray7;
arrayList13 = new ArrayList<>();
} else {
sparseArray5 = sparseArray7;
arrayList13 = arrayList23;
}
arrayList13.add(message3);
ArrayList<TLRPC.Message> arrayList40 = arrayList13;
ArrayList arrayList41 = arrayList39;
int i33 = size8;
ArrayList<Integer> arrayList42 = arrayList17;
ArrayList<Long> arrayList43 = arrayList18;
SparseArray<SparseIntArray> sparseArray13 = sparseArray12;
LongSparseArray longSparseArray15 = longSparseArray11;
long j12 = j11;
ArrayList<TLRPC.Message> arrayList44 = decryptMessage;
MessageObject messageObject3 = new MessageObject(this.currentAccount, message3, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(j11)));
arrayList41.add(messageObject3);
ArrayList arrayList45 = arrayList21 == null ? new ArrayList() : arrayList21;
arrayList45.add(messageObject3);
i31++;
arrayList21 = arrayList45;
arrayList39 = arrayList41;
arrayList23 = arrayList40;
decryptMessage = arrayList44;
size8 = i33;
j11 = j12;
sparseArray7 = sparseArray5;
arrayList18 = arrayList43;
arrayList17 = arrayList42;
sparseArray12 = sparseArray13;
longSparseArray11 = longSparseArray15;
i30 = i32;
}
i7 = i30;
sparseArray = sparseArray7;
arrayList6 = arrayList17;
arrayList7 = arrayList18;
longSparseArray3 = longSparseArray11;
sparseArray2 = sparseArray12;
longSparseArray6 = longSparseArray14;
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray3;
} else {
i7 = i30;
sparseArray = sparseArray7;
arrayList6 = arrayList17;
arrayList7 = arrayList18;
sparseArray2 = sparseArray12;
if (update2 instanceof TLRPC.TL_updateEncryptedChatTyping) {
TLRPC.EncryptedChat encryptedChatDB = getEncryptedChatDB(((TLRPC.TL_updateEncryptedChatTyping) update2).chat_id, true);
if (encryptedChatDB != null) {
long j13 = r0.chat_id << 32;
ArrayList<PrintingUser> arrayList46 = this.printingUsers.get(Long.valueOf(j13));
if (arrayList46 == null) {
arrayList46 = new ArrayList<>();
this.printingUsers.put(Long.valueOf(j13), arrayList46);
}
int size9 = arrayList46.size();
int i34 = 0;
while (true) {
if (i34 >= size9) {
j4 = j5;
z8 = false;
break;
}
PrintingUser printingUser2 = arrayList46.get(i34);
if (printingUser2.userId == encryptedChatDB.user_id) {
j4 = j5;
printingUser2.lastTime = j4;
printingUser2.action = new TLRPC.TL_sendMessageTypingAction();
z8 = true;
break;
}
i34++;
}
if (!z8) {
PrintingUser printingUser3 = new PrintingUser();
printingUser3.userId = encryptedChatDB.user_id;
printingUser3.lastTime = j4;
printingUser3.action = new TLRPC.TL_sendMessageTypingAction();
arrayList46.add(printingUser3);
z10 = true;
}
if (Math.abs(getConnectionsManager().getCurrentTime() - i) < 30) {
this.onlinePrivacy.put(Integer.valueOf(encryptedChatDB.user_id), Integer.valueOf(i));
}
} else {
j4 = j5;
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
j5 = j4;
} else {
long j14 = j5;
if (update2 instanceof TLRPC.TL_updateEncryptedMessagesRead) {
TLRPC.TL_updateEncryptedMessagesRead tL_updateEncryptedMessagesRead = (TLRPC.TL_updateEncryptedMessagesRead) update2;
SparseIntArray sparseIntArray7 = sparseIntArray3 == null ? new SparseIntArray() : sparseIntArray3;
sparseIntArray7.put(tL_updateEncryptedMessagesRead.chat_id, tL_updateEncryptedMessagesRead.max_date);
arrayList8 = arrayList24;
if (arrayList8 == null) {
arrayList8 = new ArrayList();
}
arrayList8.add(tL_updateEncryptedMessagesRead);
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
sparseIntArray3 = sparseIntArray7;
} else {
arrayList8 = arrayList24;
if (update2 instanceof TLRPC.TL_updateChatParticipantAdd) {
TLRPC.TL_updateChatParticipantAdd tL_updateChatParticipantAdd = (TLRPC.TL_updateChatParticipantAdd) update2;
getMessagesStorage().updateChatInfo(tL_updateChatParticipantAdd.chat_id, tL_updateChatParticipantAdd.user_id, 0, tL_updateChatParticipantAdd.inviter_id, tL_updateChatParticipantAdd.version);
} else if (update2 instanceof TLRPC.TL_updateChatParticipantDelete) {
TLRPC.TL_updateChatParticipantDelete tL_updateChatParticipantDelete = (TLRPC.TL_updateChatParticipantDelete) update2;
getMessagesStorage().updateChatInfo(tL_updateChatParticipantDelete.chat_id, tL_updateChatParticipantDelete.user_id, 1, 0, tL_updateChatParticipantDelete.version);
} else {
if ((update2 instanceof TLRPC.TL_updateDcOptions) || (update2 instanceof TLRPC.TL_updateConfig)) {
j = j14;
arrayList24 = arrayList8;
arrayList5 = arrayList21;
longSparseArray2 = longSparseArray12;
sparseLongArray2 = sparseLongArray4;
SparseIntArray sparseIntArray8 = sparseIntArray4;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
sparseIntArray = sparseIntArray8;
getConnectionsManager().updateDcSettings();
} else if (update2 instanceof TLRPC.TL_updateEncryption) {
getSecretChatHelper().processUpdateEncryption((TLRPC.TL_updateEncryption) update2, concurrentHashMap);
} else if (update2 instanceof TLRPC.TL_updateUserBlocked) {
final TLRPC.TL_updateUserBlocked tL_updateUserBlocked = (TLRPC.TL_updateUserBlocked) update2;
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$268$MessagesController(tL_updateUserBlocked);
}
});
} else if (update2 instanceof TLRPC.TL_updateNotifySettings) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
ArrayList arrayList47 = arrayList19;
arrayList47.add(update2);
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
arrayList19 = arrayList47;
} else {
if (update2 instanceof TLRPC.TL_updateServiceNotification) {
final TLRPC.TL_updateServiceNotification tL_updateServiceNotification = (TLRPC.TL_updateServiceNotification) update2;
if (tL_updateServiceNotification.popup && tL_updateServiceNotification.message != null && tL_updateServiceNotification.message.length() > 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$269$MessagesController(tL_updateServiceNotification);
}
});
}
if ((tL_updateServiceNotification.flags & 2) == 0 || tL_updateServiceNotification.message.equals("ErrorSendMessageTooFreq")) {
j = j14;
arrayList24 = arrayList8;
arrayList21 = arrayList21;
longSparseArray6 = longSparseArray12;
} else {
TLRPC.TL_message tL_message = new TLRPC.TL_message();
int newMessageId = getUserConfig().getNewMessageId();
tL_message.id = newMessageId;
tL_message.local_id = newMessageId;
getUserConfig().saveConfig(false);
tL_message.unread = true;
tL_message.flags = 256;
if (tL_updateServiceNotification.inbox_date != 0) {
tL_message.date = tL_updateServiceNotification.inbox_date;
} else {
tL_message.date = (int) (System.currentTimeMillis() / 1000);
}
tL_message.from_id = 777000;
tL_message.to_id = new TLRPC.TL_peerUser();
tL_message.to_id.user_id = getUserConfig().getClientUserId();
tL_message.dialog_id = 777000L;
if (tL_updateServiceNotification.media != null) {
tL_message.media = tL_updateServiceNotification.media;
tL_message.flags |= 512;
}
tL_message.message = tL_updateServiceNotification.message;
if (tL_updateServiceNotification.entities != null) {
tL_message.entities = tL_updateServiceNotification.entities;
tL_message.flags |= 128;
}
if (arrayList23 == null) {
arrayList23 = new ArrayList<>();
}
?? r0 = arrayList23;
r0.add(tL_message);
arrayList24 = arrayList8;
j = j14;
MessageObject messageObject4 = new MessageObject(this.currentAccount, tL_message, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(tL_message.dialog_id)));
longSparseArray6 = longSparseArray12 == null ? new LongSparseArray() : longSparseArray12;
ArrayList arrayList48 = (ArrayList) longSparseArray6.get(tL_message.dialog_id);
if (arrayList48 == null) {
arrayList48 = new ArrayList();
longSparseArray6.put(tL_message.dialog_id, arrayList48);
}
arrayList48.add(messageObject4);
ArrayList arrayList49 = arrayList21;
if (arrayList49 == null) {
arrayList49 = new ArrayList();
}
arrayList49.add(messageObject4);
arrayList21 = arrayList49;
arrayList23 = r0;
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
} else {
j = j14;
arrayList24 = arrayList8;
arrayList5 = arrayList21;
longSparseArray2 = longSparseArray12;
if (update2 instanceof TLRPC.TL_updateDialogPinned) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList12 = arrayList19;
arrayList12.add(update2);
} else if (update2 instanceof TLRPC.TL_updatePinnedDialogs) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList12 = arrayList19;
arrayList12.add(update2);
} else if (update2 instanceof TLRPC.TL_updateFolderPeers) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList12 = arrayList19;
arrayList12.add(update2);
getMessagesStorage().setDialogsFolderId(((TLRPC.TL_updateFolderPeers) update2).folder_peers, null, 0L, 0);
} else if (update2 instanceof TLRPC.TL_updatePrivacy) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList12 = arrayList19;
arrayList12.add(update2);
} else {
if (update2 instanceof TLRPC.TL_updateWebPage) {
TLRPC.TL_updateWebPage tL_updateWebPage = (TLRPC.TL_updateWebPage) update2;
longSparseArray = longSparseArray4 == null ? new LongSparseArray<>() : longSparseArray4;
longSparseArray.put(tL_updateWebPage.webpage.id, tL_updateWebPage.webpage);
} else if (update2 instanceof TLRPC.TL_updateChannelWebPage) {
TLRPC.TL_updateChannelWebPage tL_updateChannelWebPage = (TLRPC.TL_updateChannelWebPage) update2;
longSparseArray = longSparseArray4 == null ? new LongSparseArray<>() : longSparseArray4;
longSparseArray.put(tL_updateChannelWebPage.webpage.id, tL_updateChannelWebPage.webpage);
} else if (update2 instanceof TLRPC.TL_updateChannelTooLong) {
TLRPC.TL_updateChannelTooLong tL_updateChannelTooLong = (TLRPC.TL_updateChannelTooLong) update2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d(update2 + " channelId = " + tL_updateChannelTooLong.channel_id);
}
int i35 = this.channelsPts.get(tL_updateChannelTooLong.channel_id);
if (i35 == 0) {
i35 = getMessagesStorage().getChannelPtsSync(tL_updateChannelTooLong.channel_id);
if (i35 == 0) {
TLRPC.Chat chat3 = concurrentHashMap2.get(Integer.valueOf(tL_updateChannelTooLong.channel_id));
if (chat3 == null || chat3.min) {
chat3 = getChat(Integer.valueOf(tL_updateChannelTooLong.channel_id));
}
if (chat3 == null || chat3.min) {
chat3 = getMessagesStorage().getChatSync(tL_updateChannelTooLong.channel_id);
putChat(chat3, true);
}
if (chat3 != null && !chat3.min) {
loadUnknownChannel(chat3, 0L);
}
} else {
this.channelsPts.put(tL_updateChannelTooLong.channel_id, i35);
}
}
if (i35 != 0) {
if ((tL_updateChannelTooLong.flags & 1) != 0) {
if (tL_updateChannelTooLong.pts > i35) {
getChannelDifference(tL_updateChannelTooLong.channel_id);
}
} else {
getChannelDifference(tL_updateChannelTooLong.channel_id);
}
}
sparseLongArray2 = sparseLongArray4;
SparseIntArray sparseIntArray9 = sparseIntArray4;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
sparseIntArray = sparseIntArray9;
} else {
if (update2 instanceof TLRPC.TL_updateReadChannelInbox) {
TLRPC.TL_updateReadChannelInbox tL_updateReadChannelInbox = (TLRPC.TL_updateReadChannelInbox) update2;
long j15 = tL_updateReadChannelInbox.max_id | (tL_updateReadChannelInbox.channel_id << 32);
long j16 = -tL_updateReadChannelInbox.channel_id;
if (sparseLongArray5 == null) {
sparseLongArray5 = new SparseLongArray();
}
sparseLongArray5.put(-tL_updateReadChannelInbox.channel_id, j15);
Integer num5 = this.dialogs_read_inbox_max.get(Long.valueOf(j16));
if (num5 == null) {
num5 = Integer.valueOf(getMessagesStorage().getDialogReadMax(false, j16));
}
this.dialogs_read_inbox_max.put(Long.valueOf(j16), Integer.valueOf(Math.max(num5.intValue(), tL_updateReadChannelInbox.max_id)));
} else if (update2 instanceof TLRPC.TL_updateReadChannelOutbox) {
TLRPC.TL_updateReadChannelOutbox tL_updateReadChannelOutbox = (TLRPC.TL_updateReadChannelOutbox) update2;
long j17 = tL_updateReadChannelOutbox.max_id | (tL_updateReadChannelOutbox.channel_id << 32);
long j18 = -tL_updateReadChannelOutbox.channel_id;
if (sparseLongArray4 == null) {
sparseLongArray4 = new SparseLongArray();
}
sparseLongArray4.put(-tL_updateReadChannelOutbox.channel_id, j17);
Integer num6 = this.dialogs_read_outbox_max.get(Long.valueOf(j18));
if (num6 == null) {
num6 = Integer.valueOf(getMessagesStorage().getDialogReadMax(true, j18));
}
this.dialogs_read_outbox_max.put(Long.valueOf(j18), Integer.valueOf(Math.max(num6.intValue(), tL_updateReadChannelOutbox.max_id)));
} else if (update2 instanceof TLRPC.TL_updateDeleteChannelMessages) {
TLRPC.TL_updateDeleteChannelMessages tL_updateDeleteChannelMessages = (TLRPC.TL_updateDeleteChannelMessages) update2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d(update2 + " channelId = " + tL_updateDeleteChannelMessages.channel_id);
}
if (sparseArray6 == null) {
sparseArray6 = new SparseArray();
}
ArrayList arrayList50 = (ArrayList) sparseArray6.get(tL_updateDeleteChannelMessages.channel_id);
if (arrayList50 == null) {
arrayList50 = new ArrayList();
sparseArray6.put(tL_updateDeleteChannelMessages.channel_id, arrayList50);
}
arrayList50.addAll(tL_updateDeleteChannelMessages.messages);
} else if (update2 instanceof TLRPC.TL_updateChannel) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d(update2 + " channelId = " + ((TLRPC.TL_updateChannel) update2).channel_id);
}
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList12 = arrayList19;
arrayList12.add(update2);
} else {
if (update2 instanceof TLRPC.TL_updateChannelMessageViews) {
TLRPC.TL_updateChannelMessageViews tL_updateChannelMessageViews = (TLRPC.TL_updateChannelMessageViews) update2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d(update2 + " channelId = " + tL_updateChannelMessageViews.channel_id);
}
sparseArray8 = sparseArray2 == null ? new SparseArray<>() : sparseArray2;
SparseIntArray sparseIntArray10 = sparseArray8.get(tL_updateChannelMessageViews.channel_id);
if (sparseIntArray10 == null) {
sparseIntArray10 = new SparseIntArray();
sparseArray8.put(tL_updateChannelMessageViews.channel_id, sparseIntArray10);
}
sparseIntArray10.put(tL_updateChannelMessageViews.id, tL_updateChannelMessageViews.views);
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
} else {
if (update2 instanceof TLRPC.TL_updateChatParticipantAdmin) {
TLRPC.TL_updateChatParticipantAdmin tL_updateChatParticipantAdmin = (TLRPC.TL_updateChatParticipantAdmin) update2;
getMessagesStorage().updateChatInfo(tL_updateChatParticipantAdmin.chat_id, tL_updateChatParticipantAdmin.user_id, 2, tL_updateChatParticipantAdmin.is_admin ? 1 : 0, tL_updateChatParticipantAdmin.version);
} else {
if (update2 instanceof TLRPC.TL_updateChatDefaultBannedRights) {
TLRPC.TL_updateChatDefaultBannedRights tL_updateChatDefaultBannedRights = (TLRPC.TL_updateChatDefaultBannedRights) update2;
if (tL_updateChatDefaultBannedRights.peer.channel_id != 0) {
i10 = tL_updateChatDefaultBannedRights.peer.channel_id;
} else {
i10 = tL_updateChatDefaultBannedRights.peer.chat_id;
}
getMessagesStorage().updateChatDefaultBannedRights(i10, tL_updateChatDefaultBannedRights.default_banned_rights, tL_updateChatDefaultBannedRights.version);
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateStickerSets) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateStickerSetsOrder) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateNewStickerSet) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateDraftMessage) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateSavedGifs) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else {
boolean z13 = update2 instanceof TLRPC.TL_updateEditChannelMessage;
if (z13 || (update2 instanceof TLRPC.TL_updateEditMessage)) {
sparseLongArray2 = sparseLongArray4;
SparseIntArray sparseIntArray11 = sparseIntArray4;
HashMap hashMap4 = hashMap3;
int clientUserId3 = getUserConfig().getClientUserId();
if (z13) {
message2 = ((TLRPC.TL_updateEditChannelMessage) update2).message;
if (message2.media instanceof TLRPC.TL_messageMediaShare) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$270$MessagesController(message2);
}
});
}
TLRPC.Chat chat4 = concurrentHashMap2.get(Integer.valueOf(message2.to_id.channel_id));
if (chat4 == null) {
chat4 = getChat(Integer.valueOf(message2.to_id.channel_id));
}
if (chat4 == null) {
chat4 = getMessagesStorage().getChatSync(message2.to_id.channel_id);
putChat(chat4, true);
}
if (chat4 != null && chat4.megagroup) {
message2.flags |= Integer.MIN_VALUE;
}
sparseArray4 = sparseArray2;
sparseIntArray2 = sparseIntArray11;
} else {
message2 = ((TLRPC.TL_updateEditMessage) update2).message;
sparseArray4 = sparseArray2;
sparseIntArray2 = sparseIntArray11;
if (message2.dialog_id == clientUserId3) {
message2.unread = false;
message2.media_unread = false;
z7 = true;
message2.out = true;
if (!message2.out && message2.from_id == getUserConfig().getClientUserId()) {
message2.out = z7;
}
if (!z) {
int size10 = message2.entities.size();
for (int i36 = 0; i36 < size10; i36++) {
TLRPC.MessageEntity messageEntity2 = message2.entities.get(i36);
if (messageEntity2 instanceof TLRPC.TL_messageEntityMentionName) {
int i37 = ((TLRPC.TL_messageEntityMentionName) messageEntity2).user_id;
TLRPC.User user5 = concurrentHashMap.get(Integer.valueOf(i37));
if (user5 == null || user5.min) {
user5 = getUser(Integer.valueOf(i37));
}
if (user5 == null || user5.min) {
TLRPC.User userSync = getMessagesStorage().getUserSync(i37);
user5 = (userSync == null || !userSync.min) ? userSync : null;
putUser(user5, true);
}
if (user5 == null) {
return false;
}
}
}
}
if (message2.to_id.chat_id == 0) {
message2.dialog_id = -message2.to_id.chat_id;
} else if (message2.to_id.channel_id != 0) {
message2.dialog_id = -message2.to_id.channel_id;
} else {
if (message2.to_id.user_id == getUserConfig().getClientUserId()) {
message2.to_id.user_id = message2.from_id;
}
message2.dialog_id = message2.to_id.user_id;
}
ConcurrentHashMap<Long, Integer> concurrentHashMap5 = !message2.out ? this.dialogs_read_outbox_max : this.dialogs_read_inbox_max;
num = concurrentHashMap5.get(Long.valueOf(message2.dialog_id));
if (num == null) {
num = Integer.valueOf(getMessagesStorage().getDialogReadMax(message2.out, message2.dialog_id));
concurrentHashMap5.put(Long.valueOf(message2.dialog_id), num);
}
message2.unread = num.intValue() >= message2.id;
if (message2.dialog_id == clientUserId3) {
message2.out = true;
message2.unread = false;
message2.media_unread = false;
}
if (message2.out && message2.message == null) {
message2.message = "";
message2.attachPath = "";
}
ImageLoader.saveMessageThumbs(message2);
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray4;
sparseIntArray = sparseIntArray2;
hashMap3 = hashMap4;
MessageObject messageObject5 = new MessageObject(this.currentAccount, message2, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message2.dialog_id)));
longSparseArray5 = longSparseArray11 != null ? new LongSparseArray() : longSparseArray11;
arrayList9 = (ArrayList) longSparseArray5.get(message2.dialog_id);
if (arrayList9 == null) {
arrayList9 = new ArrayList();
longSparseArray5.put(message2.dialog_id, arrayList9);
}
arrayList9.add(messageObject5);
longSparseArray = longSparseArray4;
longSparseArray6 = longSparseArray2;
sparseArray8 = sparseArray3;
sparseLongArray4 = sparseLongArray2;
sparseLongArray5 = sparseLongArray3;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseIntArray4 = sparseIntArray;
i18 = i7;
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
}
}
z7 = true;
if (!message2.out) {
message2.out = z7;
}
if (!z) {
}
if (message2.to_id.chat_id == 0) {
}
if (!message2.out) {
}
num = concurrentHashMap5.get(Long.valueOf(message2.dialog_id));
if (num == null) {
}
message2.unread = num.intValue() >= message2.id;
if (message2.dialog_id == clientUserId3) {
}
if (message2.out) {
message2.message = "";
message2.attachPath = "";
}
ImageLoader.saveMessageThumbs(message2);
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray4;
sparseIntArray = sparseIntArray2;
hashMap3 = hashMap4;
MessageObject messageObject52 = new MessageObject(this.currentAccount, message2, concurrentHashMap, concurrentHashMap2, this.createdDialogIds.contains(Long.valueOf(message2.dialog_id)));
if (longSparseArray11 != null) {
}
arrayList9 = (ArrayList) longSparseArray5.get(message2.dialog_id);
if (arrayList9 == null) {
}
arrayList9.add(messageObject52);
longSparseArray = longSparseArray4;
longSparseArray6 = longSparseArray2;
sparseArray8 = sparseArray3;
sparseLongArray4 = sparseLongArray2;
sparseLongArray5 = sparseLongArray3;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseIntArray4 = sparseIntArray;
i18 = i7;
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
} else if (update2 instanceof TLRPC.TL_updateChannelPinnedMessage) {
TLRPC.TL_updateChannelPinnedMessage tL_updateChannelPinnedMessage = (TLRPC.TL_updateChannelPinnedMessage) update2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d(update2 + " channelId = " + tL_updateChannelPinnedMessage.channel_id);
}
getMessagesStorage().updateChatPinnedMessage(tL_updateChannelPinnedMessage.channel_id, tL_updateChannelPinnedMessage.id);
} else if (update2 instanceof TLRPC.TL_updateChatPinnedMessage) {
TLRPC.TL_updateChatPinnedMessage tL_updateChatPinnedMessage = (TLRPC.TL_updateChatPinnedMessage) update2;
getMessagesStorage().updateChatPinnedMessage(tL_updateChatPinnedMessage.chat_id, tL_updateChatPinnedMessage.id);
} else if (update2 instanceof TLRPC.TL_updateUserPinnedMessage) {
TLRPC.TL_updateUserPinnedMessage tL_updateUserPinnedMessage = (TLRPC.TL_updateUserPinnedMessage) update2;
getMessagesStorage().updateUserPinnedMessage(tL_updateUserPinnedMessage.user_id, tL_updateUserPinnedMessage.id);
} else if (update2 instanceof TLRPC.TL_updateReadFeaturedStickers) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updatePhoneCall) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateLangPack) {
final TLRPC.TL_updateLangPack tL_updateLangPack = (TLRPC.TL_updateLangPack) update2;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$271$MessagesController(tL_updateLangPack);
}
});
} else if (update2 instanceof TLRPC.TL_updateLangPackTooLong) {
LocaleController.getInstance().reloadCurrentRemoteLocale(this.currentAccount, ((TLRPC.TL_updateLangPackTooLong) update2).lang_code);
} else if (update2 instanceof TLRPC.TL_updateFavedStickers) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateContactsReset) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList11 = arrayList19;
arrayList11.add(update2);
} else if (update2 instanceof TLRPC.TL_updateChannelAvailableMessages) {
TLRPC.TL_updateChannelAvailableMessages tL_updateChannelAvailableMessages = (TLRPC.TL_updateChannelAvailableMessages) update2;
SparseIntArray sparseIntArray12 = sparseIntArray4;
if (sparseIntArray12 == null) {
sparseIntArray12 = new SparseIntArray();
}
int i38 = sparseIntArray12.get(tL_updateChannelAvailableMessages.channel_id);
if (i38 == 0 || i38 < tL_updateChannelAvailableMessages.available_min_id) {
sparseIntArray12.put(tL_updateChannelAvailableMessages.channel_id, tL_updateChannelAvailableMessages.available_min_id);
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
sparseArray8 = sparseArray2;
sparseIntArray4 = sparseIntArray12;
} else {
SparseIntArray sparseIntArray13 = sparseIntArray4;
if (update2 instanceof TLRPC.TL_updateDialogUnreadMark) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
ArrayList arrayList51 = arrayList19;
arrayList51.add(update2);
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
arrayList19 = arrayList51;
sparseArray8 = sparseArray2;
sparseIntArray4 = sparseIntArray13;
longSparseArray6 = longSparseArray2;
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
i18 = i7;
j5 = j;
} else {
if (update2 instanceof TLRPC.TL_updateMessagePoll) {
TLRPC.TL_updateMessagePoll tL_updateMessagePoll = (TLRPC.TL_updateMessagePoll) update2;
if (Math.abs(SystemClock.uptimeMillis() - getSendMessagesHelper().getVoteSendTime(tL_updateMessagePoll.poll_id)) < 600) {
sparseLongArray2 = sparseLongArray4;
sparseIntArray = sparseIntArray13;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
} else {
sparseLongArray2 = sparseLongArray4;
getMessagesStorage().updateMessagePollResults(tL_updateMessagePoll.poll_id, tL_updateMessagePoll.poll, tL_updateMessagePoll.results);
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList10 = arrayList19;
arrayList10.add(update2);
longSparseArray = longSparseArray4;
arrayList19 = arrayList10;
longSparseArray5 = longSparseArray11;
sparseArray8 = sparseArray2;
sparseIntArray4 = sparseIntArray13;
longSparseArray6 = longSparseArray2;
sparseLongArray4 = sparseLongArray2;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
i18 = i7;
}
} else {
sparseLongArray2 = sparseLongArray4;
if (update2 instanceof TLRPC.TL_updateMessageReactions) {
TLRPC.TL_updateMessageReactions tL_updateMessageReactions = (TLRPC.TL_updateMessageReactions) update2;
if (tL_updateMessageReactions.peer.chat_id != 0) {
i9 = tL_updateMessageReactions.peer.chat_id;
} else if (tL_updateMessageReactions.peer.channel_id != 0) {
i9 = tL_updateMessageReactions.peer.channel_id;
} else {
i8 = tL_updateMessageReactions.peer.user_id;
getMessagesStorage().updateMessageReactions(i8, tL_updateMessageReactions.msg_id, tL_updateMessageReactions.peer.channel_id, tL_updateMessageReactions.reactions);
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList10 = arrayList19;
arrayList10.add(update2);
}
i8 = -i9;
getMessagesStorage().updateMessageReactions(i8, tL_updateMessageReactions.msg_id, tL_updateMessageReactions.peer.channel_id, tL_updateMessageReactions.reactions);
if (arrayList19 == null) {
}
arrayList10 = arrayList19;
arrayList10.add(update2);
} else if (update2 instanceof TLRPC.TL_updatePeerLocated) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList10 = arrayList19;
arrayList10.add(update2);
} else if (update2 instanceof TLRPC.TL_updateTheme) {
if (arrayList19 == null) {
arrayList19 = new ArrayList();
}
arrayList10 = arrayList19;
arrayList10.add(update2);
} else {
if (!(update2 instanceof TLRPCContacts.UpdateContactApplyRequested)) {
if (update2 instanceof TLRPC.TL_updateUserMomentStateV1) {
final TLRPC.TL_updateUserMomentStateV1 tL_updateUserMomentStateV1 = (TLRPC.TL_updateUserMomentStateV1) update2;
if (tL_updateUserMomentStateV1 != null && tL_updateUserMomentStateV1.user_id != 0 && tL_updateUserMomentStateV1.type != 0) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$272$MessagesController(tL_updateUserMomentStateV1);
}
});
}
} else {
if (update2 instanceof TLRPCCall.TL_UpdateMeetCallRequested) {
TLRPCCall.TL_UpdateMeetCallRequested tL_UpdateMeetCallRequested = (TLRPCCall.TL_UpdateMeetCallRequested) update2;
if (tL_UpdateMeetCallRequested == null || tL_UpdateMeetCallRequested.admin_id == getUserConfig().getClientUserId() || (System.currentTimeMillis() / 1000) - tL_UpdateMeetCallRequested.date >= 35) {
hashMap = hashMap3;
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("MessagesController call ===> receive video call , id = " + tL_UpdateMeetCallRequested.id);
}
if (tL_UpdateMeetCallRequested.participant_id != null) {
Iterator<TLRPC.InputPeer> it2 = tL_UpdateMeetCallRequested.participant_id.iterator();
while (it2.hasNext() && it2.next().user_id != AccountInstance.getInstance(UserConfig.selectedAccount).getUserConfig().getCurrentUser().id) {
}
}
hashMap = hashMap3;
hashMap.get(tL_UpdateMeetCallRequested.id);
}
} else {
hashMap = hashMap3;
if (update2 instanceof TLRPCCall.TL_UpdateMeetCallAccepted) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("MessagesController call ===> 对方已接受请求");
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallAccept, TLRPC.Update.this);
}
});
} else if (update2 instanceof TLRPCCall.TL_UpdateMeetCallDiscarded) {
TLRPCCall.TL_UpdateMeetCallDiscarded tL_UpdateMeetCallDiscarded2 = (TLRPCCall.TL_UpdateMeetCallDiscarded) update2;
if (BuildVars.LOGS_ENABLED) {
FileLog.d("MessagesController call ===> 收到挂断反馈 , d.id = " + tL_UpdateMeetCallDiscarded2.id + " d.duration = " + tL_UpdateMeetCallDiscarded2.duration);
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.reecivedAVideoDiscarded, TLRPC.Update.this);
}
});
} else if (update2 instanceof TLRPCCall.TL_UpdateMeetCall) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("MessagesController call ===> 准备进入视频通道");
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallReady, TLRPC.Update.this);
}
});
} else if (update2 instanceof TLRPCContacts.UpdateResetContactsApplyUnread) {
handleUpdatesContactsApply(0);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$276$MessagesController();
}
});
} else if (update2 instanceof TLRPCContacts.UpdateRegetContactsApplies) {
getContactsApplyDifferenceV2(true, false);
} else if (update2 instanceof TLRPCCall.TL_UpdateMeetCallWaiting) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallBusy, TLRPC.Update.this);
}
}, AdaptiveTrackSelection.DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS);
} else if (update2 instanceof TLRPCCall.TL_UpdateMeetChangeCall) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("MessagesController call ===> 对方切换到语音");
}
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.receivedAVideoCallChangeVoice, TLRPC.Update.this);
}
});
} else if (!(update2 instanceof TLRPCContacts.CL_user_updateUserFull) && (update2 instanceof TLRPCContacts.TL_updateContactGroups)) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$279$MessagesController();
}
});
}
}
hashMap3 = hashMap;
}
}
sparseIntArray = sparseIntArray13;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
}
longSparseArray = longSparseArray4;
arrayList19 = arrayList10;
longSparseArray5 = longSparseArray11;
sparseArray8 = sparseArray2;
sparseIntArray4 = sparseIntArray13;
longSparseArray6 = longSparseArray2;
sparseLongArray4 = sparseLongArray2;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
i18 = i7;
}
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
}
}
}
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
arrayList19 = arrayList11;
sparseArray8 = sparseArray2;
longSparseArray6 = longSparseArray2;
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
i18 = i7;
j5 = j;
}
sparseLongArray2 = sparseLongArray4;
sparseIntArray = sparseIntArray4;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
}
longSparseArray6 = longSparseArray2;
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
i18 = i7;
j5 = j;
}
longSparseArray = longSparseArray4;
}
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
longSparseArray6 = longSparseArray2;
}
longSparseArray5 = longSparseArray11;
arrayList21 = arrayList5;
arrayList19 = arrayList12;
longSparseArray6 = longSparseArray2;
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseArray8 = sparseArray2;
i18 = i7;
j5 = j;
}
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseArray8 = sparseArray2;
i18 = i7;
j5 = j;
}
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
longSparseArray6 = longSparseArray2;
sparseArray8 = sparseArray3;
sparseLongArray4 = sparseLongArray2;
sparseLongArray5 = sparseLongArray3;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseIntArray4 = sparseIntArray;
i18 = i7;
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
}
j = j14;
arrayList24 = arrayList8;
arrayList5 = arrayList21;
longSparseArray2 = longSparseArray12;
sparseLongArray2 = sparseLongArray4;
SparseIntArray sparseIntArray92 = sparseIntArray4;
sparseLongArray3 = sparseLongArray5;
sparseArray3 = sparseArray2;
sparseIntArray = sparseIntArray92;
longSparseArray = longSparseArray4;
longSparseArray5 = longSparseArray11;
longSparseArray6 = longSparseArray2;
sparseArray8 = sparseArray3;
sparseLongArray4 = sparseLongArray2;
sparseLongArray5 = sparseLongArray3;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseIntArray4 = sparseIntArray;
i18 = i7;
j5 = j;
arrayList21 = arrayList5;
sparseArray7 = sparseArray;
}
j5 = j14;
arrayList24 = arrayList8;
}
longSparseArray6 = longSparseArray12;
}
sparseArray7 = sparseArray;
arrayList18 = arrayList7;
arrayList17 = arrayList6;
sparseArray8 = sparseArray2;
i18 = i7;
}
}
longSparseArray = longSparseArray4;
arrayList19 = arrayList14;
}
longSparseArray6 = longSparseArray12;
longSparseArray5 = longSparseArray11;
sparseArray8 = sparseArray12;
}
}
longSparseArray = longSparseArray4;
longSparseArray6 = longSparseArray12;
longSparseArray5 = longSparseArray11;
sparseArray8 = sparseArray12;
i18 = i26;
}
}
longSparseArray = longSparseArray4;
}
longSparseArray4 = longSparseArray;
size3 = i19;
i17 = i20 + 1;
arrayList16 = arrayList;
}
final SparseArray sparseArray14 = sparseArray6;
final SparseArray sparseArray15 = sparseArray7;
final ArrayList<Integer> arrayList52 = arrayList17;
final int i39 = i18;
final ArrayList<Long> arrayList53 = arrayList18;
final ArrayList arrayList54 = arrayList21;
final SparseIntArray sparseIntArray14 = sparseIntArray4;
final SparseLongArray sparseLongArray10 = sparseLongArray4;
final LongSparseArray longSparseArray16 = longSparseArray5;
final LongSparseArray longSparseArray17 = longSparseArray6;
final SparseLongArray sparseLongArray11 = sparseLongArray5;
final SparseArray<SparseIntArray> sparseArray16 = sparseArray8;
if (longSparseArray17 != null) {
int size11 = longSparseArray17.size();
for (int i40 = 0; i40 < size11; i40++) {
if (updatePrintingUsersWithNewMessages(longSparseArray17.keyAt(i40), (ArrayList) longSparseArray17.valueAt(i40))) {
z10 = true;
}
}
}
final boolean z14 = z10;
if (z14) {
updatePrintingStrings();
}
if (arrayList52 != null) {
getContactsController().processContactsUpdates(arrayList52, concurrentHashMap);
}
if (arrayList54 != null) {
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$281$MessagesController(arrayList54);
}
});
}
if (arrayList22 != null) {
getMessagesStorage().putMessages(arrayList22, true, true, false, getDownloadController().getAutodownloadMask(), true);
}
if (arrayList23 != null) {
getStatsController().incrementReceivedItemsCount(ApplicationLoader.getCurrentNetworkType(), 1, arrayList23.size());
getMessagesStorage().putMessages(arrayList23, true, true, false, getDownloadController().getAutodownloadMask(), false);
}
if (longSparseArray16 != null) {
int size12 = longSparseArray16.size();
for (int i41 = 0; i41 < size12; i41++) {
TLRPC.TL_messages_messages tL_messages_messages = new TLRPC.TL_messages_messages();
ArrayList arrayList55 = (ArrayList) longSparseArray16.valueAt(i41);
int size13 = arrayList55.size();
for (int i42 = 0; i42 < size13; i42++) {
tL_messages_messages.messages.add(((MessageObject) arrayList55.get(i42)).messageOwner);
}
getMessagesStorage().putMessages((TLRPC.messages_Messages) tL_messages_messages, longSparseArray16.keyAt(i41), -2, 0, false, false);
}
}
if (sparseArray16 != null) {
getMessagesStorage().putChannelViews(sparseArray16, true);
}
final ArrayList arrayList56 = arrayList19;
final LongSparseArray<TLRPC.WebPage> longSparseArray18 = longSparseArray4;
final SparseIntArray sparseIntArray15 = sparseIntArray3;
final LongSparseArray longSparseArray19 = longSparseArray7;
final ArrayList arrayList57 = arrayList20;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$286$MessagesController(i39, arrayList56, longSparseArray18, longSparseArray17, longSparseArray19, longSparseArray16, z14, arrayList52, arrayList57, sparseArray16);
}
});
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$288$MessagesController(sparseLongArray11, sparseLongArray10, sparseIntArray15, arrayList53, sparseArray14, sparseArray15, sparseIntArray14);
}
});
if (longSparseArray18 != null) {
getMessagesStorage().putWebPages(longSparseArray18);
}
if (sparseLongArray11 == null && sparseLongArray10 == null && sparseIntArray15 == null && arrayList53 == null) {
arrayList4 = arrayList53;
} else {
if (sparseLongArray11 == null && arrayList53 == null) {
sparseLongArray = sparseLongArray11;
arrayList4 = arrayList53;
z3 = true;
} else {
sparseLongArray = sparseLongArray11;
arrayList4 = arrayList53;
z3 = true;
getMessagesStorage().updateDialogsWithReadMessages(sparseLongArray, sparseLongArray10, arrayList4, true);
}
getMessagesStorage().markMessagesAsRead(sparseLongArray, sparseLongArray10, sparseIntArray15, z3);
}
if (arrayList4 != null) {
getMessagesStorage().markMessagesContentAsRead(arrayList4, getConnectionsManager().getCurrentTime());
}
if (sparseArray14 != null) {
int size14 = sparseArray14.size();
for (int i43 = 0; i43 < size14; i43++) {
final int keyAt = sparseArray14.keyAt(i43);
final ArrayList arrayList58 = (ArrayList) sparseArray14.valueAt(i43);
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$289$MessagesController(arrayList58, keyAt);
}
});
}
}
if (sparseArray15 != null) {
int size15 = sparseArray15.size();
for (int i44 = 0; i44 < size15; i44++) {
MessagesStorage.getInstance(this.currentAccount).markMessagesAsDeleted((ArrayList) sparseArray15.valueAt(i44), true, sparseArray15.keyAt(i44), false, true);
}
}
if (sparseIntArray14 != null) {
int size16 = sparseIntArray14.size();
for (int i45 = 0; i45 < size16; i45++) {
final int keyAt2 = sparseIntArray14.keyAt(i45);
final int valueAt = sparseIntArray14.valueAt(i45);
getMessagesStorage().getStorageQueue().postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$processUpdateArray$290$MessagesController(keyAt2, valueAt);
}
});
}
}
if (arrayList24 == null) {
return true;
}
int size17 = arrayList24.size();
for (int i46 = 0; i46 < size17; i46++) {
TLRPC.TL_updateEncryptedMessagesRead tL_updateEncryptedMessagesRead2 = (TLRPC.TL_updateEncryptedMessagesRead) arrayList24.get(i46);
getMessagesStorage().createTaskForSecretChat(tL_updateEncryptedMessagesRead2.chat_id, tL_updateEncryptedMessagesRead2.max_date, tL_updateEncryptedMessagesRead2.date, 1, null);
}
return true;
}
public void lambda$processUpdateArray$265$MessagesController(ArrayList arrayList, ArrayList arrayList2) {
putUsers(arrayList, false);
putChats(arrayList2, false);
}
public void lambda$processUpdateArray$266$MessagesController(ArrayList arrayList, ArrayList arrayList2) {
putUsers(arrayList, false);
putChats(arrayList2, false);
}
public void lambda$processUpdateArray$268$MessagesController(final TLRPC.TL_updateUserBlocked tL_updateUserBlocked) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$267$MessagesController(tL_updateUserBlocked);
}
});
}
public void lambda$null$267$MessagesController(TLRPC.TL_updateUserBlocked tL_updateUserBlocked) {
if (tL_updateUserBlocked.blocked) {
if (this.blockedUsers.indexOfKey(tL_updateUserBlocked.user_id) < 0) {
this.blockedUsers.put(tL_updateUserBlocked.user_id, 1);
}
} else {
this.blockedUsers.delete(tL_updateUserBlocked.user_id);
}
getNotificationCenter().postNotificationName(NotificationCenter.blockedUsersDidLoad, new Object[0]);
}
public void lambda$processUpdateArray$269$MessagesController(TLRPC.TL_updateServiceNotification tL_updateServiceNotification) {
getNotificationCenter().postNotificationName(NotificationCenter.needShowAlert, 2, tL_updateServiceNotification.message, tL_updateServiceNotification.type);
}
public void lambda$processUpdateArray$270$MessagesController(TLRPC.Message message) {
getNotificationCenter().postNotificationName(NotificationCenter.livestatechange, message.media);
}
public void lambda$processUpdateArray$271$MessagesController(TLRPC.TL_updateLangPack tL_updateLangPack) {
LocaleController.getInstance().saveRemoteLocaleStringsForCurrentLocale(tL_updateLangPack.difference, this.currentAccount);
}
public void lambda$processUpdateArray$272$MessagesController(TLRPC.TL_updateUserMomentStateV1 tL_updateUserMomentStateV1) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.userFriendsCircleUpdate, tL_updateUserMomentStateV1);
}
public void lambda$processUpdateArray$276$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, 0);
}
public void lambda$processUpdateArray$279$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.groupingChanged, new Object[0]);
}
public void lambda$null$280$MessagesController(ArrayList arrayList) {
getNotificationsController().processNewMessages(arrayList, true, false, null);
}
public void lambda$processUpdateArray$281$MessagesController(final ArrayList arrayList) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$280$MessagesController(arrayList);
}
});
}
public void lambda$processUpdateArray$286$MessagesController(int i, ArrayList arrayList, LongSparseArray longSparseArray, LongSparseArray longSparseArray2, LongSparseArray longSparseArray3, LongSparseArray longSparseArray4, boolean z, ArrayList arrayList2, ArrayList arrayList3, SparseArray sparseArray) {
int i2;
int i3;
boolean z2;
boolean z3;
int i4;
char c;
LongSparseArray<ArrayList<MessageObject>> longSparseArray5;
long j;
boolean z4;
ArrayList<TLRPC.User> arrayList4;
int i5;
int i6;
ArrayList<TLRPC.User> arrayList5;
ArrayList<TLRPC.User> arrayList6;
int i7;
int i8;
int i9;
int i10;
int i11;
long j2;
int i12;
int i13;
int i14;
int i15;
int i16;
int i17;
int i18;
TLRPC.Dialog dialog;
int i19;
int i20;
int i21;
int i22;
ArrayList<Long> arrayList7;
ArrayList<TLRPC.User> arrayList8;
long j3;
int i23;
int i24;
?? r3 = 0;
int i25 = 0;
if (arrayList != null) {
ArrayList<TLRPC.User> arrayList9 = new ArrayList<>();
ArrayList<TLRPC.User> arrayList10 = new ArrayList<>();
int size = arrayList.size();
int i26 = i;
int i27 = 0;
SharedPreferences.Editor editor = null;
z2 = false;
while (i27 < size) {
TLRPC.Update update = (TLRPC.Update) arrayList.get(i27);
if (update instanceof TLRPC.TL_updatePrivacy) {
TLRPC.TL_updatePrivacy tL_updatePrivacy = (TLRPC.TL_updatePrivacy) update;
if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyStatusTimestamp) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, i25);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyChatInvite) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 1);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyMoment) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 8);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneCall) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 2);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneP2P) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 3);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyProfilePhoto) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 4);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyForwards) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 5);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyPhoneNumber) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 6);
} else if (tL_updatePrivacy.key instanceof TLRPC.TL_privacyKeyAddedByPhone) {
getContactsController().setPrivacyRules(tL_updatePrivacy.rules, 7);
}
} else if (update instanceof TLRPC.TL_updateUserStatus) {
TLRPC.TL_updateUserStatus tL_updateUserStatus = (TLRPC.TL_updateUserStatus) update;
TLRPC.User user = getUser(Integer.valueOf(tL_updateUserStatus.user_id));
if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusRecently) {
tL_updateUserStatus.status.expires = -100;
} else if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusLastWeek) {
tL_updateUserStatus.status.expires = -101;
} else if (tL_updateUserStatus.status instanceof TLRPC.TL_userStatusLastMonth) {
tL_updateUserStatus.status.expires = -102;
}
if (user != null) {
user.id = tL_updateUserStatus.user_id;
user.status = tL_updateUserStatus.status;
}
TLRPC.TL_user tL_user = new TLRPC.TL_user();
tL_user.id = tL_updateUserStatus.user_id;
tL_user.status = tL_updateUserStatus.status;
arrayList10.add(tL_user);
if (tL_updateUserStatus.user_id == getUserConfig().getClientUserId()) {
getNotificationsController().setLastOnlineFromOtherDevice(tL_updateUserStatus.status.expires);
}
} else if (update instanceof TLRPC.TL_updateUserName) {
TLRPC.TL_updateUserName tL_updateUserName = (TLRPC.TL_updateUserName) update;
TLRPC.User user2 = getUser(Integer.valueOf(tL_updateUserName.user_id));
if (user2 != null) {
if (!UserObject.isContact(user2)) {
user2.first_name = tL_updateUserName.first_name;
user2.last_name = tL_updateUserName.last_name;
}
if (!TextUtils.isEmpty(user2.username)) {
this.objectsByUsernames.remove(user2.username);
}
if (TextUtils.isEmpty(tL_updateUserName.username)) {
this.objectsByUsernames.put(tL_updateUserName.username, user2);
}
user2.username = tL_updateUserName.username;
}
TLRPC.TL_user tL_user2 = new TLRPC.TL_user();
tL_user2.id = tL_updateUserName.user_id;
tL_user2.first_name = tL_updateUserName.first_name;
tL_user2.last_name = tL_updateUserName.last_name;
tL_user2.username = tL_updateUserName.username;
arrayList9.add(tL_user2);
} else {
if (update instanceof TLRPC.TL_updateDialogPinned) {
TLRPC.TL_updateDialogPinned tL_updateDialogPinned = (TLRPC.TL_updateDialogPinned) update;
long peerDialogId = tL_updateDialogPinned.peer instanceof TLRPC.TL_dialogPeer ? DialogObject.getPeerDialogId(((TLRPC.TL_dialogPeer) tL_updateDialogPinned.peer).peer) : 0L;
arrayList4 = arrayList9;
long j4 = peerDialogId;
i5 = i26;
i6 = size;
ArrayList<TLRPC.User> arrayList11 = arrayList10;
if (!pinDialog(peerDialogId, tL_updateDialogPinned.pinned, null, -1L)) {
getUserConfig().setPinnedDialogsLoaded(tL_updateDialogPinned.folder_id, false);
getUserConfig().saveConfig(false);
loadPinnedDialogs(tL_updateDialogPinned.folder_id, j4, null);
}
arrayList5 = arrayList11;
} else {
arrayList4 = arrayList9;
i5 = i26;
i6 = size;
ArrayList<TLRPC.User> arrayList12 = arrayList10;
if (update instanceof TLRPC.TL_updatePinnedDialogs) {
TLRPC.TL_updatePinnedDialogs tL_updatePinnedDialogs = (TLRPC.TL_updatePinnedDialogs) update;
getUserConfig().setPinnedDialogsLoaded(tL_updatePinnedDialogs.folder_id, false);
getUserConfig().saveConfig(false);
if ((tL_updatePinnedDialogs.flags & 1) != 0) {
arrayList7 = new ArrayList<>();
ArrayList<TLRPC.DialogPeer> arrayList13 = tL_updatePinnedDialogs.order;
int size2 = arrayList13.size();
int i28 = 0;
while (i28 < size2) {
TLRPC.DialogPeer dialogPeer = arrayList13.get(i28);
if (dialogPeer instanceof TLRPC.TL_dialogPeer) {
TLRPC.Peer peer = ((TLRPC.TL_dialogPeer) dialogPeer).peer;
if (peer.user_id != 0) {
i24 = peer.user_id;
arrayList8 = arrayList12;
} else {
arrayList8 = arrayList12;
if (peer.chat_id != 0) {
i23 = peer.chat_id;
} else {
i23 = peer.channel_id;
}
i24 = -i23;
}
j3 = i24;
} else {
arrayList8 = arrayList12;
j3 = 0;
}
arrayList7.add(Long.valueOf(j3));
i28++;
arrayList12 = arrayList8;
}
arrayList5 = arrayList12;
} else {
arrayList5 = arrayList12;
arrayList7 = null;
}
loadPinnedDialogs(tL_updatePinnedDialogs.folder_id, 0L, arrayList7);
} else {
arrayList5 = arrayList12;
if (update instanceof TLRPC.TL_updateFolderPeers) {
TLRPC.TL_updateFolderPeers tL_updateFolderPeers = (TLRPC.TL_updateFolderPeers) update;
int size3 = tL_updateFolderPeers.folder_peers.size();
for (int i29 = 0; i29 < size3; i29++) {
TLRPC.TL_folderPeer tL_folderPeer = tL_updateFolderPeers.folder_peers.get(i29);
TLRPC.Dialog dialog2 = this.dialogs_dict.get(DialogObject.getPeerDialogId(tL_folderPeer.peer));
if (dialog2 != null && dialog2.folder_id != tL_folderPeer.folder_id) {
dialog2.pinned = false;
dialog2.pinnedNum = 0;
dialog2.folder_id = tL_folderPeer.folder_id;
ensureFolderDialogExists(tL_folderPeer.folder_id, null);
}
}
arrayList6 = arrayList4;
i7 = i5;
} else {
if (update instanceof TLRPC.TL_updateUserPhoto) {
TLRPC.TL_updateUserPhoto tL_updateUserPhoto = (TLRPC.TL_updateUserPhoto) update;
TLRPC.User user3 = getUser(Integer.valueOf(tL_updateUserPhoto.user_id));
if (user3 != null) {
user3.photo = tL_updateUserPhoto.photo;
}
TLRPC.TL_user tL_user3 = new TLRPC.TL_user();
tL_user3.id = tL_updateUserPhoto.user_id;
tL_user3.photo = tL_updateUserPhoto.photo;
arrayList6 = arrayList4;
arrayList6.add(tL_user3);
} else {
arrayList6 = arrayList4;
if (update instanceof TLRPC.TL_updateUserPhone) {
TLRPC.TL_updateUserPhone tL_updateUserPhone = (TLRPC.TL_updateUserPhone) update;
final TLRPC.User user4 = getUser(Integer.valueOf(tL_updateUserPhone.user_id));
if (user4 != null) {
user4.phone = tL_updateUserPhone.phone;
Utilities.phoneBookQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$282$MessagesController(user4);
}
});
if (UserObject.isUserSelf(user4)) {
getNotificationCenter().postNotificationName(NotificationCenter.mainUserInfoChanged, new Object[0]);
}
}
TLRPC.TL_user tL_user4 = new TLRPC.TL_user();
tL_user4.id = tL_updateUserPhone.user_id;
tL_user4.phone = tL_updateUserPhone.phone;
arrayList6.add(tL_user4);
} else if (update instanceof TLRPC.TL_updateNotifySettings) {
TLRPC.TL_updateNotifySettings tL_updateNotifySettings = (TLRPC.TL_updateNotifySettings) update;
if (tL_updateNotifySettings.notify_settings instanceof TLRPC.TL_peerNotifySettings) {
if (editor == null) {
editor = this.notificationsPreferences.edit();
}
SharedPreferences.Editor editor2 = editor;
int currentTime = getConnectionsManager().getCurrentTime();
if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyPeer) {
TLRPC.TL_notifyPeer tL_notifyPeer = (TLRPC.TL_notifyPeer) tL_updateNotifySettings.peer;
if (tL_notifyPeer.peer.user_id != 0) {
i20 = tL_notifyPeer.peer.user_id;
} else {
if (tL_notifyPeer.peer.chat_id != 0) {
i19 = tL_notifyPeer.peer.chat_id;
} else {
i19 = tL_notifyPeer.peer.channel_id;
}
i20 = -i19;
}
long j5 = i20;
TLRPC.Dialog dialog3 = this.dialogs_dict.get(j5);
if (dialog3 != null) {
dialog3.notify_settings = tL_updateNotifySettings.notify_settings;
}
if ((tL_updateNotifySettings.notify_settings.flags & 2) != 0) {
editor2.putBoolean("silent_" + j5, tL_updateNotifySettings.notify_settings.silent);
} else {
editor2.remove("silent_" + j5);
}
if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
if (tL_updateNotifySettings.notify_settings.mute_until > currentTime) {
if (tL_updateNotifySettings.notify_settings.mute_until > currentTime + 31536000) {
editor2.putInt("notify2_" + j5, 2);
if (dialog3 != null) {
tL_updateNotifySettings.notify_settings.mute_until = Integer.MAX_VALUE;
}
i22 = 0;
} else {
int i30 = tL_updateNotifySettings.notify_settings.mute_until;
editor2.putInt("notify2_" + j5, 3);
editor2.putInt("notifyuntil_" + j5, tL_updateNotifySettings.notify_settings.mute_until);
if (dialog3 != null) {
tL_updateNotifySettings.notify_settings.mute_until = i30;
}
i22 = i30;
}
getMessagesStorage().setDialogFlags(j5, (i22 << 32) | 1);
getNotificationsController().removeNotificationsForDialog(j5);
} else {
if (dialog3 != null) {
i21 = 0;
tL_updateNotifySettings.notify_settings.mute_until = 0;
} else {
i21 = 0;
}
editor2.putInt("notify2_" + j5, i21);
getMessagesStorage().setDialogFlags(j5, 0L);
}
} else {
if (dialog3 != null) {
tL_updateNotifySettings.notify_settings.mute_until = 0;
}
editor2.remove("notify2_" + j5);
getMessagesStorage().setDialogFlags(j5, 0L);
}
} else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyChats) {
if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
editor2.putBoolean("EnablePreviewGroup", tL_updateNotifySettings.notify_settings.show_previews);
}
int i31 = tL_updateNotifySettings.notify_settings.flags;
if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
editor2.putInt("EnableGroup2", tL_updateNotifySettings.notify_settings.mute_until);
}
} else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyUsers) {
if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
editor2.putBoolean("EnablePreviewAll", tL_updateNotifySettings.notify_settings.show_previews);
}
int i32 = tL_updateNotifySettings.notify_settings.flags;
if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
editor2.putInt("EnableAll2", tL_updateNotifySettings.notify_settings.mute_until);
}
} else if (tL_updateNotifySettings.peer instanceof TLRPC.TL_notifyBroadcasts) {
if ((tL_updateNotifySettings.notify_settings.flags & 1) != 0) {
editor2.putBoolean("EnablePreviewChannel", tL_updateNotifySettings.notify_settings.show_previews);
}
int i33 = tL_updateNotifySettings.notify_settings.flags;
if ((tL_updateNotifySettings.notify_settings.flags & 4) != 0) {
editor2.putInt("EnableChannel2", tL_updateNotifySettings.notify_settings.mute_until);
}
}
editor = editor2;
}
} else {
if (update instanceof TLRPC.TL_updateChannel) {
final TLRPC.TL_updateChannel tL_updateChannel = (TLRPC.TL_updateChannel) update;
TLRPC.Dialog dialog4 = this.dialogs_dict.get(-tL_updateChannel.channel_id);
TLRPC.Chat chat = getChat(Integer.valueOf(tL_updateChannel.channel_id));
if (chat != null) {
if (dialog4 == null && (chat instanceof TLRPC.TL_channel) && !chat.left) {
Utilities.stageQueue.postRunnable(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$283$MessagesController(tL_updateChannel);
}
});
} else if (chat.left && dialog4 != null && ((dialog = this.proxyDialog) == null || dialog.id != dialog4.id)) {
i18 = 0;
deleteDialog(dialog4.id, 0);
i7 = i5 | 8192;
loadFullChat(tL_updateChannel.channel_id, i18, true);
}
}
i18 = 0;
i7 = i5 | 8192;
loadFullChat(tL_updateChannel.channel_id, i18, true);
} else {
i7 = i5;
if (update instanceof TLRPC.TL_updateChatDefaultBannedRights) {
TLRPC.TL_updateChatDefaultBannedRights tL_updateChatDefaultBannedRights = (TLRPC.TL_updateChatDefaultBannedRights) update;
if (tL_updateChatDefaultBannedRights.peer.channel_id != 0) {
i17 = tL_updateChatDefaultBannedRights.peer.channel_id;
} else {
i17 = tL_updateChatDefaultBannedRights.peer.chat_id;
}
final TLRPC.Chat chat2 = getChat(Integer.valueOf(i17));
if (chat2 != null) {
chat2.default_banned_rights = tL_updateChatDefaultBannedRights.default_banned_rights;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$284$MessagesController(chat2);
}
});
}
} else if (update instanceof TLRPC.TL_updateStickerSets) {
getMediaDataController().loadStickers(0, false, true);
} else if (update instanceof TLRPC.TL_updateStickerSetsOrder) {
TLRPC.TL_updateStickerSetsOrder tL_updateStickerSetsOrder = (TLRPC.TL_updateStickerSetsOrder) update;
getMediaDataController().reorderStickers(tL_updateStickerSetsOrder.masks ? 1 : 0, tL_updateStickerSetsOrder.order);
} else if (update instanceof TLRPC.TL_updateFavedStickers) {
getMediaDataController().loadRecents(2, false, false, true);
} else if (update instanceof TLRPC.TL_updateContactsReset) {
getContactsController().forceImportContacts();
} else if (update instanceof TLRPC.TL_updateNewStickerSet) {
getMediaDataController().addNewStickerSet(((TLRPC.TL_updateNewStickerSet) update).stickerset);
} else if (update instanceof TLRPC.TL_updateSavedGifs) {
this.emojiPreferences.edit().putLong("lastGifLoadTime", 0L).commit();
} else if (update instanceof TLRPC.TL_updateRecentStickers) {
this.emojiPreferences.edit().putLong("lastStickersLoadTime", 0L).commit();
} else if (update instanceof TLRPC.TL_updateDraftMessage) {
TLRPC.TL_updateDraftMessage tL_updateDraftMessage = (TLRPC.TL_updateDraftMessage) update;
TLRPC.Peer peer2 = tL_updateDraftMessage.peer;
if (peer2.user_id != 0) {
i16 = peer2.user_id;
} else {
if (peer2.channel_id != 0) {
i15 = peer2.channel_id;
} else {
i15 = peer2.chat_id;
}
i16 = -i15;
}
getMediaDataController().saveDraft(i16, tL_updateDraftMessage.draft, null, true);
} else if (update instanceof TLRPC.TL_updateReadFeaturedStickers) {
getMediaDataController().markFaturedStickersAsRead(false);
} else if (update instanceof TLRPC.TL_updatePhoneCall) {
TLRPC.PhoneCall phoneCall = ((TLRPC.TL_updatePhoneCall) update).phone_call;
VoIPService sharedInstance = VoIPService.getSharedInstance();
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Received call in update: " + phoneCall);
FileLog.d("call id " + phoneCall.id);
}
if (phoneCall instanceof TLRPC.TL_phoneCallRequested) {
if (phoneCall.date + (this.callRingTimeout / 1000) < getConnectionsManager().getCurrentTime()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("ignoring too old call");
}
} else if (Build.VERSION.SDK_INT >= 21 && !NotificationManagerCompat.from(ApplicationLoader.applicationContext).areNotificationsEnabled()) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Ignoring incoming call because notifications are disabled in system");
}
} else {
TelephonyManager telephonyManager = (TelephonyManager) ApplicationLoader.applicationContext.getSystemService("phone");
if (sharedInstance != null || VoIPService.callIShouldHavePutIntoIntent != null || telephonyManager.getCallState() != 0) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Auto-declining call " + phoneCall.id + " because there's already active one");
}
TLRPC.TL_phone_discardCall tL_phone_discardCall = new TLRPC.TL_phone_discardCall();
tL_phone_discardCall.peer = new TLRPC.TL_inputPhoneCall();
tL_phone_discardCall.peer.access_hash = phoneCall.access_hash;
tL_phone_discardCall.peer.id = phoneCall.id;
tL_phone_discardCall.reason = new TLRPC.TL_phoneCallDiscardReasonBusy();
getConnectionsManager().sendRequest(tL_phone_discardCall, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$null$285$MessagesController(tLObject, tL_error);
}
});
} else {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Starting service for call " + phoneCall.id);
}
VoIPService.callIShouldHavePutIntoIntent = phoneCall;
Intent intent = new Intent(ApplicationLoader.applicationContext, (Class<?>) VoIPService.class);
intent.putExtra("is_outgoing", false);
intent.putExtra("user_id", phoneCall.participant_id == getUserConfig().getClientUserId() ? phoneCall.admin_id : phoneCall.participant_id);
intent.putExtra("account", this.currentAccount);
try {
if (Build.VERSION.SDK_INT >= 26) {
ApplicationLoader.applicationContext.startForegroundService(intent);
} else {
ApplicationLoader.applicationContext.startService(intent);
}
} catch (Throwable th) {
FileLog.e(th);
}
}
}
} else if (sharedInstance != null && phoneCall != null) {
sharedInstance.onCallUpdated(phoneCall);
} else if (VoIPService.callIShouldHavePutIntoIntent != null) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("Updated the call while the service is starting");
}
if (phoneCall.id == VoIPService.callIShouldHavePutIntoIntent.id) {
VoIPService.callIShouldHavePutIntoIntent = phoneCall;
}
}
} else if (update instanceof TLRPC.TL_updateDialogUnreadMark) {
TLRPC.TL_updateDialogUnreadMark tL_updateDialogUnreadMark = (TLRPC.TL_updateDialogUnreadMark) update;
if (tL_updateDialogUnreadMark.peer instanceof TLRPC.TL_dialogPeer) {
TLRPC.TL_dialogPeer tL_dialogPeer = (TLRPC.TL_dialogPeer) tL_updateDialogUnreadMark.peer;
if (tL_dialogPeer.peer.user_id != 0) {
i14 = tL_dialogPeer.peer.user_id;
} else {
if (tL_dialogPeer.peer.chat_id != 0) {
i13 = tL_dialogPeer.peer.chat_id;
} else {
i13 = tL_dialogPeer.peer.channel_id;
}
i14 = -i13;
}
j2 = i14;
} else {
j2 = 0;
}
getMessagesStorage().setDialogUnread(j2, tL_updateDialogUnreadMark.unread);
TLRPC.Dialog dialog5 = this.dialogs_dict.get(j2);
if (dialog5 == null || dialog5.unread_mark == tL_updateDialogUnreadMark.unread) {
i12 = i7;
} else {
dialog5.unread_mark = tL_updateDialogUnreadMark.unread;
if (dialog5.unread_count == 0 && !isDialogMuted(j2)) {
if (dialog5.unread_mark) {
this.unreadUnmutedDialogs++;
} else {
this.unreadUnmutedDialogs--;
}
}
if (dialog5.unread_count == 0 && dialog5.unread_mark) {
this.dialogsUnreadOnly.add(dialog5);
}
i12 = i7 | 256;
}
i7 = i12;
} else if (update instanceof TLRPC.TL_updateMessagePoll) {
TLRPC.TL_updateMessagePoll tL_updateMessagePoll = (TLRPC.TL_updateMessagePoll) update;
getNotificationCenter().postNotificationName(NotificationCenter.didUpdatePollResults, Long.valueOf(tL_updateMessagePoll.poll_id), tL_updateMessagePoll.poll, tL_updateMessagePoll.results);
} else if (update instanceof TLRPC.TL_updatePeerSettings) {
TLRPC.TL_updatePeerSettings tL_updatePeerSettings = (TLRPC.TL_updatePeerSettings) update;
if (tL_updatePeerSettings.peer instanceof TLRPC.TL_peerUser) {
i11 = tL_updatePeerSettings.peer.user_id;
} else {
if (tL_updatePeerSettings.peer instanceof TLRPC.TL_peerChat) {
i10 = tL_updatePeerSettings.peer.chat_id;
} else {
i10 = tL_updatePeerSettings.peer.channel_id;
}
i11 = -i10;
}
savePeerSettings(i11, tL_updatePeerSettings.settings, true);
} else if (update instanceof TLRPC.TL_updatePeerLocated) {
getNotificationCenter().postNotificationName(NotificationCenter.newPeopleNearbyAvailable, update);
} else if (update instanceof TLRPC.TL_updateMessageReactions) {
TLRPC.TL_updateMessageReactions tL_updateMessageReactions = (TLRPC.TL_updateMessageReactions) update;
if (tL_updateMessageReactions.peer.chat_id != 0) {
i9 = tL_updateMessageReactions.peer.chat_id;
} else if (tL_updateMessageReactions.peer.channel_id != 0) {
i9 = tL_updateMessageReactions.peer.channel_id;
} else {
i8 = tL_updateMessageReactions.peer.user_id;
getNotificationCenter().postNotificationName(NotificationCenter.didUpdateReactions, Long.valueOf(i8), Integer.valueOf(tL_updateMessageReactions.msg_id), tL_updateMessageReactions.reactions);
}
i8 = -i9;
getNotificationCenter().postNotificationName(NotificationCenter.didUpdateReactions, Long.valueOf(i8), Integer.valueOf(tL_updateMessageReactions.msg_id), tL_updateMessageReactions.reactions);
} else if (update instanceof TLRPC.TL_updateTheme) {
Theme.setThemeUploadInfo(null, (TLRPC.TL_theme) ((TLRPC.TL_updateTheme) update).theme, true);
}
}
i27++;
arrayList10 = arrayList5;
size = i6;
i25 = 0;
ArrayList<TLRPC.User> arrayList14 = arrayList6;
i26 = i7;
arrayList9 = arrayList14;
}
}
i7 = i5;
i27++;
arrayList10 = arrayList5;
size = i6;
i25 = 0;
ArrayList<TLRPC.User> arrayList142 = arrayList6;
i26 = i7;
arrayList9 = arrayList142;
}
z2 = true;
i27++;
arrayList10 = arrayList5;
size = i6;
i25 = 0;
ArrayList<TLRPC.User> arrayList1422 = arrayList6;
i26 = i7;
arrayList9 = arrayList1422;
}
}
arrayList6 = arrayList4;
i7 = i5;
i27++;
arrayList10 = arrayList5;
size = i6;
i25 = 0;
ArrayList<TLRPC.User> arrayList14222 = arrayList6;
i26 = i7;
arrayList9 = arrayList14222;
}
i6 = size;
arrayList5 = arrayList10;
int i34 = i26;
arrayList6 = arrayList9;
i7 = i34;
i27++;
arrayList10 = arrayList5;
size = i6;
i25 = 0;
ArrayList<TLRPC.User> arrayList142222 = arrayList6;
i26 = i7;
arrayList9 = arrayList142222;
}
ArrayList<TLRPC.User> arrayList15 = arrayList10;
int i35 = i26;
ArrayList<TLRPC.User> arrayList16 = arrayList9;
i3 = i35;
if (editor != null) {
editor.commit();
z4 = false;
getNotificationCenter().postNotificationName(NotificationCenter.notificationsSettingsUpdated, new Object[0]);
} else {
z4 = false;
}
i2 = 1;
getMessagesStorage().updateUsers(arrayList15, true, true, true);
getMessagesStorage().updateUsers(arrayList16, z4, true, true);
r3 = z4;
} else {
i2 = 1;
i3 = i;
z2 = false;
}
if (longSparseArray != null) {
NotificationCenter notificationCenter = getNotificationCenter();
int i36 = NotificationCenter.didReceivedWebpagesInUpdates;
Object[] objArr = new Object[i2];
objArr[r3] = longSparseArray;
notificationCenter.postNotificationName(i36, objArr);
int i37 = 2;
int i38 = 0;
while (i38 < i37) {
LongSparseArray<ArrayList<MessageObject>> longSparseArray6 = i38 == i2 ? this.reloadingScheduledWebpagesPending : this.reloadingWebpagesPending;
int size4 = longSparseArray.size();
int i39 = 0;
while (i39 < size4) {
long keyAt = longSparseArray.keyAt(i39);
ArrayList<MessageObject> arrayList17 = longSparseArray6.get(keyAt);
longSparseArray6.remove(keyAt);
if (arrayList17 != null) {
TLRPC.WebPage webPage = (TLRPC.WebPage) longSparseArray.valueAt(i39);
ArrayList<TLRPC.Message> arrayList18 = new ArrayList<>();
if ((webPage instanceof TLRPC.TL_webPage) || (webPage instanceof TLRPC.TL_webPageEmpty)) {
int size5 = arrayList17.size();
int i40 = 0;
j = 0;
while (i40 < size5) {
LongSparseArray<ArrayList<MessageObject>> longSparseArray7 = longSparseArray6;
arrayList17.get(i40).messageOwner.media.webpage = webPage;
if (i40 == 0) {
j = arrayList17.get(i40).getDialogId();
ImageLoader.saveMessageThumbs(arrayList17.get(i40).messageOwner);
}
arrayList18.add(arrayList17.get(i40).messageOwner);
i40++;
longSparseArray6 = longSparseArray7;
}
longSparseArray5 = longSparseArray6;
} else {
longSparseArray6.put(webPage.id, arrayList17);
longSparseArray5 = longSparseArray6;
j = 0;
}
if (!arrayList18.isEmpty()) {
getMessagesStorage().putMessages(arrayList18, true, true, false, getDownloadController().getAutodownloadMask(), i38 == 1);
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(j), arrayList17);
}
} else {
longSparseArray5 = longSparseArray6;
}
i39++;
longSparseArray6 = longSparseArray5;
}
i38++;
i37 = 2;
i2 = 1;
}
}
if (longSparseArray2 != null) {
int size6 = longSparseArray2.size();
for (int i41 = 0; i41 < size6; i41++) {
updateInterfaceWithMessages(longSparseArray2.keyAt(i41), (ArrayList) longSparseArray2.valueAt(i41), false);
}
} else {
if (!z2) {
z3 = false;
if (longSparseArray3 != null) {
int size7 = longSparseArray3.size();
for (int i42 = 0; i42 < size7; i42++) {
updateInterfaceWithMessages(longSparseArray3.keyAt(i42), (ArrayList) longSparseArray3.valueAt(i42), true);
}
}
if (longSparseArray4 != null) {
int size8 = longSparseArray4.size();
for (int i43 = 0; i43 < size8; i43++) {
long keyAt2 = longSparseArray4.keyAt(i43);
ArrayList<MessageObject> arrayList19 = (ArrayList) longSparseArray4.valueAt(i43);
MessageObject messageObject = this.dialogMessage.get(keyAt2);
if (messageObject != null) {
int size9 = arrayList19.size();
int i44 = 0;
while (true) {
if (i44 >= size9) {
break;
}
MessageObject messageObject2 = arrayList19.get(i44);
if (messageObject.getId() != messageObject2.getId()) {
if (messageObject.getDialogId() == messageObject2.getDialogId() && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) && messageObject.replyMessageObject != null && messageObject.replyMessageObject.getId() == messageObject2.getId()) {
messageObject.replyMessageObject = messageObject2;
messageObject.generatePinMessageText(null, null);
z3 = true;
break;
}
i44++;
} else {
this.dialogMessage.put(keyAt2, messageObject2);
if (messageObject2.messageOwner.to_id != null && messageObject2.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject2.getId(), messageObject2);
}
z3 = true;
}
}
}
getMediaDataController().loadReplyMessagesForMessages(arrayList19, keyAt2, false);
getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, Long.valueOf(keyAt2), arrayList19, false);
}
}
if (z3) {
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, new Object[0]);
}
if (z) {
i3 |= 64;
}
if (arrayList2 != null) {
i3 = i3 | 1 | 128;
}
if (arrayList3 != null) {
int size10 = arrayList3.size();
for (int i45 = 0; i45 < size10; i45++) {
getMessagesStorage().updateChatParticipants((TLRPC.ChatParticipants) arrayList3.get(i45));
}
}
if (sparseArray == null) {
i4 = 1;
c = 0;
getNotificationCenter().postNotificationName(NotificationCenter.didUpdatedMessagesViews, sparseArray);
} else {
i4 = 1;
c = 0;
}
if (i3 == 0) {
NotificationCenter notificationCenter2 = getNotificationCenter();
int i46 = NotificationCenter.updateInterfaces;
Object[] objArr2 = new Object[i4];
objArr2[c] = Integer.valueOf(i3);
notificationCenter2.postNotificationName(i46, objArr2);
return;
}
return;
}
sortDialogs(null);
}
z3 = true;
if (longSparseArray3 != null) {
}
if (longSparseArray4 != null) {
}
if (z3) {
}
if (z) {
}
if (arrayList2 != null) {
}
if (arrayList3 != null) {
}
if (sparseArray == null) {
}
if (i3 == 0) {
}
}
public void lambda$null$282$MessagesController(TLRPC.User user) {
getContactsController().addContactToPhoneBook(user, true);
}
public void lambda$null$283$MessagesController(TLRPC.TL_updateChannel tL_updateChannel) {
getChannelDifference(tL_updateChannel.channel_id, 1, 0L, null);
}
public void lambda$null$284$MessagesController(TLRPC.Chat chat) {
getNotificationCenter().postNotificationName(NotificationCenter.channelRightsUpdated, chat);
}
public void lambda$null$285$MessagesController(TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
processUpdates((TLRPC.Updates) tLObject, false);
}
}
public void lambda$processUpdateArray$288$MessagesController(final SparseLongArray sparseLongArray, final SparseLongArray sparseLongArray2, final SparseIntArray sparseIntArray, final ArrayList arrayList, final SparseArray sparseArray, final SparseArray sparseArray2, final SparseIntArray sparseIntArray2) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$287$MessagesController(sparseLongArray, sparseLongArray2, sparseIntArray, arrayList, sparseArray, sparseArray2, sparseIntArray2);
}
});
}
public void lambda$null$287$MessagesController(SparseLongArray sparseLongArray, SparseLongArray sparseLongArray2, SparseIntArray sparseIntArray, ArrayList arrayList, SparseArray sparseArray, SparseArray sparseArray2, SparseIntArray sparseIntArray2) {
int i;
MessageObject messageObject;
MessageObject messageObject2;
MessageObject messageObject3;
if (sparseLongArray == null && sparseLongArray2 == null) {
i = 0;
} else {
getNotificationCenter().postNotificationName(NotificationCenter.messagesRead, sparseLongArray, sparseLongArray2);
if (sparseLongArray != null) {
getNotificationsController().processReadMessages(sparseLongArray, 0L, 0, 0, false);
SharedPreferences.Editor edit = this.notificationsPreferences.edit();
int size = sparseLongArray.size();
i = 0;
for (int i2 = 0; i2 < size; i2++) {
int keyAt = sparseLongArray.keyAt(i2);
int valueAt = (int) sparseLongArray.valueAt(i2);
TLRPC.Dialog dialog = this.dialogs_dict.get(keyAt);
if (dialog != null && dialog.top_message > 0 && dialog.top_message <= valueAt && (messageObject2 = this.dialogMessage.get(dialog.id)) != null && !messageObject2.isOut()) {
messageObject2.setIsRead();
i |= 256;
}
if (keyAt != getUserConfig().getClientUserId()) {
edit.remove("diditem" + keyAt);
edit.remove("diditemo" + keyAt);
}
}
edit.commit();
} else {
i = 0;
}
if (sparseLongArray2 != null) {
int size2 = sparseLongArray2.size();
for (int i3 = 0; i3 < size2; i3++) {
int keyAt2 = sparseLongArray2.keyAt(i3);
int valueAt2 = (int) sparseLongArray2.valueAt(i3);
TLRPC.Dialog dialog2 = this.dialogs_dict.get(keyAt2);
if (dialog2 != null && dialog2.top_message > 0 && dialog2.top_message <= valueAt2 && (messageObject = this.dialogMessage.get(dialog2.id)) != null && messageObject.isOut()) {
messageObject.setIsRead();
i |= 256;
}
}
}
}
if (sparseIntArray != null) {
int size3 = sparseIntArray.size();
for (int i4 = 0; i4 < size3; i4++) {
int keyAt3 = sparseIntArray.keyAt(i4);
int valueAt3 = sparseIntArray.valueAt(i4);
getNotificationCenter().postNotificationName(NotificationCenter.messagesReadEncrypted, Integer.valueOf(keyAt3), Integer.valueOf(valueAt3));
long j = keyAt3 << 32;
if (this.dialogs_dict.get(j) != null && (messageObject3 = this.dialogMessage.get(j)) != null && messageObject3.messageOwner.date <= valueAt3) {
messageObject3.setIsRead();
i |= 256;
}
}
}
if (arrayList != null) {
getNotificationCenter().postNotificationName(NotificationCenter.messagesReadContent, arrayList);
}
if (sparseArray != null) {
int size4 = sparseArray.size();
for (int i5 = 0; i5 < size4; i5++) {
int keyAt4 = sparseArray.keyAt(i5);
ArrayList arrayList2 = (ArrayList) sparseArray.valueAt(i5);
if (arrayList2 != null) {
getNotificationCenter().postNotificationName(NotificationCenter.messagesDeleted, arrayList2, Integer.valueOf(keyAt4), false);
if (keyAt4 == 0) {
int size5 = arrayList2.size();
for (int i6 = 0; i6 < size5; i6++) {
MessageObject messageObject4 = this.dialogMessagesByIds.get(((Integer) arrayList2.get(i6)).intValue());
if (messageObject4 != null) {
messageObject4.deleted = true;
}
}
} else {
MessageObject messageObject5 = this.dialogMessage.get(-keyAt4);
if (messageObject5 != null) {
int size6 = arrayList2.size();
int i7 = 0;
while (true) {
if (i7 >= size6) {
break;
}
if (messageObject5.getId() == ((Integer) arrayList2.get(i7)).intValue()) {
messageObject5.deleted = true;
break;
}
i7++;
}
}
}
}
}
getNotificationsController().removeDeletedMessagesFromNotifications(sparseArray);
}
if (sparseArray2 != null) {
int size7 = sparseArray2.size();
for (int i8 = 0; i8 < size7; i8++) {
int keyAt5 = sparseArray2.keyAt(i8);
ArrayList arrayList3 = (ArrayList) sparseArray2.valueAt(i8);
if (arrayList3 != null) {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.messagesDeleted, arrayList3, Integer.valueOf(keyAt5), true);
}
}
}
if (sparseIntArray2 != null) {
int size8 = sparseIntArray2.size();
int i9 = 0;
while (true) {
if (i9 >= size8) {
break;
}
int keyAt6 = sparseIntArray2.keyAt(i9);
int valueAt4 = sparseIntArray2.valueAt(i9);
long j2 = -keyAt6;
getNotificationCenter().postNotificationName(NotificationCenter.historyCleared, Long.valueOf(j2), Integer.valueOf(valueAt4));
MessageObject messageObject6 = this.dialogMessage.get(j2);
if (messageObject6 != null && messageObject6.getId() <= valueAt4) {
messageObject6.deleted = true;
break;
}
i9++;
}
getNotificationsController().removeDeletedHisoryFromNotifications(sparseIntArray2);
}
if (i != 0) {
getNotificationCenter().postNotificationName(NotificationCenter.updateInterfaces, Integer.valueOf(i));
}
}
public void lambda$processUpdateArray$289$MessagesController(ArrayList arrayList, int i) {
getMessagesStorage().updateDialogsWithDeletedMessages(arrayList, getMessagesStorage().markMessagesAsDeleted(arrayList, false, i, true, false), false, i);
}
public void lambda$processUpdateArray$290$MessagesController(int i, int i2) {
getMessagesStorage().updateDialogsWithDeletedMessages(new ArrayList<>(), getMessagesStorage().markMessagesAsDeleted(i, i2, false, true), false, i);
}
public boolean isDialogMuted(long j) {
int i = this.notificationsPreferences.getInt("notify2_" + j, -1);
if (i == -1) {
return !getNotificationsController().isGlobalNotificationsEnabled(j);
}
if (i == 2) {
return true;
}
if (i == 3) {
if (this.notificationsPreferences.getInt("notifyuntil_" + j, 0) >= getConnectionsManager().getCurrentTime()) {
return true;
}
}
return false;
}
private boolean updatePrintingUsersWithNewMessages(long j, ArrayList<MessageObject> arrayList) {
boolean z;
if (j > 0) {
if (this.printingUsers.get(Long.valueOf(j)) != null) {
this.printingUsers.remove(Long.valueOf(j));
return true;
}
} else if (j < 0) {
ArrayList arrayList2 = new ArrayList();
Iterator<MessageObject> it = arrayList.iterator();
while (it.hasNext()) {
MessageObject next = it.next();
if (!arrayList2.contains(Integer.valueOf(next.messageOwner.from_id))) {
arrayList2.add(Integer.valueOf(next.messageOwner.from_id));
}
}
ArrayList<PrintingUser> arrayList3 = this.printingUsers.get(Long.valueOf(j));
if (arrayList3 != null) {
int i = 0;
z = false;
while (i < arrayList3.size()) {
if (arrayList2.contains(Integer.valueOf(arrayList3.get(i).userId))) {
arrayList3.remove(i);
i--;
if (arrayList3.isEmpty()) {
this.printingUsers.remove(Long.valueOf(j));
}
z = true;
}
i++;
}
} else {
z = false;
}
if (z) {
return true;
}
}
return false;
}
public void updateInterfaceWithMessages(final long j, ArrayList<MessageObject> arrayList, boolean z) {
MessageObject messageObject;
boolean z2;
int i;
boolean z3;
boolean z4;
if (arrayList == null || arrayList.isEmpty()) {
return;
}
boolean z5 = false;
boolean z6 = ((int) j) == 0;
if (z) {
messageObject = null;
z2 = false;
i = 0;
z3 = false;
} else {
messageObject = null;
z2 = false;
i = 0;
z3 = false;
for (int i2 = 0; i2 < arrayList.size(); i2++) {
MessageObject messageObject2 = arrayList.get(i2);
if (messageObject == null || ((!z6 && messageObject2.getId() > messageObject.getId()) || (((z6 || (messageObject2.getId() < 0 && messageObject.getId() < 0)) && messageObject2.getId() < messageObject.getId()) || messageObject2.messageOwner.date > messageObject.messageOwner.date))) {
if (messageObject2.messageOwner.to_id.channel_id != 0) {
i = messageObject2.messageOwner.to_id.channel_id;
}
messageObject = messageObject2;
}
if (!z2 && !messageObject2.isOut()) {
z2 = true;
}
if (messageObject2.isOut() && !messageObject2.isSending() && !messageObject2.isForwarded()) {
if (messageObject2.isNewGif()) {
getMediaDataController().addRecentGif(messageObject2.messageOwner.media.document, messageObject2.messageOwner.date);
} else if (!messageObject2.isAnimatedEmoji() && (messageObject2.isSticker() || messageObject2.isAnimatedSticker())) {
getMediaDataController().addRecentSticker(0, messageObject2, messageObject2.messageOwner.media.document, messageObject2.messageOwner.date, false);
}
}
if (messageObject2.isOut() && messageObject2.isSent()) {
z3 = true;
}
}
}
getMediaDataController().loadReplyMessagesForMessages(arrayList, j, z);
getNotificationCenter().postNotificationName(NotificationCenter.didReceiveNewMessages, Long.valueOf(j), arrayList, Boolean.valueOf(z));
if (messageObject == null || z) {
return;
}
TLRPC.TL_dialog tL_dialog = (TLRPC.TL_dialog) this.dialogs_dict.get(j);
if (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionChatMigrateTo) {
if (tL_dialog != null) {
this.allDialogs.remove(tL_dialog);
this.dialogsServerOnly.remove(tL_dialog);
this.dialogsCanAddUsers.remove(tL_dialog);
this.dialogsChannelsOnly.remove(tL_dialog);
this.dialogsGroupsOnly.remove(tL_dialog);
this.dialogsUnreadOnly.remove(tL_dialog);
this.dialogsUsersOnly.remove(tL_dialog);
this.dialogsForward.remove(tL_dialog);
this.dialogs_dict.remove(tL_dialog.id);
this.dialogs_read_inbox_max.remove(Long.valueOf(tL_dialog.id));
this.dialogs_read_outbox_max.remove(Long.valueOf(tL_dialog.id));
int i3 = this.nextDialogsCacheOffset.get(tL_dialog.folder_id, 0);
if (i3 > 0) {
this.nextDialogsCacheOffset.put(tL_dialog.folder_id, i3 - 1);
}
this.dialogMessage.remove(tL_dialog.id);
ArrayList<TLRPC.Dialog> arrayList2 = this.dialogsByFolder.get(tL_dialog.folder_id);
if (arrayList2 != null) {
arrayList2.remove(tL_dialog);
}
MessageObject messageObject3 = this.dialogMessagesByIds.get(tL_dialog.top_message);
this.dialogMessagesByIds.remove(tL_dialog.top_message);
if (messageObject3 != null && messageObject3.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject3.messageOwner.random_id);
}
tL_dialog.top_message = 0;
getNotificationsController().removeNotificationsForDialog(tL_dialog.id);
getNotificationCenter().postNotificationName(NotificationCenter.needReloadRecentDialogsSearch, new Object[0]);
return;
}
return;
}
if (tL_dialog == null) {
TLRPC.Chat chat = getChat(Integer.valueOf(i));
if (i != 0 && chat == null) {
return;
}
if (chat != null && ChatObject.isNotInChat(chat)) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("not found dialog with id " + j + " dictCount = " + this.dialogs_dict.size() + " allCount = " + this.allDialogs.size());
}
final TLRPC.TL_dialog tL_dialog2 = new TLRPC.TL_dialog();
tL_dialog2.id = j;
tL_dialog2.unread_count = 0;
tL_dialog2.top_message = messageObject.getId();
tL_dialog2.last_message_date = messageObject.messageOwner.date;
tL_dialog2.flags = ChatObject.isChannel(chat) ? 1 : 0;
this.dialogs_dict.put(j, tL_dialog2);
this.allDialogs.add(tL_dialog2);
this.dialogMessage.put(j, messageObject);
if (messageObject.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
}
}
getMessagesStorage().getDialogFolderId(j, new MessagesStorage.IntCallback() {
@Override
public final void run(int i4) {
MessagesController.this.lambda$updateInterfaceWithMessages$291$MessagesController(tL_dialog2, j, i4);
}
});
} else {
if (z2 && tL_dialog.folder_id == 1 && !isDialogMuted(tL_dialog.id)) {
tL_dialog.folder_id = 0;
tL_dialog.pinned = false;
tL_dialog.pinnedNum = 0;
getMessagesStorage().setDialogsFolderId(null, null, tL_dialog.id, 0);
z5 = true;
}
if ((tL_dialog.top_message <= 0 || messageObject.getId() <= 0 || messageObject.getId() <= tL_dialog.top_message) && ((tL_dialog.top_message >= 0 || messageObject.getId() >= 0 || messageObject.getId() >= tL_dialog.top_message) && this.dialogMessage.indexOfKey(j) >= 0 && tL_dialog.top_message >= 0 && tL_dialog.last_message_date > messageObject.messageOwner.date)) {
z4 = z5;
if (z4) {
sortDialogs(null);
}
if (z3) {
return;
}
getMediaDataController().increasePeerRaiting(j);
return;
}
MessageObject messageObject4 = this.dialogMessagesByIds.get(tL_dialog.top_message);
this.dialogMessagesByIds.remove(tL_dialog.top_message);
if (messageObject4 != null && messageObject4.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.remove(messageObject4.messageOwner.random_id);
}
tL_dialog.top_message = messageObject.getId();
tL_dialog.last_message_date = messageObject.messageOwner.date;
this.dialogMessage.put(j, messageObject);
if (messageObject.messageOwner.to_id.channel_id == 0) {
this.dialogMessagesByIds.put(messageObject.getId(), messageObject);
if (messageObject.messageOwner.random_id != 0) {
this.dialogMessagesByRandomIds.put(messageObject.messageOwner.random_id, messageObject);
}
}
}
z4 = true;
if (z4) {
}
if (z3) {
}
}
public void lambda$updateInterfaceWithMessages$291$MessagesController(TLRPC.Dialog dialog, long j, int i) {
if (i == -1) {
int i2 = (int) j;
if (i2 != 0) {
loadUnknownDialog(getInputPeer(i2), 0L);
return;
}
return;
}
if (i != 0) {
dialog.folder_id = i;
sortDialogs(null);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}
}
public void addDialogAction(long j, boolean z) {
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog == null) {
return;
}
if (z) {
this.clearingHistoryDialogs.put(j, dialog);
} else {
this.deletingDialogs.put(j, dialog);
this.allDialogs.remove(dialog);
sortDialogs(null);
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}
public void removeDialogAction(long j, boolean z, boolean z2) {
TLRPC.Dialog dialog = this.dialogs_dict.get(j);
if (dialog == null) {
return;
}
if (z) {
this.clearingHistoryDialogs.remove(j);
} else {
this.deletingDialogs.remove(j);
if (!z2) {
this.allDialogs.add(dialog);
sortDialogs(null);
}
}
if (z2) {
return;
}
getNotificationCenter().postNotificationName(NotificationCenter.dialogsNeedReload, true);
}
public boolean isClearingDialog(long j) {
return this.clearingHistoryDialogs.get(j) != null;
}
public void sortDialogs(SparseArray<TLRPC.Chat> sparseArray) {
TLRPC.User currentUser;
boolean z;
TLRPC.Chat chat;
TLRPC.Chat chat2;
this.dialogsServerOnly.clear();
this.dialogsCanAddUsers.clear();
this.dialogsChannelsOnly.clear();
this.dialogsGroupsOnly.clear();
this.dialogsUnreadOnly.clear();
this.dialogsUsersOnly.clear();
this.dialogsForward.clear();
for (int i = 0; i < this.dialogsByFolder.size(); i++) {
ArrayList<TLRPC.Dialog> valueAt = this.dialogsByFolder.valueAt(i);
if (valueAt != null) {
valueAt.clear();
}
}
this.unreadUnmutedDialogs = 0;
int clientUserId = getUserConfig().getClientUserId();
Collections.sort(this.allDialogs, this.dialogComparator);
this.isLeftProxyChannel = true;
TLRPC.Dialog dialog = this.proxyDialog;
if (dialog != null && dialog.id < 0 && (chat2 = getChat(Integer.valueOf(-((int) this.proxyDialog.id)))) != null && !chat2.left) {
this.isLeftProxyChannel = false;
}
boolean z2 = getNotificationsController().showBadgeMessages;
int size = this.allDialogs.size();
int i2 = 0;
boolean z3 = false;
while (i2 < size) {
TLRPC.Dialog dialog2 = this.allDialogs.get(i2);
int i3 = (int) (dialog2.id >> 32);
int i4 = (int) dialog2.id;
if (dialog2 instanceof TLRPC.TL_dialog) {
if (i4 != 0 && i3 != 1) {
this.dialogsServerOnly.add(dialog2);
if (DialogObject.isChannel(dialog2)) {
TLRPC.Chat chat3 = getChat(Integer.valueOf(-i4));
if (chat3 != null && ((chat3.megagroup && chat3.admin_rights != null && (chat3.admin_rights.post_messages || chat3.admin_rights.add_admins)) || chat3.creator)) {
this.dialogsCanAddUsers.add(dialog2);
}
if (chat3 != null && chat3.megagroup) {
this.dialogsGroupsOnly.add(dialog2);
} else {
this.dialogsChannelsOnly.add(dialog2);
if (!ChatObject.hasAdminRights(chat3) || !ChatObject.canPost(chat3)) {
z = false;
if (dialog2.unread_count == 0 || dialog2.unread_mentions_count != 0) {
this.dialogsUnreadOnly.add(dialog2);
}
if (z && dialog2.folder_id == 0) {
if (i4 != clientUserId) {
this.dialogsForward.add(0, dialog2);
z3 = true;
} else {
this.dialogsForward.add(dialog2);
}
}
}
}
} else if (i4 < 0) {
if (sparseArray != null && (chat = sparseArray.get(-i4)) != null && chat.migrated_to != null) {
this.allDialogs.remove(i2);
i2--;
size--;
i2++;
} else {
this.dialogsCanAddUsers.add(dialog2);
this.dialogsGroupsOnly.add(dialog2);
}
} else if (i4 > 0 && i4 != clientUserId) {
this.dialogsUsersOnly.add(dialog2);
}
}
z = true;
if (dialog2.unread_count == 0) {
}
this.dialogsUnreadOnly.add(dialog2);
if (z) {
if (i4 != clientUserId) {
}
}
}
if ((dialog2.unread_count != 0 || dialog2.unread_mark) && !isDialogMuted(dialog2.id)) {
this.unreadUnmutedDialogs++;
}
if (this.proxyDialog != null && dialog2.id == this.proxyDialog.id && this.isLeftProxyChannel) {
this.allDialogs.remove(i2);
i2--;
size--;
i2++;
} else {
addDialogToItsFolder(-1, dialog2, z2);
i2++;
}
}
TLRPC.Dialog dialog3 = this.proxyDialog;
if (dialog3 != null && this.isLeftProxyChannel) {
this.allDialogs.add(0, dialog3);
addDialogToItsFolder(-2, this.proxyDialog, z2);
}
if (!z3 && (currentUser = getUserConfig().getCurrentUser()) != null) {
TLRPC.TL_dialog tL_dialog = new TLRPC.TL_dialog();
tL_dialog.id = currentUser.id;
tL_dialog.notify_settings = new TLRPC.TL_peerNotifySettings();
tL_dialog.peer = new TLRPC.TL_peerUser();
tL_dialog.peer.user_id = currentUser.id;
this.dialogsForward.add(0, tL_dialog);
}
for (int i5 = 0; i5 < this.dialogsByFolder.size(); i5++) {
int keyAt = this.dialogsByFolder.keyAt(i5);
if (this.dialogsByFolder.valueAt(i5).isEmpty()) {
this.dialogsByFolder.remove(keyAt);
}
}
}
private void addDialogToItsFolder(int i, TLRPC.Dialog dialog, boolean z) {
int i2;
TLRPC.Dialog dialog2;
if (dialog instanceof TLRPC.TL_dialogFolder) {
dialog.unread_count = 0;
dialog.unread_mentions_count = 0;
i2 = 0;
} else {
i2 = dialog.folder_id;
}
ArrayList<TLRPC.Dialog> arrayList = this.dialogsByFolder.get(i2);
if (arrayList == null) {
arrayList = new ArrayList<>();
this.dialogsByFolder.put(i2, arrayList);
}
if (i2 != 0 && dialog.unread_count != 0 && (dialog2 = this.dialogs_dict.get(DialogObject.makeFolderDialogId(i2))) != null) {
if (z) {
if (isDialogMuted(dialog.id)) {
dialog2.unread_count += dialog.unread_count;
} else {
dialog2.unread_mentions_count += dialog.unread_count;
}
} else if (isDialogMuted(dialog.id)) {
dialog2.unread_count++;
} else {
dialog2.unread_mentions_count++;
}
}
if (i == -1) {
arrayList.add(dialog);
return;
}
if (i == -2) {
if (arrayList.isEmpty() || !(arrayList.get(0) instanceof TLRPC.TL_dialogFolder)) {
arrayList.add(0, dialog);
return;
} else {
arrayList.add(1, dialog);
return;
}
}
arrayList.add(i, dialog);
}
public static String getRestrictionReason(ArrayList<TLRPC.TL_restrictionReason> arrayList) {
if (arrayList.isEmpty()) {
return null;
}
int size = arrayList.size();
for (int i = 0; i < size; i++) {
TLRPC.TL_restrictionReason tL_restrictionReason = arrayList.get(i);
if ("all".equals(tL_restrictionReason.platform) || "android".equals(tL_restrictionReason.platform)) {
return tL_restrictionReason.text;
}
}
return null;
}
private static void showCantOpenAlert(BaseFragment baseFragment, String str) {
if (baseFragment == null || baseFragment.getParentActivity() == null) {
return;
}
AlertDialog.Builder builder = new AlertDialog.Builder(baseFragment.getParentActivity());
builder.setTitle(LocaleController.getString("AppName", R.string.AppName));
builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null);
builder.setMessage(str);
baseFragment.showDialog(builder.create());
}
public boolean checkCanOpenChat(Bundle bundle, BaseFragment baseFragment) {
return checkCanOpenChat(bundle, baseFragment, null);
}
public boolean checkCanOpenChat(final Bundle bundle, final BaseFragment baseFragment, MessageObject messageObject) {
TLRPC.User user;
TLRPC.Chat chat;
int dialogId;
TLRPC.TL_messages_getMessages tL_messages_getMessages;
if (bundle != null && baseFragment != null) {
int i = bundle.getInt("user_id", 0);
int i2 = bundle.getInt("chat_id", 0);
int i3 = bundle.getInt("message_id", 0);
String str = null;
if (i != 0) {
user = getUser(Integer.valueOf(i));
chat = null;
} else if (i2 != 0) {
chat = getChat(Integer.valueOf(i2));
user = null;
} else {
user = null;
chat = null;
}
if (user == null && chat == null) {
return true;
}
if (chat != null) {
str = getRestrictionReason(chat.restriction_reason);
} else if (user != null) {
str = getRestrictionReason(user.restriction_reason);
}
if (str != null) {
showCantOpenAlert(baseFragment, str);
return false;
}
if (i3 != 0 && messageObject != null && chat != null && chat.access_hash == 0 && (dialogId = (int) messageObject.getDialogId()) != 0) {
final AlertDialog alertDialog = new AlertDialog(baseFragment.getParentActivity(), 3);
if (dialogId < 0) {
chat = getChat(Integer.valueOf(-dialogId));
}
if (dialogId > 0 || !ChatObject.isChannel(chat)) {
TLRPC.TL_messages_getMessages tL_messages_getMessages2 = new TLRPC.TL_messages_getMessages();
tL_messages_getMessages2.id.add(Integer.valueOf(messageObject.getId()));
tL_messages_getMessages = tL_messages_getMessages2;
} else {
TLRPC.Chat chat2 = getChat(Integer.valueOf(-dialogId));
TLRPC.TL_channels_getMessages tL_channels_getMessages = new TLRPC.TL_channels_getMessages();
tL_channels_getMessages.channel = getInputChannel(chat2);
tL_channels_getMessages.id.add(Integer.valueOf(messageObject.getId()));
tL_messages_getMessages = tL_channels_getMessages;
}
final int sendRequest = getConnectionsManager().sendRequest(tL_messages_getMessages, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$checkCanOpenChat$293$MessagesController(alertDialog, baseFragment, bundle, tLObject, tL_error);
}
});
alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
MessagesController.this.lambda$checkCanOpenChat$294$MessagesController(sendRequest, baseFragment, dialogInterface);
}
});
baseFragment.setVisibleDialog(alertDialog);
alertDialog.show();
return false;
}
}
return true;
}
public void lambda$checkCanOpenChat$293$MessagesController(final AlertDialog alertDialog, final BaseFragment baseFragment, final Bundle bundle, final TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$292$MessagesController(alertDialog, tLObject, baseFragment, bundle);
}
});
}
}
public void lambda$null$292$MessagesController(AlertDialog alertDialog, TLObject tLObject, BaseFragment baseFragment, Bundle bundle) {
try {
alertDialog.dismiss();
} catch (Exception e) {
FileLog.e(e);
}
TLRPC.messages_Messages messages_messages = (TLRPC.messages_Messages) tLObject;
putUsers(messages_messages.users, false);
putChats(messages_messages.chats, false);
getMessagesStorage().putUsersAndChats(messages_messages.users, messages_messages.chats, true, true);
baseFragment.presentFragment(new ChatActivity(bundle), true);
}
public void lambda$checkCanOpenChat$294$MessagesController(int i, BaseFragment baseFragment, DialogInterface dialogInterface) {
getConnectionsManager().cancelRequest(i, true);
if (baseFragment != null) {
baseFragment.setVisibleDialog(null);
}
}
public static void openChatOrProfileWith(TLRPC.User user, TLRPC.Chat chat, BaseFragment baseFragment, int i, boolean z) {
if ((user == null && chat == null) || baseFragment == null) {
return;
}
String str = null;
if (chat != null) {
str = getRestrictionReason(chat.restriction_reason);
} else if (user != null) {
str = getRestrictionReason(user.restriction_reason);
if (user.bot) {
i = 1;
z = true;
}
}
if (str != null) {
showCantOpenAlert(baseFragment, str);
return;
}
Bundle bundle = new Bundle();
if (chat != null) {
bundle.putInt("chat_id", chat.id);
} else {
bundle.putInt("user_id", user.id);
}
if (i == 0) {
baseFragment.presentFragment(new ProfileActivity(bundle));
} else if (i == 2) {
baseFragment.presentFragment(new ChatActivity(bundle), true, true);
} else {
baseFragment.presentFragment(new ChatActivity(bundle), z);
}
}
public void openByUserName(String str, BaseFragment baseFragment, int i) {
openByUserName(str, baseFragment, i, false);
}
public void openByUserName(String str, final BaseFragment baseFragment, final int i, final boolean z) {
TLRPC.Chat chat;
TLRPC.User user;
if (str == null || baseFragment == null) {
return;
}
TLObject userOrChat = getUserOrChat(str);
if (userOrChat instanceof TLRPC.User) {
user = (TLRPC.User) userOrChat;
if (!user.min) {
chat = null;
}
user = null;
chat = null;
} else {
if (userOrChat instanceof TLRPC.Chat) {
TLRPC.Chat chat2 = (TLRPC.Chat) userOrChat;
if (!chat2.min) {
chat = chat2;
user = null;
}
}
user = null;
chat = null;
}
if (user != null) {
openChatOrProfileWith(user, null, baseFragment, i, z);
return;
}
if (chat != null) {
openChatOrProfileWith(null, chat, baseFragment, 1, z);
return;
}
if (baseFragment.getParentActivity() == null) {
return;
}
final AlertDialog[] alertDialogArr = {new AlertDialog(baseFragment.getParentActivity(), 3)};
TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
tL_contacts_resolveUsername.username = str;
final int sendRequest = getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$openByUserName$296$MessagesController(alertDialogArr, baseFragment, z, i, tLObject, tL_error);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$openByUserName$298$MessagesController(alertDialogArr, sendRequest, baseFragment);
}
}, 500L);
}
public void lambda$openByUserName$296$MessagesController(final AlertDialog[] alertDialogArr, final BaseFragment baseFragment, final boolean z, final int i, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$295$MessagesController(alertDialogArr, baseFragment, tL_error, tLObject, z, i);
}
});
}
public void lambda$null$295$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, TLRPC.TL_error tL_error, TLObject tLObject, boolean z, int i) {
try {
alertDialogArr[0].dismiss();
} catch (Exception unused) {
}
alertDialogArr[0] = null;
baseFragment.setVisibleDialog(null);
if (tL_error == null) {
TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
putUsers(tL_contacts_resolvedPeer.users, false);
putChats(tL_contacts_resolvedPeer.chats, false);
getMessagesStorage().putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, false, true);
if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
openChatOrProfileWith(null, tL_contacts_resolvedPeer.chats.get(0), baseFragment, 1, z);
return;
} else {
if (tL_contacts_resolvedPeer.users.isEmpty()) {
return;
}
if (!tL_contacts_resolvedPeer.users.get(0).contact) {
baseFragment.presentFragment(new AddContactsInfoActivity(null, tL_contacts_resolvedPeer.users.get(0)));
return;
} else {
openChatOrProfileWith(tL_contacts_resolvedPeer.users.get(0), null, baseFragment, i, z);
return;
}
}
}
if (baseFragment == null || baseFragment.getParentActivity() == null) {
return;
}
if (i == 0) {
ToastUtils.show(R.string.NoUsernameFound);
} else {
AlertsCreator.createSimpleAlert(baseFragment.getParentActivity(), LocaleController.getString("JoinToGroupErrorNotExist", R.string.JoinToGroupErrorNotExist)).show();
}
}
public void lambda$openByUserName$298$MessagesController(AlertDialog[] alertDialogArr, final int i, BaseFragment baseFragment) {
if (alertDialogArr[0] == null) {
return;
}
alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
MessagesController.this.lambda$null$297$MessagesController(i, dialogInterface);
}
});
baseFragment.showDialog(alertDialogArr[0]);
}
public void lambda$null$297$MessagesController(int i, DialogInterface dialogInterface) {
getConnectionsManager().cancelRequest(i, true);
}
public void openByUserName(String str, final BaseFragment baseFragment, final TLRPC.Chat chat, final boolean z) {
TLRPC.Chat chat2;
TLRPC.User user;
if (str == null || baseFragment == null) {
return;
}
if (!ChatObject.canSendEmbed(chat)) {
ToastUtils.show(R.string.ForbidViewUserAndGroupInfoTips);
return;
}
TLObject userOrChat = getUserOrChat(str);
if (userOrChat instanceof TLRPC.User) {
user = (TLRPC.User) userOrChat;
if (!user.min) {
chat2 = null;
}
user = null;
chat2 = null;
} else {
if (userOrChat instanceof TLRPC.Chat) {
TLRPC.Chat chat3 = (TLRPC.Chat) userOrChat;
if (!chat3.min) {
chat2 = chat3;
user = null;
}
}
user = null;
chat2 = null;
}
boolean z2 = false;
if (user == null) {
if (chat2 != null) {
openChatOrProfileWith(null, chat2, baseFragment, 1, z);
return;
}
if (baseFragment.getParentActivity() == null) {
return;
}
final AlertDialog[] alertDialogArr = {new AlertDialog(baseFragment.getParentActivity(), 3)};
TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
tL_contacts_resolveUsername.username = str;
final int sendRequest = getConnectionsManager().sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$openByUserName$300$MessagesController(alertDialogArr, baseFragment, z, chat, tLObject, tL_error);
}
});
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$openByUserName$302$MessagesController(alertDialogArr, sendRequest, baseFragment);
}
}, 500L);
return;
}
if (!user.self && chat != null && !ChatObject.hasAdminRights(chat) && chat.megagroup && (chat.flags & ConnectionsManager.FileTypeVideo) != 0 && !user.mutual_contact) {
ToastUtils.show(R.string.ForbidViewUserInfoTips);
return;
}
if (user.contact) {
Bundle bundle = new Bundle();
bundle.putInt("user_id", user.id);
if (chat != null) {
if (chat.megagroup && (33554432 & chat.flags) != 0) {
z2 = true;
}
bundle.putBoolean("forbid_add_contact", z2);
bundle.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
}
baseFragment.presentFragment(new NewProfileActivity(bundle));
return;
}
Bundle bundle2 = new Bundle();
bundle2.putInt("user_id", user.id);
if (chat != null) {
if (chat.megagroup && (33554432 & chat.flags) != 0) {
z2 = true;
}
bundle2.putBoolean("forbid_add_contact", z2);
bundle2.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
}
bundle2.putInt("from_type", 2);
baseFragment.presentFragment(new NewProfileActivity(bundle2));
}
public void lambda$openByUserName$300$MessagesController(final AlertDialog[] alertDialogArr, final BaseFragment baseFragment, final boolean z, final TLRPC.Chat chat, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$299$MessagesController(alertDialogArr, baseFragment, tL_error, tLObject, z, chat);
}
});
}
public void lambda$null$299$MessagesController(AlertDialog[] alertDialogArr, BaseFragment baseFragment, TLRPC.TL_error tL_error, TLObject tLObject, boolean z, TLRPC.Chat chat) {
boolean z2 = false;
try {
alertDialogArr[0].dismiss();
} catch (Exception unused) {
}
alertDialogArr[0] = null;
baseFragment.setVisibleDialog(null);
if (tL_error == null) {
TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
putUsers(tL_contacts_resolvedPeer.users, false);
putChats(tL_contacts_resolvedPeer.chats, false);
getMessagesStorage().putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, true, true);
if (!tL_contacts_resolvedPeer.chats.isEmpty()) {
openChatOrProfileWith(null, tL_contacts_resolvedPeer.chats.get(0), baseFragment, 1, z);
return;
}
if (tL_contacts_resolvedPeer.users.isEmpty()) {
return;
}
TLRPC.User user = tL_contacts_resolvedPeer.users.get(0);
if (!user.self && chat != null && !ChatObject.hasAdminRights(chat) && chat.megagroup && (chat.flags & ConnectionsManager.FileTypeVideo) != 0 && !user.mutual_contact) {
ToastUtils.show(R.string.ForbidViewUserInfoTips);
return;
}
Bundle bundle = new Bundle();
bundle.putInt("user_id", user.id);
if (chat != null) {
if (chat.megagroup && (chat.flags & ConnectionsManager.FileTypeVideo) != 0) {
z2 = true;
}
bundle.putBoolean("forbid_add_contact", z2);
bundle.putBoolean("has_admin_right", ChatObject.hasAdminRights(chat));
}
bundle.putInt("from_type", 2);
baseFragment.presentFragment(new NewProfileActivity(bundle));
return;
}
if (baseFragment == null || baseFragment.getParentActivity() == null) {
return;
}
try {
ToastUtils.show(R.string.NoUsernameFound);
} catch (Exception e) {
FileLog.e(e);
}
}
public void lambda$openByUserName$302$MessagesController(AlertDialog[] alertDialogArr, final int i, BaseFragment baseFragment) {
if (alertDialogArr[0] == null) {
return;
}
alertDialogArr[0].setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public final void onCancel(DialogInterface dialogInterface) {
MessagesController.this.lambda$null$301$MessagesController(i, dialogInterface);
}
});
baseFragment.showDialog(alertDialogArr[0]);
}
public void lambda$null$301$MessagesController(int i, DialogInterface dialogInterface) {
getConnectionsManager().cancelRequest(i, true);
}
public void saveContactsAppliesId(int i) {
this.mainPreferences.edit().putInt("contacts_apply_id", i).apply();
}
public void saveContactsAppliesDate(int i) {
this.mainPreferences.edit().putInt("last_contacts_get_diff", i).apply();
}
public void saveContactsAppliesHash(long j) {
this.mainPreferences.edit().putLong("contacts_apply_hash", j).apply();
}
public void handleUpdatesContactsApply(int i) {
if (i <= 0) {
this.mainPreferences.edit().putInt("contacts_apply_count", 0).apply();
} else {
this.mainPreferences.edit().putInt("contacts_apply_count", i).apply();
}
}
public void getContactsApplyDifferenceV2(boolean z, boolean z2) {
getContactsApplyDifferenceV2(z, false, z2);
}
public void getContactsApplyDifferenceV2(final boolean z, boolean z2, boolean z3) {
if (this.contactsGetDiff) {
return;
}
this.contactsGetDiff = true;
int i = this.mainPreferences.getInt("contacts_apply_id", -1);
int i2 = this.mainPreferences.getInt("last_contacts_get_diff", 0);
long j = this.mainPreferences.getLong("contacts_apply_hash", 0L);
TLRPCContacts.GetContactAppliesDifferenceV2 getContactAppliesDifferenceV2 = new TLRPCContacts.GetContactAppliesDifferenceV2();
getContactAppliesDifferenceV2.apply_id = z ? -1 : i;
getContactAppliesDifferenceV2.total_limit = 100;
getContactAppliesDifferenceV2.date = i2;
getContactAppliesDifferenceV2.hash = z2 ? 0L : j;
getConnectionsManager().sendRequest(getContactAppliesDifferenceV2, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
MessagesController.this.lambda$getContactsApplyDifferenceV2$306$MessagesController(z, tLObject, tL_error);
}
});
}
public void lambda$getContactsApplyDifferenceV2$306$MessagesController(boolean z, TLObject tLObject, TLRPC.TL_error tL_error) {
this.contactsGetDiff = false;
if (tL_error == null) {
final TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2 = (TLRPCContacts.ContactsAppiesDifferenceV2) tLObject;
if (contactsAppiesDifferenceV2 instanceof TLRPCContacts.HC_contacts_apply_notModified) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$303$MessagesController();
}
});
return;
}
if (contactsAppiesDifferenceV2 instanceof TLRPCContacts.HC_contacts_apply_differenceSlice_v2) {
getMessagesController().putUsers(contactsAppiesDifferenceV2.users, false);
ArrayList arrayList = new ArrayList();
for (int i = 0; i < contactsAppiesDifferenceV2.otherUpdates.size(); i++) {
TLRPC.Update update = contactsAppiesDifferenceV2.otherUpdates.get(i);
if (update instanceof TLRPCContacts.UpdateContactApplyRequested) {
TLRPCContacts.UpdateContactApplyRequested updateContactApplyRequested = (TLRPCContacts.UpdateContactApplyRequested) update;
if (updateContactApplyRequested.apply_info.from_peer.user_id != getUserConfig().clientUserId) {
arrayList.add(updateContactApplyRequested.apply_info);
}
}
}
getContactsApplyDifferenceV2(false, true);
if (BuildVars.LOGS_ENABLED) {
FileLog.e("------------> slice response");
}
if (arrayList.size() <= 0 || !BuildVars.LOGS_ENABLED) {
return;
}
FileLog.e("------------> infos.size() :" + arrayList.size());
return;
}
final ArrayList arrayList2 = new ArrayList();
getMessagesController().putUsers(contactsAppiesDifferenceV2.users, false);
for (int i2 = 0; i2 < contactsAppiesDifferenceV2.otherUpdates.size(); i2++) {
TLRPC.Update update2 = contactsAppiesDifferenceV2.otherUpdates.get(i2);
if (update2 instanceof TLRPCContacts.UpdateContactApplyRequested) {
TLRPCContacts.UpdateContactApplyRequested updateContactApplyRequested2 = (TLRPCContacts.UpdateContactApplyRequested) update2;
if (updateContactApplyRequested2.apply_info.from_peer.user_id != getUserConfig().clientUserId) {
arrayList2.add(updateContactApplyRequested2.apply_info);
}
}
}
if (arrayList2.size() > 0) {
handleUpdatesContactsApply(contactsAppiesDifferenceV2.state.unread_count);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$304$MessagesController(contactsAppiesDifferenceV2, arrayList2);
}
});
} else {
handleUpdatesContactsApply(contactsAppiesDifferenceV2.state.unread_count);
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
MessagesController.this.lambda$null$305$MessagesController(contactsAppiesDifferenceV2);
}
});
}
saveContactsAppliesId(contactsAppiesDifferenceV2.state.apply_id);
saveContactsAppliesHash(contactsAppiesDifferenceV2.hash);
}
}
public void lambda$null$303$MessagesController() {
getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, 0);
}
public void lambda$null$304$MessagesController(TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2, ArrayList arrayList) {
getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, Integer.valueOf(contactsAppiesDifferenceV2.state.unread_count));
getNotificationCenter().postNotificationName(NotificationCenter.contactApplieReceived, arrayList, contactsAppiesDifferenceV2.users);
}
public void lambda$null$305$MessagesController(TLRPCContacts.ContactsAppiesDifferenceV2 contactsAppiesDifferenceV2) {
getNotificationCenter().postNotificationName(NotificationCenter.contactApplyUpdateCount, Integer.valueOf(contactsAppiesDifferenceV2.state.unread_count));
}
}