mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-27 02:34:39 +01:00
Revert back strategy of DiscordReason and VoipController
This commit is contained in:
parent
899054337e
commit
b72a55ea75
@ -26,32 +26,33 @@ use JsonSerializable;
|
||||
/**
|
||||
* Why was the call discarded?
|
||||
*/
|
||||
enum DiscardReason: string implements JsonSerializable
|
||||
enum DiscardReason implements JsonSerializable
|
||||
{
|
||||
/** The phone call was discarded because the user is busy in another call */
|
||||
case BUSY = 'phoneCallDiscardReasonBusy';
|
||||
/** The phone call was discarded because the user is busy in another call */
|
||||
case HANGUP = 'phoneCallDiscardReasonHangup';
|
||||
/** The phone call was disconnected */
|
||||
case DISCONNECTED = 'phoneCallDiscardReasonDisconnect';
|
||||
/** We missed the call */
|
||||
case MISSED = 'phoneCallDiscardReasonMissed';
|
||||
case MISSED;
|
||||
/** The phone call was disconnected */
|
||||
case DISCONNECTED;
|
||||
/** The phone call ended normally */
|
||||
case HANGUP;
|
||||
/** The phone call was discarded because the user is busy in another call */
|
||||
case BUSY;
|
||||
|
||||
/**
|
||||
* @throws AssertionError
|
||||
* @internal
|
||||
* @throws AssertionError
|
||||
*/
|
||||
public static function fromString(?string $name): ?DiscardReason
|
||||
{
|
||||
if ($name === null) {
|
||||
return null;
|
||||
}
|
||||
$newName = \strtoupper(\substr($name, 22));
|
||||
foreach (DiscardReason::cases() as $case) {
|
||||
if ($case->value === $name) {
|
||||
if ($case->name === $newName) {
|
||||
return $case;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("Undefined case PhoneCallDiscardReason::" . $name);
|
||||
throw new AssertionError("Undefined case PhoneCallDiscardReason::".$name);
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
@ -59,4 +60,4 @@ enum DiscardReason: string implements JsonSerializable
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
}
|
@ -343,7 +343,12 @@ final class VoIPController
|
||||
|
||||
$this->log(\sprintf(Lang::$current_lang['call_discarding'], $this->public->callID), Logger::VERBOSE);
|
||||
try {
|
||||
$this->API->methodCallAsyncRead('phone.discardCall', ['peer' => $this->call, 'duration' => \time() - $this->public->date, 'connection_id' => 0, 'reason' => ['_' => $reason]]);
|
||||
$this->API->methodCallAsyncRead('phone.discardCall', ['peer' => $this->call, 'duration' => \time() - $this->public->date, 'connection_id' => 0, 'reason' => ['_' => match ($reason) {
|
||||
DiscardReason::BUSY => 'phoneCallDiscardReasonBusy',
|
||||
DiscardReason::HANGUP => 'phoneCallDiscardReasonHangup',
|
||||
DiscardReason::DISCONNECTED => 'phoneCallDiscardReasonDisconnect',
|
||||
DiscardReason::MISSED => 'phoneCallDiscardReasonMissed'
|
||||
}]]);
|
||||
} catch (RPCErrorException $e) {
|
||||
if (!\in_array($e->rpc, ['CALL_ALREADY_DECLINED', 'CALL_ALREADY_ACCEPTED'], true)) {
|
||||
throw $e;
|
||||
@ -676,4 +681,4 @@ final class VoIPController
|
||||
{
|
||||
return $this->public->__toString();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user