Skip to content

Commit

Permalink
Fix MyTelegramOrgWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Nov 9, 2023
1 parent d8ad514 commit 9c96a83
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/DoHWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ final class DoHWrapper
public readonly Rfc6455Connector $webSocketConnector;

public function __construct(
private MTProto $API,
private SettingsGetter&LoggerGetter $API,
?CookieJar $jar = null
) {
$configProvider = new class implements DnsConfigLoader {
Expand Down
2 changes: 1 addition & 1 deletion src/EventHandler/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ abstract class Message extends AbstractMessage

/**
* Group ID for albums.
*
*
* All messages associated to the same album will have an identical grouped ID.
*/
public readonly ?int $groupedId;
Expand Down
2 changes: 1 addition & 1 deletion src/MTProto.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
*
* @internal
*/
final class MTProto implements TLCallback, LoggerGetter
final class MTProto implements TLCallback, LoggerGetter, SettingsGetter
{
use AuthKeyHandler;
use CallHandler;
Expand Down
13 changes: 9 additions & 4 deletions src/MyTelegramOrgWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,19 @@ public function __wakeup(): void
$this->jar = new LocalCookieJar();
}
$this->datacenter = new DoHWrapper(
$this->settings->getConnection(),
new class(new Logger($this->settings->getLogger())) implements LoggerGetter {
public function __construct(private Logger $logger)
new class($this->settings) implements SettingsGetter,
LoggerGetter {
public function __construct(
private readonly Settings $settings
) {
}
public function getSettings(): Settings
{
return $this->settings;
}
public function getLogger(): Logger
{
return $this->logger;
return $this->getLogger();
}
},
$this->jar
Expand Down
23 changes: 23 additions & 0 deletions src/SettingsGetter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php declare(strict_types=1);

/**
* This file is part of MadelineProto.
* MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
* MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
* You should have received a copy of the GNU General Public License along with MadelineProto.
* If not, see <http://www.gnu.org/licenses/>.
*
* @author Daniil Gentili <[email protected]>
* @copyright 2016-2023 Daniil Gentili <[email protected]>
* @license https://opensource.org/licenses/AGPL-3.0 AGPLv3
* @link https://docs.madelineproto.xyz MadelineProto documentation
*/

namespace danog\MadelineProto;

/** @internal */
interface SettingsGetter
{
public function getSettings(): Settings;
}

0 comments on commit 9c96a83

Please sign in to comment.