-
-
Notifications
You must be signed in to change notification settings - Fork 662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for secret chat messages in the SimpleEventHandler! #1401
Conversation
mtalaeii
commented
Sep 3, 2023
- Add Media types for DecryptedMedia
- Separate PrivateMessage classes
- Add Media types for DecryptedMedia - Separate PrivateMessage classes
* @link https://docs.madelineproto.xyz MadelineProto documentation | ||
*/ | ||
|
||
namespace danog\MadelineProto\EventHandler\Message\Private; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pls don't change the namespace, put both SecretMessage and PrivateMessage in the Message namespace
@@ -132,6 +143,9 @@ public function wrapMedia(array $media, bool $protected = false): ?Media | |||
if ($has_document_photo) { | |||
return new DocumentPhoto($this, $media, $has_document_photo, $protected); | |||
} | |||
if ($media['_'] === 'decryptedMessageMediaDocument') { | |||
return new Media\Decrypted\Document($this, $media, $protected); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that creating separate classes for secret media is not the way to go, instead we could just add some fields to the existing media classes that will only be populated in secret chats (i.e. fields that are not present for normal media)
|
||
final class SecretMessage extends AbstractPrivateMessage | ||
{ | ||
/** Content of the message */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to duplicate these properties, we can just re-use the ones in privatemessage
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, these properties are already present in PrivateMessage, they can be populated directly by the constructor of PrivateMessage, there's no need to populate them in SecretMessage.
The chatId
is also present in AbstractMessage, it's just slightly different for secret chats (and in this case, the logic to handle the distinction can also be present in AbstractMessage)
{ | ||
parent::__construct($API, $rawMessage, $info); | ||
$decryptedMessage = $rawMessage['decrypted_message']; | ||
$this->chatId = $rawMessage['chat_id']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->chatId = DialogId::fromSecretChatId($rawMessage['chat_id'])
and $this->senderId = $info['bot_api_id'];
I'm gonna to make this pr as draft as these days i have some stuff todos so please keep it open and dont close it. |