Skip to content

Commit 0a2b025

Browse files
committed
Fixes
1 parent a7084b2 commit 0a2b025

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

tools/gen_filerefmap.php

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,19 @@ public function __construct(
3030
$this->methodsOfType = $methodsOfType;
3131
}
3232

33-
public function getConstructorsOfType(string $type, bool $methods, bool $ignoreEmpty = false): array
33+
public function getConstructorsOfType(string $type, bool $ignoreEmpty = false): array
3434
{
35-
$t = $methods ? ($this->methodsOfType[$type] ?? []) : ($this->constructorsOfType[$type] ?? []);
36-
$methods = $methods ? 'methods' : 'constructors';
35+
$t = $this->constructorsOfType[$type] ?? [];
3736
if (!$ignoreEmpty) {
38-
Assert::notEmpty($t, "No {$methods} found for type: $type");
37+
Assert::notEmpty($t, "No constructors found for type: $type");
38+
}
39+
return $t;
40+
}
41+
public function getMethodsOfType(string $type, bool $ignoreEmpty = false): array
42+
{
43+
$t = $this->methodsOfType[$type] ?? [];
44+
if (!$ignoreEmpty) {
45+
Assert::notEmpty($t, "No methods found for type: $type");
3946
}
4047
return $t;
4148
}
@@ -96,8 +103,8 @@ public function getTypeAtPosition(SimpleExtractorOp $_path): string
96103
$hadFlag = false;
97104
do {
98105
if ($realType !== null
99-
&& !isset($this->tl->getConstructorsOfType($realType, true, true)[$path[$idx]])
100-
&& !isset($this->tl->getConstructorsOfType($realType, false, true)[$path[$idx]])
106+
&& !isset($this->tl->getConstructorsOfType($realType, true)[$path[$idx]])
107+
&& !isset($this->tl->getMethodsOfType($realType, true)[$path[$idx]])
101108
) {
102109
throw new AssertionError("{$path[$idx]} is NOT a constructor of type $type, path: " . json_encode($path));
103110
}
@@ -794,7 +801,7 @@ public function build(TLContext $tl): array
794801
$TL = new TLWrapper($TL);
795802
$locations = [];
796803

797-
foreach ($TL->getConstructorsOfType('Message', false) as $constructor => $_) {
804+
foreach ($TL->getConstructorsOfType('Message') as $constructor => $_) {
798805
if ($constructor === 'messageEmpty') {
799806
continue;
800807
}
@@ -870,7 +877,7 @@ public function build(TLContext $tl): array
870877
]
871878
);
872879
$locations['help.getPremiumPromo'][] = new CopyMethodCallOp('help.getPremiumPromo');
873-
foreach ($TL->getConstructorsOfType('payments.StarsStatus', true) as $method => $_) {
880+
foreach ($TL->getMethodsOfType('payments.StarsStatus') as $method => $_) {
874881
$locations['starsTransaction'][] = new CallOp(
875882
'payments.getStarsTransactionsByID',
876883
[
@@ -962,10 +969,10 @@ public function build(TLContext $tl): array
962969
foreach (['account.savedRingtones', 'account.savedRingtoneConverted', 'account.uploadRingtone'] as $c) {
963970
$locations[$c][] = new CallOp('account.getSavedRingtones', ['hash' => new LiteralOp('long', 0)]);
964971
}
965-
$locations['recentMeUrlChatInvite'][] = new CallOp(
966-
'messages.checkChatInvite',
967-
['hash' => new ExtractFromHereOp(['recentMeUrlChatInvite', 'url'])],
968-
);
972+
973+
$locations['recentMeUrlChatInvite'][] = new Noop('Do not store references based on chat invite links');
974+
$locations['messages.checkChatInvite'][] = new Noop('Do not store references based on chat invite links');
975+
969976
$locations['messages.availableEffects'][] = new CallOp(
970977
'messages.getAvailableEffects',
971978
['hash' => new LiteralOp('int', 0)],
@@ -1017,6 +1024,7 @@ public function build(TLContext $tl): array
10171024
$locations['messages.getPreparedInlineMessage'][]= new Noop('Inline bot results are ephemeral');
10181025

10191026
$locations['messages.uploadMedia'][]= new Noop('A freshly uploaded media file will obtain a context only once it is sent to a chat');
1027+
$locations['messages.uploadImportedMedia'][]= new Noop('A freshly uploaded media file will obtain a context only once it is sent to a chat');
10201028

10211029
$locations['document'][] = new CallOp(
10221030
'messages.getStickerSet',
@@ -1032,7 +1040,7 @@ public function build(TLContext $tl): array
10321040

10331041
// Ignore these for now
10341042
foreach (['payments.ResaleStarGifts', 'payments.StarGiftUpgradePreview', 'StarGift'] as $type) {
1035-
foreach ($TL->getConstructorsOfType($type, false) as $constructor => $_) {
1043+
foreach ($TL->getConstructorsOfType($type) as $constructor => $_) {
10361044
$locations[$constructor][] = new Noop('Contexts for star gifts are not yet implemented');
10371045
}
10381046
}
@@ -1062,7 +1070,7 @@ public function build(TLContext $tl): array
10621070
$param['type'] === $type ||
10631071
(
10641072
isset($param['subtype'])
1065-
&& "Vector<{$param['subtype']}>" === $type
1073+
&& $param['subtype'] === $type
10661074
)
10671075
)) {
10681076
$stack[$posName] = $param['name'];
@@ -1075,25 +1083,17 @@ public function build(TLContext $tl): array
10751083
}
10761084
unset($stackTypes[$t]);
10771085
}
1078-
unset($stack[$pos], $stack[$posName]);
1079-
1080-
if (!$found) {
1081-
foreach ($TL->getConstructorsOfType($type, true, true) as $method => $data) {
1082-
$stack[$posName] = '';
1083-
$stack[$pos] = $method;
1084-
$onStackEnd($stack);
1085-
}
1086-
foreach ($TL->getConstructorsOfType("Vector<$type>", true, true) as $method => $data) {
1087-
$stack[$posName] = '';
1088-
$stack[$pos] = $method;
1089-
$onStackEnd($stack);
1090-
}
1091-
unset($stack[$posName], $stack[$pos]);
1092-
1093-
} elseif ($type === 'Update') {
1086+
foreach ($TL->getMethodsOfType($type, true) as $method => $data) {
1087+
$stack[$posName] = '';
1088+
$stack[$pos] = $method;
10941089
$onStackEnd($stack);
10951090
}
1096-
1091+
foreach ($TL->getMethodsOfType("Vector<$type>", true) as $method => $data) {
1092+
$stack[$posName] = '';
1093+
$stack[$pos] = $method;
1094+
$onStackEnd($stack);
1095+
}
1096+
unset($stack[$posName], $stack[$pos]);
10971097
};
10981098

10991099
$fileRefs = ['Document' => 'document', 'Photo' => 'photo'];

0 commit comments

Comments
 (0)