Skip to content

Commit

Permalink
feat: support unblock deleted users
Browse files Browse the repository at this point in the history
  • Loading branch information
LiuYi0526 committed May 10, 2024
2 parents 855ada6 + 5ea9c65 commit 07d9a02
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2449,7 +2449,7 @@ public void loadArchivedStickersCount(int type, boolean cache) {
archivedStickersCount[type] = count;
getNotificationCenter().postNotificationName(NotificationCenter.archivedStickersCountDidLoad, type);
}
} else if (getUserConfig().getCurrentUser() != null && !getUserConfig().getCurrentUser().bot) {
} else if (getUserConfig().isClientActivated() && !getUserConfig().getCurrentUser().bot) {
TLRPC.TL_messages_getArchivedStickers req = new TLRPC.TL_messages_getArchivedStickers();
req.limit = 0;
req.masks = type == TYPE_MASK;
Expand Down Expand Up @@ -2830,7 +2830,7 @@ public void loadStickers(int type, boolean cache, boolean force, boolean schedul
}
});
});
} else if(!getUserConfig().getCurrentUser().bot) {
} else if (getUserConfig().isClientActivated() && !getUserConfig().getCurrentUser().bot) {
if (type == TYPE_FEATURED || type == TYPE_FEATURED_EMOJIPACKS) {
final boolean emoji = type == TYPE_FEATURED_EMOJIPACKS;
TLRPC.TL_messages_allStickers response = new TLRPC.TL_messages_allStickers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7751,7 +7751,7 @@ public void getBlockedPeers(boolean reset) {
}));
}

public void unblockAllUsers() {
public void unblockAllUsers(boolean isDeleted, boolean retry) {

if (totalBlockedCount == 0) return;

Expand All @@ -7762,9 +7762,18 @@ public void unblockAllUsers() {
if (blockedCopy.size() == 0) return;

for (int index = 0; index < blockedCopy.size(); index++) {

TLRPC.TL_contacts_unblock req = new TLRPC.TL_contacts_unblock();
long peer_id = blockedCopy.keyAt(index);
if (isDeleted) {
if (peer_id > 0) {
TLRPC.User user = getMessagesController().getUser(peer_id);
if (!UserObject.isDeleted(user)) {
continue;
}
} else {
continue;
}
}
TLRPC.TL_contacts_unblock req = new TLRPC.TL_contacts_unblock();
req.id = getInputPeer(peer_id);
getConnectionsManager().sendRequest(req, (response, error) -> {

Expand All @@ -7779,7 +7788,9 @@ public void unblockAllUsers() {

}

unblockAllUsers();
if (retry) {
unblockAllUsers(isDeleted, isDeleted ? false : retry);
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ private void resetItems() {
return true;
}));
}
if (NekoXConfig.disableStatusUpdate && !UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser().bot) {
if (NekoXConfig.disableStatusUpdate && UserConfig.getInstance(UserConfig.selectedAccount).isClientActivated() && !UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser().bot) {
boolean online = MessagesController.getInstance(UserConfig.selectedAccount).isOnline();
String message = online ? StrUtil.upperFirst(LocaleController.getString("Online", R.string.Online)) : LocaleController.getString("VoipOfflineTitle", R.string.VoipOfflineTitle);
if (NekoXConfig.keepOnlineStatus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30405,7 +30405,7 @@ private void startEditingMessageObject(MessageObject messageObject) {
updatePinnedMessageView(true);
updateVisibleRows();

if (!messageObject.scheduled && !messageObject.isQuickReply() && !getUserConfig().getCurrentUser().bot) {
if (!messageObject.scheduled && !messageObject.isQuickReply() && getUserConfig().isClientActivated() && !getUserConfig().getCurrentUser().bot) {
TLRPC.TL_messages_getMessageEditData req = new TLRPC.TL_messages_getMessageEditData();
req.peer = getMessagesController().getInputPeer(dialog_id);
req.id = messageObject.getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public class PrivacyUsersActivity extends BaseFragment implements NotificationCe
public static final int TYPE_BLOCKED = 1;
public static final int TYPE_FILTER = 2;

private int unblock_all = 1;
private static final int unblockAll = 100;
private static final int unblockDeleted = 101;

public interface PrivacyActivityDelegate {
void didUpdateUserList(ArrayList<Long> ids, boolean added);
Expand Down Expand Up @@ -155,13 +156,27 @@ public View createView(Context context) {
public void onItemClick(int id) {
if (id == -1) {
finishFragment();
} else if (id == unblock_all) {
} else if (id == unblockAll) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("UnblockAll", R.string.UnblockAll));
if (getMessagesController().totalBlockedCount != 0) {
builder.setMessage(LocaleController.getString("UnblockAllWarn", R.string.UnblockAllWarn));
builder.setPositiveButton(LocaleController.getString("UnblockAll", R.string.UnblockAll), (dialog, which) -> {
new Thread(() -> getMessagesController().unblockAllUsers()).start();
new Thread(() -> getMessagesController().unblockAllUsers(false, true)).start();
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
} else {
builder.setMessage(LocaleController.getString("BlockedListEmpty",R.string.BlockedListEmpty));
builder.setPositiveButton(LocaleController.getString("OK",R.string.OK),null);
}
showDialog(builder.create());
} else if (id == unblockDeleted) {
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
builder.setTitle(LocaleController.getString("UnblockDeleted", R.string.UnblockDeleted));
if (getMessagesController().totalBlockedCount != 0) {
builder.setMessage(LocaleController.getString("UnblockDeletedWarn", R.string.UnblockDeletedWarn));
builder.setPositiveButton(LocaleController.getString("UnblockDeleted", R.string.UnblockDeleted), (dialog, which) -> {
new Thread(() -> getMessagesController().unblockAllUsers(true, true)).start();
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null);
} else {
Expand All @@ -179,7 +194,8 @@ public void onItemClick(int id) {

ActionBarMenuItem otherItem = menu.addItem(0, R.drawable.ic_ab_other);
otherItem.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
otherItem.addSubItem(unblock_all, LocaleController.getString("UnblockAll", R.string.UnblockAll));
otherItem.addSubItem(unblockAll, LocaleController.getString("UnblockAll", R.string.UnblockAll));
otherItem.addSubItem(unblockDeleted, LocaleController.getString("UnblockDeleted", R.string.UnblockDeleted));

}

Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values-zh-rCN/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@
<string name="PreviewSendVideo">发送视频</string>
<string name="PreviewSendFile">发送文件</string>
<string name="SentryAnalytics">Sentry 崩溃自动上报</string>
<string name="UnblockDeleted">解禁已删除账号</string>
<string name="UnblockDeletedWarn">您确定要解除屏蔽**所有已删除账号**吗?</string>
</resources>
2 changes: 2 additions & 0 deletions TMessagesProj/src/main/res/values/strings_na.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,6 @@
<string name="PreviewSendVideo">Send Video</string>
<string name="PreviewSendFile">Send File</string>
<string name="SentryAnalytics">Sentry Crash Report</string>
<string name="UnblockDeleted">Unblock Deleted Users</string>
<string name="UnblockDeletedWarn">Are you sure you want to unblock **all deleted users**?</string>
</resources>

0 comments on commit 07d9a02

Please sign in to comment.