From a403a462db53665b465283f963585edaac3b631c Mon Sep 17 00:00:00 2001 From: Wizou Date: Fri, 17 Sep 2021 03:25:27 +0200 Subject: [PATCH] fetch Updates_GetState on session resuming to subscribe to new updates --- src/Client.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index 52627b4..fc3a4c2 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -743,11 +743,19 @@ namespace WTelegram { var prevUser = Schema.Deserialize(_session.User); var userId = _config("user_id"); // if config prefers to validate current user by its id, use it - if (userId != null && int.TryParse(userId, out int id) && (id == -1 || prevUser.id == id)) - return prevUser; - phone_number = Config("phone_number"); // otherwise, validation is done by the phone number - if (prevUser?.phone == string.Concat(phone_number.Where(char.IsDigit))) + if (userId == null || !int.TryParse(userId, out int id) || id != -1 && prevUser.id != id) + { + phone_number = Config("phone_number"); // otherwise, validation is done by the phone number + if (prevUser?.phone != string.Concat(phone_number.Where(char.IsDigit))) + prevUser = null; + } + if (prevUser != null) + { + // TODO: implement a more complete Updates gaps handling system? https://core.telegram.org/api/updates + var udpatesState = await Updates_GetState(); + OnUpdate(udpatesState); return prevUser; + } } catch (Exception ex) {