Skip to content

Commit 4692531

Browse files
committed
Fix: media urls for chats with redirected messages.
1 parent 1089dd4 commit 4692531

2 files changed

Lines changed: 4 additions & 19 deletions

File tree

app/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public function encodeResponse(Client $client, bool $firstRun = true): self
335335
);
336336
break;
337337
case 'rss':
338-
$messages = new Messages($this->response['data'], $client);
338+
$messages = new Messages($this->response['data'], $client, $this->request['peer']);
339339
$rss = new RSS($messages->get(), $this->request['peer']);
340340
$this->response['data'] = $rss->get();
341341
break;

app/Messages.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,14 @@ class Messages {
1919
'messageMediaWebPage',
2020
];
2121

22-
/**
23-
* Messages constructor.
24-
* @param \stdClass $telegramResponse
25-
* @param Client $client
26-
*/
27-
public function __construct(\stdClass $telegramResponse, Client $client) {
22+
public function __construct(\stdClass $telegramResponse, Client $client, string $peer) {
2823
$this->telegramResponse = $telegramResponse;
2924
$this->client = $client;
30-
$this->setUsername();
25+
$this->username = $peer;
26+
$this->channelUrl = static::TELEGRAM_URL . $this->username . '/';
3127
$this->parseMessages();
3228
}
3329

34-
private function setUsername() {
35-
if (!$this->channelUrl) {
36-
$chat = $this->telegramResponse->chats[0];
37-
$this->username = $chat->username ?? $this->client->getId($chat);
38-
if (!$this->username) {
39-
return null;
40-
}
41-
$this->channelUrl = static::TELEGRAM_URL . $this->username . '/';
42-
}
43-
}
44-
4530
private function parseMessages(): self {
4631
if ($messages = $this->telegramResponse->messages ?? []) {
4732
$groupedMessages = [];

0 commit comments

Comments
 (0)