-
-
Notifications
You must be signed in to change notification settings - Fork 734
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implemented phone verification (only get) and 50 MiB file limit for nitro accounts #445
Changes from all commits
3de70f4
c228a8d
7dfc8e7
7304622
da3d46a
d334009
64c2ce7
017dae7
5580542
341409e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,54 @@ public interface SelfUser extends User | |
*/ | ||
String getEmail() throws AccountTypeException; | ||
|
||
/** | ||
* Shows whether there has ever been a mobile app connected to this account. | ||
* <br><b>NOTE:</b> this is a {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT} method only! | ||
* | ||
* @throws AccountTypeException | ||
* If this method is called when {@link net.dv8tion.jda.core.JDA#getAccountType() JDA#getAccountType()} does not return | ||
* {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}. E.g: If the logged in account isn't a Client account! | ||
* | ||
* @return {@code true} if the account is linked with a mobile app, otherwise {@code false} | ||
*/ | ||
boolean isMobile() throws AccountTypeException; | ||
|
||
/** | ||
* The Discord Nitro status of this account. | ||
* <br><b>NOTE:</b> this is a {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT} method only! | ||
* | ||
* @throws AccountTypeException | ||
* If this method is called when {@link net.dv8tion.jda.core.JDA#getAccountType() JDA#getAccountType()} does not return | ||
* {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}. E.g: If the logged in account isn't a Client account! | ||
* | ||
* @return The Discord Nitro status of the currently logged in account. | ||
*/ | ||
boolean isNitro() throws AccountTypeException; | ||
|
||
/** | ||
* Used to get the phone number of the currently logged in account if a phone number has been attached to it. | ||
* <br><b>NOTE:</b> this is a {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT} method only! | ||
* | ||
* @throws AccountTypeException | ||
* If this method is called when {@link net.dv8tion.jda.core.JDA#getAccountType() JDA#getAccountType()} does not return | ||
* {@link net.dv8tion.jda.core.AccountType#CLIENT AccountType.CLIENT}. E.g: If the logged in account isn't a Client account! | ||
* | ||
* @return The phone of the currently logged in account or null if there's no number associated | ||
*/ | ||
String getPhoneNumber() throws AccountTypeException; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do you specifically throw an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I chose this because we already have the same be behavior for |
||
|
||
/** | ||
* Returns the maximum size for files that can be uploaded with this account. | ||
* <br>Returns {@value net.dv8tion.jda.core.entities.Message#MAX_FILE_SIZE} for bots and non-nitro client accounts | ||
* and {@value net.dv8tion.jda.core.entities.Message#MAX_FILE_SIZE_NITRO} for client accounts with a active nitro subscription. | ||
* | ||
* @return The maximum size for files that can be uploaded with this account | ||
* | ||
* @see net.dv8tion.jda.core.entities.Message#MAX_FILE_SIZE | ||
* @see net.dv8tion.jda.core.entities.Message#MAX_FILE_SIZE_NITRO | ||
*/ | ||
long getAllowedFileSize(); | ||
|
||
/** | ||
* The {@link net.dv8tion.jda.core.managers.AccountManager AccountManager} | ||
* for the currently logged in account. | ||
|
@@ -73,16 +121,4 @@ public interface SelfUser extends User | |
* @return An AccountManagerUpdatable instance for the current account | ||
*/ | ||
AccountManagerUpdatable getManagerUpdatable(); | ||
|
||
// /** | ||
// * Creates a OAuth invite-link used to invite bot-accounts.<br> | ||
// * This is literally just a shortcut to | ||
// * {@link net.dv8tion.jda.utils.ApplicationUtil#getAuthInvite(net.dv8tion.jda.JDA, net.dv8tion.jda.Permission...) ApplicationUtil.getAuthInvite(JDA, Permission...)} | ||
// * | ||
// * @param perms | ||
// * Possibly empty list of Permissions that should be requested via invite | ||
// * @return | ||
// * The link used to invite the bot | ||
// */ | ||
// String getAuthUrl(Permission... perms); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -516,20 +516,28 @@ public boolean checkVerification() | |
return true; | ||
if(canSendVerification) | ||
return true; | ||
|
||
if (api.getSelfUser().getPhoneNumber() != null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MinnDevelopment @Sanduhr32 is this what you mean? edit: I hate these snippets... |
||
return canSendVerification = true; | ||
|
||
switch (verificationLevel) | ||
{ | ||
case VERY_HIGH: | ||
break; // we already checked for a verified phone number | ||
case HIGH: | ||
if(ChronoUnit.MINUTES.between(getSelfMember().getJoinDate(), OffsetDateTime.now()) < 10) | ||
if (ChronoUnit.MINUTES.between(getSelfMember().getJoinDate(), OffsetDateTime.now()) < 10) | ||
break; | ||
case MEDIUM: | ||
if(ChronoUnit.MINUTES.between(MiscUtil.getCreationTime(api.getSelfUser()), OffsetDateTime.now()) < 5) | ||
if (ChronoUnit.MINUTES.between(MiscUtil.getCreationTime(api.getSelfUser()), OffsetDateTime.now()) < 5) | ||
break; | ||
case LOW: | ||
if(!api.getSelfUser().isVerified()) | ||
if (!api.getSelfUser().isVerified()) | ||
break; | ||
case NONE: | ||
canSendVerification = true; | ||
return true; | ||
case UNKNOWN: | ||
return true; // try and let discord decide | ||
} | ||
return false; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2015-2017 Austin Keener & Michael Ritter & Florian Spieß | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package net.dv8tion.jda.core.events.self; | ||
|
||
import net.dv8tion.jda.core.JDA; | ||
|
||
/** | ||
* <b><u>SelfUpdateMobileEvent</u></b><br> | ||
* Fired if you login to your discord account with a mobile device for the first time.<br> | ||
*/ | ||
public class SelfUpdateMobileEvent extends GenericSelfUpdateEvent | ||
{ | ||
private final boolean wasMobile; | ||
|
||
public SelfUpdateMobileEvent(JDA api, long responseNumber, boolean wasMobile) | ||
{ | ||
super(api, responseNumber); | ||
this.wasMobile = wasMobile; | ||
} | ||
|
||
/** | ||
* Returns the old mobile status. <i>Should</i> always be {@code false}. | ||
* | ||
* @return The mobile status. | ||
*/ | ||
public boolean wasMobile() | ||
{ | ||
return wasMobile; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't really consistent you are calling your Boolean premium to check if user is a Nitro users but here you are calling you constant MAX_FILE_SIZE_NITRO instead of MAX_FILE_SIZE_PREMIUM. I'd say either rename the Boolean to nitro or rename this constant.