From 157f54be7ab99b005d2cb58cdbdfcf67938d46f1 Mon Sep 17 00:00:00 2001 From: saiaapiz <29090012+saiaapiz14@users.noreply.github.com> Date: Mon, 7 Oct 2024 18:27:33 +0800 Subject: [PATCH] Resolve Incorrect Update.userId Assignment Referencing issue [#85](https://github.com/celestix/gotgproto/issues/85). The problem arises because Go maps are unordered, and `getDifferent` is called before `fillUserIdFromMessage`. This sequence can lead to an incorrect `userId` being assigned to `Update.userId` due to inconsistent entity processing. Ensuring proper order of operations will resolve this. --- ext/update.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/update.go b/ext/update.go index f24c685..c7695a7 100644 --- a/ext/update.go +++ b/ext/update.go @@ -43,6 +43,7 @@ func GetNewUpdate(ctx context.Context, client *tg.Client, selfUserId int64, p *s case *tg.UpdateNewMessage: m := update.GetMessage() u.EffectiveMessage = types.ConstructMessage(m) + u.fillUserIdFromMessage(selfUserId) diff, err := client.UpdatesGetDifference(ctx, &tg.UpdatesGetDifferenceRequest{ Pts: update.Pts - 1, Date: int(time.Now().Unix()), @@ -70,7 +71,6 @@ func GetNewUpdate(ctx context.Context, client *tg.Client, selfUserId int64, p *s } } } - u.fillUserIdFromMessage(selfUserId) case message.AnswerableMessageUpdate: m := update.GetMessage() u.EffectiveMessage = types.ConstructMessage(m)