Skip to content

Commit 897f934

Browse files
committed
Remove all ExtractFromParent usages
1 parent 42951e0 commit 897f934

4 files changed

Lines changed: 104 additions & 16 deletions

File tree

tools/FileRefExtractor/FieldExtractorOp.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ final public function getType(TLContext $tl): string
137137
} elseif (($expectFlag & (self::FLAG_IF_ABSENT_ABORT | self::FLAG_PASSTHROUGH)) !== 0) {
138138
throw new AssertionError("Expected no flag at position $idx, got $expectFlag in path ".json_encode($path));
139139
}
140-
141-
$typeForReturn = isset($param['subtype']) ? "Vector<{$param['subtype']}>" : $param['type'];
142-
$typeForCheck = $param['subtype'] ?? $param['type'];
143-
$isFlag = isset($param['pow']);
144140
break;
145141
}
146142
}

tools/FileRefExtractor/Ops/ExtractFromHereOp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function normalize(array $stack, string $current, bool $ignoreFlag): ?\da
2929
{
3030
$new = [];
3131
foreach ($this->path as $i => $part) {
32-
if ($ignoreFlag && \array_key_exists(2, $part) && $part[2] === null) {
32+
if ($ignoreFlag && \array_key_exists(2, $part) && is_int($part[2]) && ($part[2] & ExtractFromHereOp::FLAG_IF_ABSENT_ABORT)) {
3333
return null;
3434
}
3535
if (isset($part[2]) && $part[2] instanceof TypedOp) {

tools/FileRefExtractor/Ops/ExtractFromParentOp.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function normalize(array $stack, string $current, bool $ignoreFlag): ?\da
3434
}
3535
$new = [];
3636
foreach ($this->path as $i => $part) {
37-
if ($ignoreFlag && \array_key_exists(2, $part) && $part[2] === null) {
37+
if ($ignoreFlag && \array_key_exists(2, $part) && is_int($part[2]) && ($part[2] & ExtractFromHereOp::FLAG_IF_ABSENT_ABORT)) {
3838
return null;
3939
}
4040
if (isset($part[2]) && $part[2] instanceof TypedOp) {

tools/gen_filerefmap.php

Lines changed: 102 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
$locations[$constructor][] = new GetMessageOp(
3636
new ExtractFromHereOp([[$constructor, 'peer_id']]),
3737
new ExtractFromHereOp([[$constructor, 'id']]),
38-
$constructor === 'message' ? new ExtractFromHereOp([[$constructor, 'from_scheduled', ExtractFromParentOp::FLAG_PASSTHROUGH]]) : null,
38+
$constructor === 'message' ? new ExtractFromHereOp([[$constructor, 'from_scheduled', ExtractFromHereOp::FLAG_PASSTHROUGH]]) : null,
3939
);
4040
}
4141

4242
$storyMethods = [];
43-
foreach (['stories.StoryViewsList', 'stories.Stories', 'stories.PeerStories', 'stories.StoryReactionsList'] as $t) {
43+
/*foreach (['stories.StoryViewsList', 'stories.Stories', 'stories.PeerStories', 'stories.StoryReactionsList'] as $t) {
4444
foreach ($TL->getMethodsOfType($t) as $method => $_) {
4545
$storyMethods[$method] = true;
4646
$locations['storyItem'][] = new CallOp(
@@ -51,12 +51,45 @@
5151
]
5252
);
5353
}
54+
}*/
55+
foreach (['stories.Stories'] as $t) {
56+
foreach ($TL->getMethodsOfType($t) as $method => $_) {
57+
$storyMethods[$method] = true;
58+
$locations[$method][] = new CallOp(
59+
'stories.getStoriesByID',
60+
[
61+
'id' => new ArrayOp(new ExtractFromHereOp([
62+
[$method, ''],
63+
['stories.stories', 'stories', ExtractFromHereOp::FLAG_UNPACK_ARRAY],
64+
['storyItem', 'id']
65+
])),
66+
'peer' => new GetInputPeerOp(new ExtractFromHereOp([[$method, 'peer']])),
67+
]
68+
);
69+
}
5470
}
55-
$locations['storyItem'][] = new CallOp(
71+
72+
73+
$locations['storyViewPublicRepost'][] = new CallOp(
5674
'stories.getStoriesByID',
5775
[
58-
'id' => new ArrayOp(new ExtractFromHereOp([['storyItem', 'id']])),
59-
'peer' => new GetInputPeerOp(new ExtractFromParentOp([['peerStories', 'peer']])),
76+
'id' => new ArrayOp(new ExtractFromHereOp([['storyViewPublicRepost', 'story'], ['storyItem', 'id']])),
77+
'peer' => new GetInputPeerOp(new ExtractFromHereOp([['storyViewPublicRepost', 'peer_id']])),
78+
]
79+
);
80+
$locations['storyReactionPublicRepost'][] = new CallOp(
81+
'stories.getStoriesByID',
82+
[
83+
'id' => new ArrayOp(new ExtractFromHereOp([['storyReactionPublicRepost', 'story'], ['storyItem', 'id']])),
84+
'peer' => new GetInputPeerOp(new ExtractFromHereOp([['storyReactionPublicRepost', 'peer_id']])),
85+
]
86+
);
87+
88+
$locations['peerStories'][] = new CallOp(
89+
'stories.getStoriesByID',
90+
[
91+
'id' => new ArrayOp(new ExtractFromHereOp([['peerStories', 'stories', ExtractFromHereOp::FLAG_UNPACK_ARRAY], ['storyItem', 'id']])),
92+
'peer' => new GetInputPeerOp(new ExtractFromHereOp([['peerStories', 'peer']])),
6093
]
6194
);
6295

@@ -91,7 +124,7 @@
91124
'peer' => new GetInputPeerOp(new ExtractFromHereOp([['storyItem', 'from_id', ExtractFromHereOp::FLAG_IF_ABSENT_ABORT]])),
92125
]);
93126
$locations['messages.getSponsoredMessages'][] = new CopyMethodCallOp('messages.getSponsoredMessages');
94-
$locations['channelAdminLogEvent'][] = new CallOp(
127+
/*$locations['channelAdminLogEvent'][] = new CallOp(
95128
'channels.getAdminLog',
96129
[
97130
'channel' => new GetInputChannelOp(new ExtractFromParentOp([['channels.getAdminLog', 'channel']])),
@@ -100,7 +133,27 @@
100133
'limit' => new PrimitiveLiteralOp('int', 1),
101134
'q' => new PrimitiveLiteralOp('string', ''),
102135
]
136+
);*/
137+
138+
$locations['channels.getAdminLog'][] = new CallOp(
139+
'channels.getAdminLog',
140+
[
141+
'channel' => new GetInputChannelOp(new ExtractFromHereOp([['channels.getAdminLog', 'channel']])),
142+
'max_id' => new ExtractFromHereOp([
143+
['channels.getAdminLog', ''],
144+
['channels.adminLogResults', 'events', ExtractFromHereOp::FLAG_UNPACK_ARRAY],
145+
['channelAdminLogEvent', 'id']
146+
]),
147+
'min_id' => new ExtractFromHereOp([
148+
['channels.getAdminLog', ''],
149+
['channels.adminLogResults', 'events', ExtractFromHereOp::FLAG_UNPACK_ARRAY],
150+
['channelAdminLogEvent', 'id']
151+
]),
152+
'limit' => new PrimitiveLiteralOp('int', 1),
153+
'q' => new PrimitiveLiteralOp('string', ''),
154+
]
103155
);
156+
104157
$locations['bots.getPreviewMedias'][] = new CopyMethodCallOp('bots.getPreviewMedias');
105158
$locations['bots.getPreviewInfo'][] = new CopyMethodCallOp('bots.getPreviewInfo');
106159
$locations['bots.addPreviewMedia'][] = new CallOp('bots.getPreviewInfo', [
@@ -142,16 +195,38 @@
142195
$starMethods = [];
143196
foreach ($TL->getMethodsOfType('payments.StarsStatus') as $method => $_) {
144197
$starMethods[$method] = true;
145-
$locations['starsTransaction'][] = new CallOp(
198+
/*$locations['starsTransaction'][] = new CallOp(
146199
'payments.getStarsTransactionsByID',
147200
[
148201
'peer' => new ExtractFromParentOp([[$method, 'peer']]),
149-
...($method === 'payments.getStarsSubscriptions' ? [] : ['ton' => new ExtractFromParentOp([[$method, 'ton', ExtractFromParentOp::FLAG_PASSTHROUGH]])]),
202+
...($method === 'payments.getStarsSubscriptions' ? [] : ['ton' => new ExtractFromParentOp([[$method, 'ton', ExtractFromHereOp::FLAG_PASSTHROUGH]])]),
150203
'id' => new ArrayOp(new ConstructorOp(
151204
'inputStarsTransaction',
152205
[
153206
'id' => new ExtractFromHereOp([['starsTransaction', 'id']]),
154-
'refund' => new ExtractFromHereOp([['starsTransaction', 'refund', ExtractFromParentOp::FLAG_PASSTHROUGH]]),
207+
'refund' => new ExtractFromHereOp([['starsTransaction', 'refund', ExtractFromHereOp::FLAG_PASSTHROUGH]]),
208+
]
209+
)),
210+
]
211+
);*/
212+
$locations[$method][] = new CallOp(
213+
'payments.getStarsTransactionsByID',
214+
[
215+
'peer' => new ExtractFromHereOp([[$method, 'peer']]),
216+
...($method === 'payments.getStarsSubscriptions' ? [] : ['ton' => new ExtractFromHereOp([[$method, 'ton', ExtractFromHereOp::FLAG_PASSTHROUGH]])]),
217+
'id' => new ArrayOp(new ConstructorOp(
218+
'inputStarsTransaction',
219+
[
220+
'id' => new ExtractFromHereOp([
221+
[$method, ''],
222+
['payments.starsStatus', 'history', ExtractFromHereOp::FLAG_IF_ABSENT_ABORT|ExtractFromHereOp::FLAG_UNPACK_ARRAY],
223+
['starsTransaction', 'id']
224+
]),
225+
'refund' => new ExtractFromHereOp([
226+
[$method, ''],
227+
['payments.starsStatus', 'history', ExtractFromHereOp::FLAG_IF_ABSENT_ABORT|ExtractFromHereOp::FLAG_UNPACK_ARRAY],
228+
['starsTransaction', 'refund', ExtractFromHereOp::FLAG_PASSTHROUGH]
229+
]),
155230
]
156231
)),
157232
]
@@ -233,15 +308,30 @@
233308
['hash' => new PrimitiveLiteralOp('int', 0)],
234309
);
235310

236-
$locations['photo'][] = new CallOp(
311+
/*$locations['photo'][] = new CallOp(
237312
'photos.getUserPhotos',
238313
[
239314
'user_id' => new ExtractFromParentOp([['photos.getUserPhotos', 'user_id']]),
240315
'offset' => new PrimitiveLiteralOp('int', -1),
241316
'max_id' => new ExtractFromHereOp([['photo', 'id']]),
242317
'limit' => new PrimitiveLiteralOp('int', 1),
243318
]
319+
);*/
320+
321+
$locations['photos.getUserPhotos'][] = new CallOp(
322+
'photos.getUserPhotos',
323+
[
324+
'user_id' => new ExtractFromHereOp([['photos.getUserPhotos', 'user_id']]),
325+
'offset' => new PrimitiveLiteralOp('int', -1),
326+
'max_id' => new ExtractFromHereOp([
327+
['photos.getUserPhotos', ''],
328+
['photos.photos', 'photos', ExtractFromHereOp::FLAG_UNPACK_ARRAY],
329+
['photo', 'id']
330+
]),
331+
'limit' => new PrimitiveLiteralOp('int', 1),
332+
]
244333
);
334+
245335
foreach (['photos.updateProfilePhoto', 'photos.uploadProfilePhoto'] as $method) {
246336
$locations[$method][] = new CallOp(
247337
'photos.getUserPhotos',
@@ -421,6 +511,8 @@ static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMe
421511
|| $cons === 'foundStory'
422512
|| $cons === 'publicForwardStory'
423513
|| $cons === 'peerStories'
514+
|| $cons === 'storyViewPublicRepost'
515+
|| $cons === 'storyReactionPublicRepost'
424516
) {
425517
return;
426518
}

0 commit comments

Comments
 (0)