Fixed bugs

This commit is contained in:
Andrea Cavalli 2020-11-04 00:42:33 +01:00
parent ec3b788a72
commit c3802c72d1
3 changed files with 40 additions and 12 deletions

View File

@ -85,7 +85,7 @@ public class PrimaryController {
destItems2.clear(); destItems2.clear();
} else { } else {
boolean added = false; boolean added = false;
if (supergroupInfo.getItem().canRestrictMembers()) { if (supergroupInfo.getItem().canRestrictMembers() || !REMOVE_MEMBERS_FROM_SOURCE_SUPERGROUP) {
if (!srcItems2.contains(supergroupInfo.getItem().getBaseChatInfo())) { if (!srcItems2.contains(supergroupInfo.getItem().getBaseChatInfo())) {
added |= srcItems2.add(supergroupInfo.getItem().getBaseChatInfo()); added |= srcItems2.add(supergroupInfo.getItem().getBaseChatInfo());
} }

View File

@ -28,7 +28,7 @@ public class SettingsServiceImpl implements SettingsService {
this.delayBetweenAdds.set(Duration.ofSeconds(seconds.getAsInt())); this.delayBetweenAdds.set(Duration.ofSeconds(seconds.getAsInt()));
}); });
} }
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
}; };
} }

View File

@ -6,6 +6,7 @@ import it.tdlight.jni.TdApi.AuthorizationStateReady;
import it.tdlight.jni.TdApi.Chat; import it.tdlight.jni.TdApi.Chat;
import it.tdlight.jni.TdApi.ChatMemberStatusAdministrator; import it.tdlight.jni.TdApi.ChatMemberStatusAdministrator;
import it.tdlight.jni.TdApi.ChatMemberStatusCreator; import it.tdlight.jni.TdApi.ChatMemberStatusCreator;
import it.tdlight.jni.TdApi.ChatMemberStatusMember;
import it.tdlight.jni.TdApi.GetSupergroupFullInfo; import it.tdlight.jni.TdApi.GetSupergroupFullInfo;
import it.tdlight.jni.TdApi.Object; import it.tdlight.jni.TdApi.Object;
import it.tdlight.jni.TdApi.Supergroup; import it.tdlight.jni.TdApi.Supergroup;
@ -104,18 +105,35 @@ public class TransferClient {
private Mono<Void> onUpdateSupergroup(Supergroup supergroup) { private Mono<Void> onUpdateSupergroup(Supergroup supergroup) {
// Fast checks to ignore most unwanted infos // Fast checks to ignore most unwanted infos
if (!supergroup.isChannel if (!supergroup.isChannel) {
&& boolean isRelevantSupergroup = false;
(supergroup.status.getConstructor() == ChatMemberStatusAdministrator.CONSTRUCTOR
|| supergroup.status.getConstructor() == ChatMemberStatusCreator.CONSTRUCTOR)) { if (supergroup.status.getConstructor() == ChatMemberStatusAdministrator.CONSTRUCTOR
|| supergroup.status.getConstructor() == ChatMemberStatusCreator.CONSTRUCTOR) {
isRelevantSupergroup = true;
} else if (!StaticSettings.requiresAdminPrivilegesOnSourceSupergroup()) {
switch (supergroup.status.getConstructor()) {
case ChatMemberStatusCreator.CONSTRUCTOR:
case ChatMemberStatusAdministrator.CONSTRUCTOR:
case ChatMemberStatusMember.CONSTRUCTOR:
isRelevantSupergroup = true;
break;
default:
isRelevantSupergroup = false;
break;
}
}
if (isRelevantSupergroup) {
if (supergroupInfos.put(supergroup.id, supergroup) == null) { if (supergroupInfos.put(supergroup.id, supergroup) == null) {
return this
.<SupergroupFullInfo>send(new GetSupergroupFullInfo(supergroup.id)) return this.<SupergroupFullInfo>send(new GetSupergroupFullInfo(supergroup.id))
.filter(TdResult::succeeded) .filter(TdResult::succeeded)
.map(TdResult::result) .map(TdResult::result)
.flatMap(supergroupFullInfo -> onUpdateSupergroupFullInfo(supergroup.id, supergroupFullInfo)); .flatMap(supergroupFullInfo -> onUpdateSupergroupFullInfo(supergroup.id, supergroupFullInfo));
} }
} }
}
return Mono.empty(); return Mono.empty();
} }
@ -165,6 +183,16 @@ public class TransferClient {
var adminStatus = (ChatMemberStatusAdministrator) baseInfo.status; var adminStatus = (ChatMemberStatusAdministrator) baseInfo.status;
var sgInfo = new SupergroupInfo(baseChatInfo, adminStatus.canRestrictMembers, adminStatus.canInviteUsers); var sgInfo = new SupergroupInfo(baseChatInfo, adminStatus.canRestrictMembers, adminStatus.canInviteUsers);
return Optional.of(sgInfo); return Optional.of(sgInfo);
} else if (!StaticSettings.requiresAdminPrivilegesOnSourceSupergroup()) {
switch (baseInfo.status.getConstructor()) {
case ChatMemberStatusCreator.CONSTRUCTOR:
case ChatMemberStatusAdministrator.CONSTRUCTOR:
case ChatMemberStatusMember.CONSTRUCTOR:
var sgInfo = new SupergroupInfo(baseChatInfo, false, false);
return Optional.of(sgInfo);
default:
return Optional.empty();
}
} else { } else {
return Optional.empty(); return Optional.empty();
} }