Skip to content

Commit 2348ca9

Browse files
committed
Improve getMessageOp
1 parent fa055a7 commit 2348ca9

8 files changed

Lines changed: 34 additions & 15 deletions

File tree

src/TL_file_ref_map_schema.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@
383383
"type": "ActionOp"
384384
},
385385
{
386-
"id": "-1256352664",
386+
"id": "595085800",
387387
"predicate": "getMessageOp",
388388
"params": [
389389
{
@@ -397,6 +397,10 @@
397397
{
398398
"name": "from_scheduled",
399399
"type": "TypedOp"
400+
},
401+
{
402+
"name": "quick_reply_shortcut_id",
403+
"type": "TypedOp"
400404
}
401405
],
402406
"type": "ActionOp"

src/TL_file_ref_map_schema.tl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extractUserIdFromInputUserAndStore#7720aa2e from:Path to:string = FieldExtractor
4444

4545
// Actions
4646
callOp#c2ff3383 method:string args:Vector<TypedOpArg> = ActionOp;
47-
getMessageOp#b51d9468 peer:TypedOp id:TypedOp from_scheduled:TypedOp = ActionOp;
47+
getMessageOp#237849e8 peer:TypedOp id:TypedOp from_scheduled:TypedOp quick_reply_shortcut_id:TypedOp = ActionOp;
4848

4949
// For string => TypedOp dictionaries
5050
typedOpArg#3a2930c2 key:string value:TypedOp = TypedOpArg;

src/file_ref_map.dat

232 Bytes
Binary file not shown.

src/file_ref_map.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tools/FileRefExtractor/BuildMode/Ast.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,12 @@ public function addNode(TLContext $ctx, ?array $action = null, ?string $why = nu
224224
// aka the source_constructor will always be of the same type, it should have all
225225
// needed flags, and the behavior will be consistent.
226226
if ($action['_'] === 'getMessageOp') {
227-
if (!isset($existingAction['from_scheduled']) && isset($action['from_scheduled'])) {
228-
$existingAction['from_scheduled'] = $action['from_scheduled'];
229-
} elseif (isset($existingAction['from_scheduled']) && !isset($action['from_scheduled'])) {
230-
$action['from_scheduled'] = $existingAction['from_scheduled'];
227+
foreach (['from_scheduled', 'quick_reply_shortcut_id'] as $k) {
228+
if (!isset($existingAction[$k]) && isset($action[$k])) {
229+
$existingAction[$k] = $action[$k];
230+
} elseif (isset($existingAction[$k]) && !isset($action[$k])) {
231+
$action[$k] = $existingAction[$k];
232+
}
231233
}
232234
} else {
233235
Assert::eq($action['_'], 'callOp');

tools/FileRefExtractor/FileRefGenerator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public static function generate(int|string $layer, string $inputSchema, string $
6868
new GetInputPeerOp(new Path([[$constructor, 'peer_id']])),
6969
new CopyOp([[$constructor, 'id']]),
7070
$constructor === 'message' ? new CopyOp([[$constructor, 'from_scheduled', Path::FLAG_PASSTHROUGH]]) : null,
71+
$constructor === 'message' ? new CopyOp([[$constructor, 'quick_reply_shortcut_id', Path::FLAG_PASSTHROUGH]]) : null,
7172
'fileSourceMessage',
7273
);
7374
}
@@ -486,6 +487,7 @@ public static function generate(int|string $layer, string $inputSchema, string $
486487
'fileSourceMessage' => [
487488
'flags' => '#',
488489
'from_scheduled' => 'flags.0?true',
490+
'quick_reply_shortcut_id' => 'flags.1?int',
489491
'peer' => 'long',
490492
'id' => 'int',
491493
],
@@ -547,20 +549,22 @@ public static function generate(int|string $layer, string $inputSchema, string $
547549
}
548550
}
549551

552+
$traversalPairs = [];
550553
$tmp = new Ast(blacklistedPredicates: $blacklistedPredicates, allowUnpacking: true, outputSchema: $pre);
551554
foreach ($incomingCons as $constructor => $_) {
552555
$type = ucfirst($constructor);
553556
$stack = [[$constructor, 'file_reference']];
554557
$stackTypes = [$type => 1];
555558
$recurse(
556-
static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMethods, $starMethods, $stickerMethods): void {
559+
static function (array $stack) use ($locations, $TL, $tmp, &$traversalPairs, &$validated, $storyMethods, $starMethods, $stickerMethods): void {
557560
$slice = [];
558561
$hadAny = false;
559562
$hadAnyWithNoFlags = false;
560563
$skippedDueToFlags = [];
561564
$top = end($stack)[0];
562565
for ($x = \count($stack)-1; $x >= 0; $x--) {
563566
$pair = $stack[$x];
567+
//$traversalPairs[json_encode($pair)] = $pair;
564568
foreach ($locations[$pair[0]] ?? [] as $op) {
565569
$normalized = $op->normalize($slice, $pair[0], false);
566570
if ($normalized === null) {
@@ -582,10 +586,7 @@ static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMe
582586
if (!$hadAny) {
583587
throw new AssertionError("Uncovered path: " . json_encode($stack));
584588
}
585-
if ($hadAnyWithNoFlags) {
586-
return;
587-
}
588-
if ($skippedDueToFlags) {
589+
if (!$hadAnyWithNoFlags && $skippedDueToFlags) {
589590
if ($top === 'updateStory'
590591
|| $top === 'peerStories'
591592
// The two above always have the story peer flag set.
@@ -629,6 +630,7 @@ static function (array $stack) use ($locations, $TL, $tmp, &$validated, $storyMe
629630
$stackTypes,
630631
);
631632
}
633+
//var_dump(array_values($traversalPairs));
632634

633635
$diff = [];
634636
foreach ($locations as $constructor => $ops) {

tools/FileRefExtractor/Ops/GetMessageOp.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public function __construct(
2929
private readonly TypedOp $peer,
3030
private readonly TypedOp $id,
3131
private readonly ?TypedOp $fromScheduled,
32+
private readonly ?TypedOp $quickReplyShortcutId,
3233
private readonly string $stored_constructor
3334
) {
3435
}
@@ -46,8 +47,12 @@ public function normalize(array $stack, string $current, bool $ignoreFlag): ?Act
4647
if ($fromScheduled === null && $this->fromScheduled !== null) {
4748
return null;
4849
}
49-
if ($peer !== $this->peer || $id !== $this->id || $fromScheduled !== $this->fromScheduled) {
50-
return new self($peer, $id, $fromScheduled, $this->stored_constructor);
50+
$quickReplyShortcutId = $this->quickReplyShortcutId?->normalize($stack, $current, $ignoreFlag);
51+
if ($quickReplyShortcutId === null && $this->quickReplyShortcutId !== null) {
52+
return null;
53+
}
54+
if ($peer !== $this->peer || $id !== $this->id || $fromScheduled !== $this->fromScheduled || $quickReplyShortcutId !== $this->quickReplyShortcutId) {
55+
return new self($peer, $id, $fromScheduled, $quickReplyShortcutId, $this->stored_constructor);
5156
}
5257
return $this;
5358
}
@@ -63,10 +68,16 @@ public function build(TLContext $tl): void
6368
if ($this->fromScheduled !== null) {
6469
Assert::eq($this->fromScheduled->getType($tl), 'true');
6570
}
71+
if ($this->quickReplyShortcutId !== null) {
72+
Assert::eq($this->quickReplyShortcutId->getType($tl), 'int');
73+
}
6674
$extra = [];
6775
if ($this->fromScheduled !== null) {
6876
$extra['from_scheduled'] = $tl->build($this->fromScheduled, 'from_scheduled');
6977
}
78+
if ($this->quickReplyShortcutId !== null) {
79+
$extra['quick_reply_shortcut_id'] = $tl->build($this->quickReplyShortcutId, 'quick_reply_shortcut_id');
80+
}
7081
$tl->buildMode->addNode($tl, [
7182
'_' => 'getMessageOp',
7283
'stored_constructor' => $this->stored_constructor,

0 commit comments

Comments
 (0)