Skip to content

Commit

Permalink
Fix issue in broadcasts
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Dec 15, 2023
1 parent 028f3b2 commit 7000de1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class API extends AbstractAPI
*
* @var string
*/
public const RELEASE = '8.0.0-beta178';
public const RELEASE = '8.0.0-beta179';
/**
* We're not logged in.
*
Expand Down
9 changes: 7 additions & 2 deletions src/Broadcast/Action/ActionSend.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ public function act(int $broadcastId, int $peer, Cancellation $cancellation): vo
return;
}
$id = $this->API->extractMessageId($this->API->methodCallAsyncRead(
\is_string($message['media']) || (isset($message['media']['_']) &&
$message['media']['_'] !== 'messageMediaWebPage')
isset($message['media']) && (
\is_string($message['media'])
|| (
isset($message['media']['_']) &&
$message['media']['_'] !== 'messageMediaWebPage'
)
)
? 'messages.sendMedia'
: 'messages.sendMessage',
array_merge($message, ['peer' => $peer, 'floodWaitLimit' => 2*86400, 'cancellation' => $cancellation]),
Expand Down
7 changes: 0 additions & 7 deletions src/Serialization.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@
*/
abstract class Serialization
{
/**
* Header for session files.
*/
public const PHP_HEADER = '<?php __HALT_COMPILER();';
public const VERSION_OLD = 2;
public const VERSION_SERIALIZATION_AWARE = 3;

/**
* Unserialize session.
*
Expand Down
17 changes: 12 additions & 5 deletions src/SessionPaths.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
*/
final class SessionPaths
{
/**
* Header for session files.
*/
private const PHP_HEADER = '<?php __HALT_COMPILER();';
private const VERSION_OLD = 2;
private const VERSION_SERIALIZATION_AWARE = 3;

/**
* Session directory path.
*/
Expand Down Expand Up @@ -135,8 +142,8 @@ public function serialize(object $object, string $path): void
try {
Logger::log("Got exclusive lock of $path.lock...");

$object = Serialization::PHP_HEADER
.\chr(Serialization::VERSION_SERIALIZATION_AWARE)
$object = self::PHP_HEADER
.\chr(self::VERSION_SERIALIZATION_AWARE)
.\chr(PHP_MAJOR_VERSION)
.\chr(PHP_MINOR_VERSION)
.\chr(Magic::$can_use_igbinary ? 1 : 0)
Expand Down Expand Up @@ -165,7 +172,7 @@ public function unserialize(string $path = ''): ?object
if (!exists($path)) {
return null;
}
$headerLen = \strlen(Serialization::PHP_HEADER);
$headerLen = \strlen(self::PHP_HEADER);

Logger::log("Waiting for shared lock of $path.lock...", Logger::ULTRA_VERBOSE);
$unlock = Tools::flock("$path.lock", LOCK_SH, 0.1);
Expand All @@ -180,7 +187,7 @@ public function unserialize(string $path = ''): ?object

$file->seek($headerLen++);
$v = \ord($file->read(null, 1));
if ($v >= Serialization::VERSION_OLD) {
if ($v >= self::VERSION_OLD) {
$php = $file->read(null, 2);
$major = \ord($php[0]);
$minor = \ord($php[1]);
Expand All @@ -190,7 +197,7 @@ public function unserialize(string $path = ''): ?object
$headerLen += 2;
}
$igbinary = false;
if ($v >= Serialization::VERSION_SERIALIZATION_AWARE) {
if ($v >= self::VERSION_SERIALIZATION_AWARE) {
$igbinary = (bool) \ord($file->read(null, 1));
if ($igbinary && !Magic::$can_use_igbinary) {
throw Exception::extension('igbinary');
Expand Down

0 comments on commit 7000de1

Please sign in to comment.