diff --git a/core/src/main/java/me/mastercapexd/auth/link/telegram/TelegramLinkEntryUser.java b/core/src/main/java/me/mastercapexd/auth/link/telegram/TelegramLinkEntryUser.java deleted file mode 100644 index 5829580f..00000000 --- a/core/src/main/java/me/mastercapexd/auth/link/telegram/TelegramLinkEntryUser.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.mastercapexd.auth.link.telegram; - -import com.bivashy.auth.api.account.Account; -import com.bivashy.auth.api.link.user.info.LinkUserInfo; - -import me.mastercapexd.auth.link.user.entry.BaseLinkEntryUser; - -public class TelegramLinkEntryUser extends BaseLinkEntryUser { - public TelegramLinkEntryUser(Account account, LinkUserInfo linkUserInfo) { - super(TelegramLinkType.getInstance(), account, linkUserInfo); - } - - public TelegramLinkEntryUser(Account account) { - this(account, account.findFirstLinkUserOrNew(TelegramLinkType.LINK_USER_FILTER, TelegramLinkType.getInstance()).getLinkUserInfo()); - } -} diff --git a/core/src/main/java/me/mastercapexd/auth/link/vk/VKLinkEntryUser.java b/core/src/main/java/me/mastercapexd/auth/link/vk/VKLinkEntryUser.java deleted file mode 100644 index f3db4264..00000000 --- a/core/src/main/java/me/mastercapexd/auth/link/vk/VKLinkEntryUser.java +++ /dev/null @@ -1,16 +0,0 @@ -package me.mastercapexd.auth.link.vk; - -import com.bivashy.auth.api.account.Account; -import com.bivashy.auth.api.link.user.info.LinkUserInfo; - -import me.mastercapexd.auth.link.user.entry.BaseLinkEntryUser; - -public class VKLinkEntryUser extends BaseLinkEntryUser { - public VKLinkEntryUser(Account account, LinkUserInfo linkUserInfo) { - super(VKLinkType.getInstance(), account, linkUserInfo); - } - - public VKLinkEntryUser(Account account) { - this(account, account.findFirstLinkUserOrNew(VKLinkType.LINK_USER_FILTER, VKLinkType.getInstance()).getLinkUserInfo()); - } -} diff --git a/core/src/main/java/me/mastercapexd/auth/step/impl/link/MessengerAuthenticationStep.java b/core/src/main/java/me/mastercapexd/auth/step/impl/link/MessengerAuthenticationStep.java index 3b48d04a..982d337c 100644 --- a/core/src/main/java/me/mastercapexd/auth/step/impl/link/MessengerAuthenticationStep.java +++ b/core/src/main/java/me/mastercapexd/auth/step/impl/link/MessengerAuthenticationStep.java @@ -1,5 +1,7 @@ package me.mastercapexd.auth.step.impl.link; +import java.util.function.Predicate; + import com.bivashy.auth.api.AuthPlugin; import com.bivashy.auth.api.account.Account; import com.bivashy.auth.api.config.message.Messages; @@ -15,15 +17,17 @@ import com.bivashy.messenger.common.keyboard.Keyboard; import me.mastercapexd.auth.config.message.server.ServerMessageContext; +import me.mastercapexd.auth.link.user.entry.BaseLinkEntryUser; import me.mastercapexd.auth.step.AuthenticationStepTemplate; public class MessengerAuthenticationStep extends AuthenticationStepTemplate implements MessageableAuthenticationStep { private static final AuthPlugin PLUGIN = AuthPlugin.instance(); private final LinkEntryUser linkEntryUser; - public MessengerAuthenticationStep(String stepName, AuthenticationStepContext authenticationStepContext, LinkEntryUser linkEntryUser) { + public MessengerAuthenticationStep(String stepName, AuthenticationStepContext authenticationStepContext, LinkType linkType, Predicate filter) { super(stepName, authenticationStepContext); - this.linkEntryUser = linkEntryUser; + Account account = authenticationStepContext.getAccount(); + this.linkEntryUser = new BaseLinkEntryUser(linkType, account, account.findFirstLinkUserOrNew(filter, linkType).getLinkUserInfo()); } @Override diff --git a/core/src/main/java/me/mastercapexd/auth/step/impl/link/TelegramLinkAuthenticationStep.java b/core/src/main/java/me/mastercapexd/auth/step/impl/link/TelegramLinkAuthenticationStep.java index 1bdd96b8..8fa12691 100644 --- a/core/src/main/java/me/mastercapexd/auth/step/impl/link/TelegramLinkAuthenticationStep.java +++ b/core/src/main/java/me/mastercapexd/auth/step/impl/link/TelegramLinkAuthenticationStep.java @@ -3,14 +3,14 @@ import com.bivashy.auth.api.step.AuthenticationStep; import com.bivashy.auth.api.step.AuthenticationStepContext; -import me.mastercapexd.auth.link.telegram.TelegramLinkEntryUser; +import me.mastercapexd.auth.link.telegram.TelegramLinkType; import me.mastercapexd.auth.step.creators.AuthenticationStepFactoryTemplate; public class TelegramLinkAuthenticationStep extends MessengerAuthenticationStep { public static final String STEP_NAME = "TELEGRAM_LINK"; public TelegramLinkAuthenticationStep(AuthenticationStepContext context) { - super(STEP_NAME, context, new TelegramLinkEntryUser(context.getAccount())); + super(STEP_NAME, context, TelegramLinkType.getInstance(), TelegramLinkType.LINK_USER_FILTER); } public static class TelegramLinkAuthenticationStepFactory extends AuthenticationStepFactoryTemplate { diff --git a/core/src/main/java/me/mastercapexd/auth/step/impl/link/VKLinkAuthenticationStep.java b/core/src/main/java/me/mastercapexd/auth/step/impl/link/VKLinkAuthenticationStep.java index efee7f23..cf25b031 100644 --- a/core/src/main/java/me/mastercapexd/auth/step/impl/link/VKLinkAuthenticationStep.java +++ b/core/src/main/java/me/mastercapexd/auth/step/impl/link/VKLinkAuthenticationStep.java @@ -3,14 +3,14 @@ import com.bivashy.auth.api.step.AuthenticationStep; import com.bivashy.auth.api.step.AuthenticationStepContext; -import me.mastercapexd.auth.link.vk.VKLinkEntryUser; +import me.mastercapexd.auth.link.vk.VKLinkType; import me.mastercapexd.auth.step.creators.AuthenticationStepFactoryTemplate; public class VKLinkAuthenticationStep extends MessengerAuthenticationStep { public static final String STEP_NAME = "VK_LINK"; public VKLinkAuthenticationStep(AuthenticationStepContext context) { - super(STEP_NAME, context, new VKLinkEntryUser(context.getAccount())); + super(STEP_NAME, context, VKLinkType.getInstance(), VKLinkType.LINK_USER_FILTER); } public static class VKLinkAuthenticationStepFactory extends AuthenticationStepFactoryTemplate {