mirror of
https://github.com/wiz0u/WTelegramClient.git
synced 2025-12-06 06:52:01 +01:00
Try to improve diagnostics/handling of weird email login case (#331)
This commit is contained in:
parent
5f411d45f9
commit
a9bbdb9fc4
|
|
@ -36,9 +36,10 @@ namespace WTelegram
|
||||||
var client = await GetClientForDC(-_dcSession.DcID, true);
|
var client = await GetClientForDC(-_dcSession.DcID, true);
|
||||||
using (stream)
|
using (stream)
|
||||||
{
|
{
|
||||||
|
const long SMALL_FILE_MAX_SIZE = 10 << 20;
|
||||||
bool hasLength = stream.CanSeek;
|
bool hasLength = stream.CanSeek;
|
||||||
long transmitted = 0, length = hasLength ? stream.Length : -1;
|
long transmitted = 0, length = hasLength ? stream.Length : -1;
|
||||||
bool isBig = !hasLength || length >= 10 * 1024 * 1024;
|
bool isBig = !hasLength || length > SMALL_FILE_MAX_SIZE;
|
||||||
int file_total_parts = hasLength ? (int)((length - 1) / FilePartSize) + 1 : -1;
|
int file_total_parts = hasLength ? (int)((length - 1) / FilePartSize) + 1 : -1;
|
||||||
long file_id = Helpers.RandomLong();
|
long file_id = Helpers.RandomLong();
|
||||||
int file_part = 0, read;
|
int file_part = 0, read;
|
||||||
|
|
|
||||||
|
|
@ -1238,10 +1238,13 @@ namespace WTelegram
|
||||||
if (verified is Account_EmailVerifiedLogin verifiedLogin) // (it should always be)
|
if (verified is Account_EmailVerifiedLogin verifiedLogin) // (it should always be)
|
||||||
sentCodeBase = verifiedLogin.sent_code;
|
sentCodeBase = verifiedLogin.sent_code;
|
||||||
}
|
}
|
||||||
|
RaiseUpdates(sentCodeBase);
|
||||||
}
|
}
|
||||||
resent:
|
resent:
|
||||||
if (sentCodeBase is Auth_SentCodeSuccess success)
|
if (sentCodeBase is Auth_SentCodeSuccess success)
|
||||||
authorization = success.authorization;
|
authorization = success.authorization;
|
||||||
|
else if (sentCodeBase is Auth_SentCodePaymentRequired paymentRequired)
|
||||||
|
throw new WTException("Auth_SentCodePaymentRequired unsupported");
|
||||||
else if (sentCodeBase is Auth_SentCode sentCode)
|
else if (sentCodeBase is Auth_SentCode sentCode)
|
||||||
{
|
{
|
||||||
phone_code_hash = sentCode.phone_code_hash;
|
phone_code_hash = sentCode.phone_code_hash;
|
||||||
|
|
@ -1410,7 +1413,7 @@ namespace WTelegram
|
||||||
public User LoginAlreadyDone(Auth_AuthorizationBase authorization)
|
public User LoginAlreadyDone(Auth_AuthorizationBase authorization)
|
||||||
{
|
{
|
||||||
if (authorization is not Auth_Authorization { user: User self })
|
if (authorization is not Auth_Authorization { user: User self })
|
||||||
throw new WTException("Failed to get Authorization: " + authorization.GetType().Name);
|
throw new WTException("Failed to get Authorization: " + authorization?.GetType().Name);
|
||||||
_session.UserId = _dcSession.UserId = self.id;
|
_session.UserId = _dcSession.UserId = self.id;
|
||||||
lock (_session) _session.Save();
|
lock (_session) _session.Save();
|
||||||
RaiseUpdates(self);
|
RaiseUpdates(self);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue