@@ -1022,6 +1022,10 @@ public function build(TLContext $tl): array
10221022 $ found = false ;
10231023 foreach ([...$ TL ->getConstructors ()->by_id , ...$ TL ->getMethods ()->by_id ] as $ constructor ) {
10241024 $ predicate = $ constructor ['predicate ' ] ?? $ constructor ['method ' ];
1025+ if ($ predicate === 'updateShortMessage ' || $ predicate === 'updateShortChatMessage ' || $ predicate === 'updateShortSentMessage ' ) {
1026+ // Assume these are converted to message constructors by the client.
1027+ continue ;
1028+ }
10251029 $ t = $ constructor ['type ' ];
10261030 if (isset ($ stackTypes [$ t ])) {
10271031 continue ;
@@ -1036,22 +1040,22 @@ public function build(TLContext $tl): array
10361040 $ stack [$ pos ] = $ predicate ;
10371041 $ recurse ($ onStackEnd , $ t , $ stack , $ stackTypes );
10381042 $ found = true ;
1039- unset($ stack [$ pos ]);
1040- unset( $ stack [ $ posName ]);
1043+ unset($ stack [$ pos ], $ stack [ $ posName ] );
1044+
10411045 }
10421046 }
10431047 unset($ stackTypes [$ t ]);
10441048 }
1045- unset($ stack [$ pos ]);
1046- unset( $ stack [ $ posName ]);
1049+ unset($ stack [$ pos ], $ stack [ $ posName ] );
1050+
10471051 if (!$ found ) {
10481052 foreach (TLContext::getConstructorsOfType ($ TL , $ type , true , true ) as $ method => $ data ) {
10491053 $ stack [$ posName ] = '' ;
10501054 $ stack [$ pos ] = $ method ;
10511055 $ onStackEnd ($ stack );
10521056 }
1053- unset($ stack [$ posName ]);
1054- unset( $ stack [ $ pos ]);
1057+ unset($ stack [$ posName ], $ stack [ $ pos ] );
1058+
10551059 } elseif ($ type === 'Update ' ) {
10561060 $ onStackEnd ($ stack );
10571061 }
@@ -1111,17 +1115,16 @@ public function build(TLContext $tl): array
11111115 $ stackTypes = [$ type => true ];
11121116 $ recurse (
11131117 static function (array $ stack ) use ($ locations , $ TL , &$ normalizedLocations ): void {
1114- if (array_intersect (
1115- [
1116- 'updateShortSentMessage ' ,
1117- 'updateShortMessage ' ,
1118- 'updateShortChatMessage ' ,
1119- ],
1120- $ stack ,
1121- )
1118+ if (count ($ stack ) >= 5 &&
1119+ $ stack [count ($ stack )-1 ] === 'messages.getWebPagePreview ' &&
1120+ $ stack [count ($ stack )-2 ] === '' &&
1121+ $ stack [count ($ stack )-3 ] === 'messages.webPagePreview ' &&
1122+ $ stack [count ($ stack )-4 ] === 'media ' &&
1123+ $ stack [count ($ stack )-5 ] !== 'messageMediaWebPage '
11221124 ) {
11231125 return ;
11241126 }
1127+
11251128 $ slice = [];
11261129 $ had = false ;
11271130 $ top = end ($ stack );
@@ -1153,4 +1156,4 @@ static function (array $stack) use ($locations, $TL, &$normalizedLocations): voi
11531156 );
11541157}
11551158
1156- var_dump ($ normalizedLocations );
1159+ var_dump ($ normalizedLocations );
0 commit comments