Properly clear up messages before resending a copy

This commit is contained in:
Daniil Gentili 2020-10-18 18:41:53 +02:00
parent a9bf26c9c0
commit f516a59082
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
3 changed files with 11 additions and 3 deletions

View File

@ -68,6 +68,9 @@ class SecretHandler extends \danog\MadelineProto\EventHandler
if ($update['message']['message'] === 'request') {
yield $this->requestSecretChat($update);
}
if ($update['message']['message'] === 'ping') {
yield $this->messages->sendMessage(['message' => 'lmao', 'peer' => $update]);
}
}
/**
* Handle secret chat messages.

View File

@ -49,7 +49,7 @@ class IncomingMessage extends Message
'future_salts' => 'req_msg_id',
'msgs_state_info' => 'req_msg_id',
'bad_server_salt' => 'bad_msg_id',
'bad_message_notification' => 'bad_msg_id',
'bad_msg_notification' => 'bad_msg_id',
'pong' => 'msg_id',
];
/**

View File

@ -271,8 +271,12 @@ trait ResponseHandler
}
if (\strpos($response['error_message'], 'FILE_REFERENCE_') === 0) {
$this->logger->logger("Got {$response['error_message']}, refreshing file reference and repeating method call...");
$this->gotResponseForOutgoingMessage($request);
$msgId = $request->getMsgId();
$request->setRefreshReferences(true);
$this->methodRecall('', ['message_id' => $request->getMsgId(), 'postpone' => true]);
$request->setMsgId(null);
$request->setSeqNo(null);
$this->methodRecall('', ['message_id' => $msgId, 'postpone' => true]);
return null;
}
@ -384,10 +388,11 @@ trait ResponseHandler
if (\is_numeric($seconds) && $seconds < $limit) {
$this->logger->logger("Flood, waiting $seconds seconds before repeating async call of $request...", Logger::NOTICE);
$this->gotResponseForOutgoingMessage($request);
$msgId = $request->getMsgId();
$request->setSent(($request->getSent() ?? \time()) + $seconds);
$request->setMsgId(null);
$request->setSeqNo(null);
Loop::delay($seconds * 1000, [$this, 'methodRecall'], ['message_id' => $request->getMsgId()]);
Loop::delay($seconds * 1000, [$this, 'methodRecall'], ['message_id' => $msgId]);
return null;
}
// no break