mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-26 19:24:42 +01:00
Fix SecretMessage::delete, SeekableTrait::seek and add deleteHistory flag to discardSecretChat
This commit is contained in:
parent
0a436cc5ac
commit
31e3a4fb86
2
docs
2
docs
@ -1 +1 @@
|
||||
Subproject commit 56c2127618b69c1d85c34a812f65aeb278a6828e
|
||||
Subproject commit da954d5948e725aa2e8a650241593de5bcdd324a
|
@ -55,6 +55,28 @@ class SecretMessage extends AbstractPrivateMessage
|
||||
return $this->replyCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the message.
|
||||
*
|
||||
* @param boolean $revoke Whether to delete the message for all participants of the chat.
|
||||
*/
|
||||
public function delete(bool $revoke = true): void
|
||||
{
|
||||
if (!$revoke) {
|
||||
return;
|
||||
}
|
||||
$this->getClient()->methodCallAsyncRead(
|
||||
'messages.sendEncryptedService',
|
||||
[
|
||||
'peer' => $this->chatId,
|
||||
'message' => [
|
||||
'_' => 'decryptedMessageService',
|
||||
'action' => ['_' => 'decryptedMessageActionDeleteMessages', 'random_ids' => [$this->id]],
|
||||
],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function screenShot(): DialogScreenshotTaken
|
||||
{
|
||||
$result = $this->getClient()->methodCallAsyncRead(
|
||||
|
@ -422,10 +422,11 @@ abstract class InternalDoc
|
||||
* Discard secret chat.
|
||||
*
|
||||
* @param int $chat Secret chat ID
|
||||
* @param bool $deleteHistory If true, deletes the entire chat history for the other user as well.
|
||||
*/
|
||||
final public function discardSecretChat(int $chat): void
|
||||
final public function discardSecretChat(int $chat, bool $deleteHistory = false): void
|
||||
{
|
||||
$this->wrapper->getAPI()->discardSecretChat($chat);
|
||||
$this->wrapper->getAPI()->discardSecretChat($chat, $deleteHistory);
|
||||
}
|
||||
/**
|
||||
* Downloads a file to the browser using the specified session file.
|
||||
|
@ -16,6 +16,8 @@
|
||||
|
||||
namespace danog\MadelineProto\Ipc\Wrapper;
|
||||
|
||||
use Amp\File\Whence;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
@ -23,14 +25,8 @@ trait SeekableTrait
|
||||
{
|
||||
/**
|
||||
* Set the handle's internal pointer position.
|
||||
*
|
||||
* $whence values:
|
||||
*
|
||||
* SEEK_SET - Set position equal to offset bytes.
|
||||
* SEEK_CUR - Set position to current location plus offset.
|
||||
* SEEK_END - Set position to end-of-file plus offset.
|
||||
*/
|
||||
public function seek(int $position, int $whence = \SEEK_SET): int
|
||||
public function seek(int $position, Whence $whence = Whence::Current): int
|
||||
{
|
||||
return $this->__call('seek', [$position, $whence]);
|
||||
}
|
||||
|
@ -233,8 +233,9 @@ trait AuthKeyHandler
|
||||
* Discard secret chat.
|
||||
*
|
||||
* @param int $chat Secret chat ID
|
||||
* @param bool $deleteHistory If true, deletes the entire chat history for the other user as well.
|
||||
*/
|
||||
public function discardSecretChat(int $chat): void
|
||||
public function discardSecretChat(int $chat, bool $deleteHistory = false): void
|
||||
{
|
||||
$this->logger->logger('Discarding secret chat '.$chat.'...', Logger::VERBOSE);
|
||||
if (isset($this->secretChats[$chat])) {
|
||||
@ -244,7 +245,7 @@ trait AuthKeyHandler
|
||||
unset($this->temp_requested_secret_chats[$chat]);
|
||||
}
|
||||
try {
|
||||
$this->methodCallAsyncRead('messages.discardEncryption', ['chat_id' => $chat]);
|
||||
$this->methodCallAsyncRead('messages.discardEncryption', ['chat_id' => $chat, 'delete_history' => $deleteHistory]);
|
||||
} catch (RPCErrorException $e) {
|
||||
if ($e->rpc !== 'ENCRYPTION_ALREADY_DECLINED') {
|
||||
throw $e;
|
||||
|
Loading…
Reference in New Issue
Block a user