1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 01:14:39 +01:00

fix peer id , improve getIdInternal

This commit is contained in:
َAhJ 2023-11-02 14:10:02 +03:30
parent 31c36e5d6a
commit 210537c432
8 changed files with 41 additions and 40 deletions

View File

@ -38,7 +38,7 @@ final class MessageViewsChanged extends Update
public function __construct(MTProto $API, array $rawMessageViews)
{
parent::__construct($API);
$this->chatId = DialogId::fromSupergroupOrChannel($rawMessageViews['channel_id']);
$this->chatId = $API->getIdInternal($rawMessageViews);
$this->id = $rawMessageViews['id'];
$this->views = $rawMessageViews['views'];
}

View File

@ -29,9 +29,9 @@ final class UpdateChannel extends Update
public readonly int $chatId;
/** @internal */
public function __construct(MTProto $API, array $rawMessageViews)
public function __construct(MTProto $API, array $rawUpdateChannel)
{
parent::__construct($API);
$this->chatId = DialogId::fromSupergroupOrChannel($rawMessageViews['channel_id']);
$this->chatId = $API->getIdInternal($rawUpdateChannel);
}
}

View File

@ -18,7 +18,6 @@ namespace danog\MadelineProto\EventHandler\Delete;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\EventHandler\Delete;
use danog\MadelineProto\MTProtoTools\DialogId;
/**
* Some messages in a [supergroup/channel](https://core.telegram.org/api/channel) were deleted.
@ -32,6 +31,6 @@ final class DeleteChannelMessages extends Delete
public function __construct(MTProto $API, array $rawDelete)
{
parent::__construct($API, $rawDelete);
$this->chatId = DialogId::fromSupergroupOrChannel($rawDelete['channel_id']);
$this->chatId = $API->getIdInternal($rawDelete);
}
}

View File

@ -17,7 +17,6 @@
namespace danog\MadelineProto\EventHandler\Query;
use danog\MadelineProto\EventHandler\CallbackQuery;
use danog\MadelineProto\EventHandler\Query;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\TL\Types\Bytes;
use ReflectionClass;

View File

@ -36,7 +36,7 @@ final class StoryReaction extends Update
public function __construct(MTProto $API, array $rawStory)
{
parent::__construct($API);
$this->senderId = $API->getIdInternal($rawStory['peer']);
$this->senderId = $API->getIdInternal($rawStory);
$this->id = $rawStory['story_id'];
$this->reaction = $rawStory['reaction']['emoticon'] ?? $rawStory['reaction']['document_id'] ?? null;
}

View File

@ -18,7 +18,6 @@ namespace danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\EventHandler\Typing;
use danog\MadelineProto\MTProto;
use danog\MadelineProto\MTProtoTools\DialogId;
/**
* A user is typing in a [supergroup](https://core.telegram.org/api/channel).
@ -35,7 +34,7 @@ final class SupergroupUserTyping extends Typing
public function __construct(MTProto $API, array $rawTyping)
{
parent::__construct($API, $rawTyping);
$this->chatId = DialogId::fromSupergroupOrChannel($rawTyping['channel_id']);
$this->chatId = $API->getIdInternal($rawTyping);
$this->topicId = $rawTyping['top_msg_id'] ?? null;
}
}

View File

@ -39,6 +39,6 @@ final class Blocked extends Update
parent::__construct($API);
$this->blocked = $rawPeerBlocked['blocked'];
$this->stories = $rawPeerBlocked['blocked_my_stories_from'];
$this->userId = $API->getIdInternal($rawPeerBlocked['peer_id']);
$this->userId = $API->getIdInternal($rawPeerBlocked);
}
}

View File

@ -187,39 +187,31 @@ trait PeerHandler
case 'updateDialogPinned':
case 'updateDialogUnreadMark':
case 'updateNotifySettings':
$id = $id['peer'];
// no break
case 'updateDraftMessage':
case 'inputDialogPeer':
case 'dialogPeer':
case 'inputNotifyPeer':
case 'notifyPeer':
case 'dialog':
case 'help.proxyDataPromo':
case 'updateReadHistoryInbox':
case 'updateReadHistoryOutbox':
case 'updateChatDefaultBannedRights':
case 'updateDeleteScheduledMessages':
case 'updateSentStoryReaction':
case 'updateBotCommands':
case 'updateBotChatInviteRequester':
case 'updatePendingJoinRequests':
case 'updateStory':
case 'dialog':
case 'dialogPeer':
case 'notifyPeer':
case 'help.proxyDataPromo':
case 'folderPeer':
case 'inputDialogPeer':
case 'inputNotifyPeer':
case 'inputFolderPeer':
return $this->getIdInternal($id['peer']);
case 'inputUserFromMessage':
case 'inputPeerUserFromMessage':
return $id['user_id'];
case 'inputChannelFromMessage':
case 'inputPeerChannelFromMessage':
case 'updateChannelParticipant':
return DialogId::fromSupergroupOrChannel($id['channel_id']);
case 'inputUserSelf':
case 'inputPeerSelf':
return $this->authorization['user']['id'];
case 'user':
return $id['id'];
case 'userFull':
return $id['id'];
case 'inputPeerUser':
case 'inputUser':
case 'peerUser':
case 'messageEntityMentionName':
case 'messageActionChatDeleteUser':
return $id['user_id'];
case 'messageActionChatJoinedByLink':
return $id['inviter_id'];
case 'chat':
@ -233,10 +225,7 @@ trait PeerHandler
case 'channel':
case 'channelFull':
return DialogId::fromSupergroupOrChannel($id['id']);
case 'inputPeerChannel':
case 'inputChannel':
case 'peerChannel':
return DialogId::fromSupergroupOrChannel($id['channel_id']);
case 'updatePeerBlocked':
case 'message':
case 'messageService':
if (!isset($id['from_id']) // No other option
@ -248,6 +237,11 @@ trait PeerHandler
return $this->getIdInternal($id['peer_id']);
}
return $this->getIdInternal($id['from_id']);
case 'peerChannel':
case 'inputChannel':
case 'inputPeerChannel':
case 'inputChannelFromMessage':
case 'inputPeerChannelFromMessage':
case 'updateChannelReadMessagesContents':
case 'updateChannelAvailableMessages':
case 'updateChannel':
@ -258,6 +252,10 @@ trait PeerHandler
case 'updateDeleteChannelMessages':
case 'updateChannelPinnedMessage':
case 'updateChannelTooLong':
case 'updateChannelParticipant':
case 'updatePinnedChannelMessages':
case 'updateChannelMessageForwards':
case 'updateChannelUserTyping':
return DialogId::fromSupergroupOrChannel($id['channel_id']);
case 'updateChatParticipants':
$id = $id['participants'];
@ -269,6 +267,7 @@ trait PeerHandler
case 'updateChatAdmins':
case 'updateChatPinnedMessage':
return -$id['chat_id'];
case 'contact':
case 'updateUserTyping':
case 'updateUserStatus':
case 'updateUserName':
@ -285,13 +284,18 @@ trait PeerHandler
case 'updateBotShippingQuery':
case 'updateUserPinnedMessage':
case 'updateUser':
case 'contact':
case 'updateUserEmojiStatus':
case 'updateBotStopped':
case 'inputUserFromMessage':
case 'inputPeerUserFromMessage':
case 'inputPeerUser':
case 'inputUser':
case 'peerUser':
case 'messageEntityMentionName':
case 'messageActionChatDeleteUser':
return $id['user_id'];
case 'updatePhoneCall':
return $id['phone_call']->getOtherID();
case 'updateReadHistoryInbox':
case 'updateReadHistoryOutbox':
return $this->getIdInternal($id['peer']);
case 'updateNewMessage':
case 'updateNewChannelMessage':
case 'updateEditMessage':