Skip to content

Commit 5cc68dd

Browse files
committed
Finalize
1 parent a31db1d commit 5cc68dd

8 files changed

Lines changed: 45 additions & 18 deletions

File tree

src/TL_filerefs_db.tl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
fileSourceMessage#8e8d1cee flags:# from_scheduled:flags.0?true peer:long id:int = FileSource;
2+
fileSourceStarsTransaction#c1bac8c7 flags:# peer:long id:string refund:flags.0?true ton:flags.1?true = FileSource;
3+
fileSourceStory#c820e3eb id:int peer:long = FileSource;
4+
fileSourceWebPage#9e5b749c url:string = FileSource;
5+
fileSourceBotApp#01cf8b7a id:long access_hash:long = FileSource;
6+
fileSourceUserFull#70fdb7b0 id:long = FileSource;
7+
fileSourceAdminLog#4797f959 channel:long max_id:long = FileSource;
8+
fileSourceStoryAlbum#5e01f223 peer:long = FileSource;
9+
fileSourceBotPreviewMedia#0aa91441 bot:long = FileSource;
10+
fileSourceBotPreviewInfo#f9d2d6fc bot:long lang_code:string = FileSource;
11+
fileSourcePaidMedia#b18d9042 id:int peer:long = FileSource;
12+
fileSourceChatFull#9de75fde chat_id:long = FileSource;
13+
fileSourceChannelFull#6fe19339 channel:long = FileSource;
14+
fileSourcePremiumPromo#c907a44f = FileSource;
15+
fileSourceAttachMenuBot#c3002694 bot:long = FileSource;
16+
fileSourceTheme#92d05e0c id:long access_hash:long = FileSource;
17+
fileSourceWallPaper#50dbf2f7 id:long access_hash:long = FileSource;
18+
fileSourceStickerSet#34c73709 stickerset:InputStickerSet = FileSource;
19+
fileSourceSavedGifs#13e78e07 = FileSource;
20+
fileSourceSavedRingtones#2b25ef1b = FileSource;
21+
fileSourceAvailableEffects#eb8578f0 = FileSource;
22+
fileSourceAvailableReactions#0e432388 = FileSource;
23+
fileSourceUserProfilePhoto#e39ee274 user_id:long max_id:long = FileSource;
24+
fileSourceDocumentByHash#0f151e0f sha256:bytes size:long mime_type:string = FileSource;

src/file_ref_map.dat

196 Bytes
Binary file not shown.

tools/FileRefExtractor/BuildMode/Ast.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ public function __construct(
4747
) {
4848
}
4949

50-
public function getOutput(): string
50+
public function write(string $dbFile, string $schemaFile): void
5151
{
5252
$schema = '';
5353
foreach ($this->outputSchema as $constructor => $params) {
5454
$schema .= self::stringifySchema($constructor, $params)."\n";
5555
}
56+
file_put_contents($schemaFile, $schema);
5657
$value = ['_' => 'fileReferenceOrigins', 'db_schema' => $schema, 'ctxs' => $this->output];
5758
Magic::start(false);
5859

@@ -61,8 +62,9 @@ public function getOutput(): string
6162
$TL = new TL((new ReflectionClass(MTProto::class))->newInstanceWithoutConstructor());
6263
$TL->init($s);
6364
$serialized = $TL->serializeObject(['type' => 'FileReferenceOrigins'], $value, '');
64-
//$valueDe = $TL->deserialize($serialized, ['type' => '', 'connection' => null, 'encrypted' => true]);
65-
return $serialized;
65+
$valueDe = $TL->deserialize($serialized, ['type' => '', 'connection' => null, 'encrypted' => true]);
66+
Assert::true($value == $valueDe);
67+
file_put_contents($dbFile, $serialized);
6668
}
6769

6870
private static function stringifySchema(string $constructor, array $params): string
@@ -94,6 +96,7 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
9496
'_' => 'origin',
9597
'predicate' => $ctx->position,
9698
'is_constructor' => $ctx->isConstructor,
99+
'parent_is_constructor' => false,
97100
];
98101
if ($this->needsParent !== null) {
99102
$out['needs_parent'] = $this->needsParent;

tools/FileRefExtractor/Ops/GetInputChannelOp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function build(TLContext $tl): array
5555
'type' => $this->getType($tl),
5656
'op' => [
5757
'_' => 'getInputChannelByIdOp',
58-
'path' => $this->path->buildPath($tl, 'extractAndStore'),
58+
'from' => $this->path->buildPath($tl, 'extractAndStore'),
5959
],
6060
];
6161
}
@@ -65,7 +65,7 @@ public function build(TLContext $tl): array
6565
'type' => $this->getType($tl),
6666
'op' => [
6767
'_' => 'getInputChannelByIdOp',
68-
'path' => $this->path->buildPath($tl, 'extractChannelIdFromInputChannelAndStore'),
68+
'from' => $this->path->buildPath($tl, 'extractChannelIdFromInputChannelAndStore'),
6969
],
7070
];
7171
}
@@ -75,7 +75,7 @@ public function build(TLContext $tl): array
7575
'type' => $this->getType($tl),
7676
'op' => [
7777
'_' => 'getInputChannelByIdOp',
78-
'path' => $this->path->buildPath($tl, 'extractChannelIdFromChannelAndStore'),
78+
'from' => $this->path->buildPath($tl, 'extractChannelIdFromChannelAndStore'),
7979
],
8080
];
8181
}

tools/FileRefExtractor/Ops/GetInputPeerOp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function build(TLContext $tl): array
5555
'type' => $this->getType($tl),
5656
'op' => [
5757
'_' => 'getInputPeerByIdOp',
58-
'path' => $this->path->buildPath($tl, 'extractPeerIdFromInputPeerAndStore'),
58+
'from' => $this->path->buildPath($tl, 'extractPeerIdFromInputPeerAndStore'),
5959
],
6060
];
6161
}
@@ -66,7 +66,7 @@ public function build(TLContext $tl): array
6666
'type' => $this->getType($tl),
6767
'op' => [
6868
'_' => 'getInputPeerByIdOp',
69-
'path' => $this->path->buildPath($tl, 'extractPeerIdFromPeerAndStore'),
69+
'from' => $this->path->buildPath($tl, 'extractPeerIdFromPeerAndStore'),
7070
],
7171
];
7272
}

tools/FileRefExtractor/Ops/GetInputStickerSet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function build(TLContext $tl): array
5656
'type' => 'InputStickerSet',
5757
'op' => [
5858
'_' => 'copyOp',
59-
'path' => $this->path->buildPath($tl, 'extractInputStickerSetFromStickerSetAndStore'),
59+
'from' => $this->path->buildPath($tl, 'extractInputStickerSetFromStickerSetAndStore'),
6060
],
6161
];
6262
}
@@ -66,7 +66,7 @@ public function build(TLContext $tl): array
6666
'type' => $this->getType($tl),
6767
'op' => [
6868
'_' => 'copyOp',
69-
'path' => $this->path->buildPath($tl, 'extractInputStickerSetFromDocumentAttributesAndStore'),
69+
'from' => $this->path->buildPath($tl, 'extractInputStickerSetFromDocumentAttributesAndStore'),
7070
],
7171
];
7272
}

tools/FileRefExtractor/Ops/GetInputUserOp.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function build(TLContext $tl): array
5555
'type' => $this->getType($tl),
5656
'op' => [
5757
'_' => 'getInputUserByIdOp',
58-
'path' => $this->path->buildPath($tl, 'extractUserIdFromInputUserAndStore'),
58+
'from' => $this->path->buildPath($tl, 'extractUserIdFromInputUserAndStore'),
5959
],
6060
];
6161
}
@@ -65,7 +65,7 @@ public function build(TLContext $tl): array
6565
'type' => $this->getType($tl),
6666
'op' => [
6767
'_' => 'getInputUserByIdOp',
68-
'path' => $this->path->buildPath($tl, 'extractAndStore'),
68+
'from' => $this->path->buildPath($tl, 'extractAndStore'),
6969
],
7070
];
7171
}
@@ -75,7 +75,7 @@ public function build(TLContext $tl): array
7575
'type' => $this->getType($tl),
7676
'op' => [
7777
'_' => 'getInputUserByIdOp',
78-
'path' => $this->path->buildPath($tl, 'extractUserIdFromUserAndStore'),
78+
'from' => $this->path->buildPath($tl, 'extractUserIdFromUserAndStore'),
7979
],
8080
];
8181
}

tools/gen_filerefmap.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@
158158
'peer' => new GetInputPeerOp(new Path([['storyItem', 'from_id', Path::FLAG_IF_ABSENT_ABORT]])),
159159
], 'fileSourceStory');
160160

161-
$locations['messages.getSponsoredMessages'][] = new CopyMethodCallOp('messages.getSponsoredMessages', 'fileSourceSponsoredMessage');
162-
//$locations['messages.getSponsoredMessages'][] = new Noop('Do not store file references from sponsored messages');
161+
//$locations['messages.getSponsoredMessages'][] = new CopyMethodCallOp('messages.getSponsoredMessages', 'fileSourceSponsoredMessage');
162+
$locations['messages.getSponsoredMessages'][] = new Noop('Do not store file references from sponsored messages');
163163

164164
$locations['channelAdminLogEvent'][] = new CallOp(
165165
'channels.getAdminLog',
@@ -606,10 +606,10 @@ static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMe
606606
$op->build(new TLContext($TL, $output, $constructor, $TL->isConstructor($constructor)));
607607
}
608608
}
609-
$tl = $output->getOutput();
610609

611-
file_put_contents(
610+
$output->write(
612611
__DIR__.'/../src/file_ref_map.dat',
613-
$tl
612+
__DIR__.'/../src/TL_filerefs_db.tl',
614613
);
614+
615615
echo("OK!\n".PHP_EOL);

0 commit comments

Comments
 (0)