mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 06:35:14 +00:00
FullMsgId rely on PeerId instead of ChannelId.
This commit is contained in:
@@ -1105,12 +1105,14 @@ QString AppendShareGameScoreUrl(
|
||||
const FullMsgId &fullId) {
|
||||
auto shareHashData = QByteArray(0x20, Qt::Uninitialized);
|
||||
auto shareHashDataInts = reinterpret_cast<uint64*>(shareHashData.data());
|
||||
auto channel = fullId.channel
|
||||
? session->data().channelLoaded(fullId.channel)
|
||||
: static_cast<ChannelData*>(nullptr);
|
||||
auto channelAccessHash = uint64(channel ? channel->access : 0);
|
||||
const auto peer = fullId.peer
|
||||
? session->data().peerLoaded(fullId.peer)
|
||||
: static_cast<PeerData*>(nullptr);
|
||||
const auto channelAccessHash = uint64((peer && peer->isChannel())
|
||||
? peer->asChannel()->access
|
||||
: 0);
|
||||
shareHashDataInts[0] = session->userId().bare;
|
||||
shareHashDataInts[1] = fullId.channel.bare;
|
||||
shareHashDataInts[1] = fullId.peer.value;
|
||||
shareHashDataInts[2] = uint64(fullId.msg.bare);
|
||||
shareHashDataInts[3] = channelAccessHash;
|
||||
|
||||
@@ -1190,31 +1192,22 @@ void ShareGameScoreByHash(
|
||||
return;
|
||||
}
|
||||
|
||||
// Check first 32 bits of channel access hash.
|
||||
auto channelAccessHash = hashDataInts[3];
|
||||
//auto channelAccessHashInts = reinterpret_cast<int32*>(&channelAccessHash);
|
||||
//if (channelAccessHashInts[0] != hashDataInts[3]) {
|
||||
// Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (((hashDataInts[1] >> 40) != 0)
|
||||
|| (!hashDataInts[1] && channelAccessHash)) {
|
||||
const auto peerId = PeerId(hashDataInts[1]);
|
||||
const auto channelAccessHash = hashDataInts[3];
|
||||
if (!peerIsChannel(peerId) && channelAccessHash) {
|
||||
// If there is no channel id, there should be no channel access_hash.
|
||||
Ui::show(Box<Ui::InformBox>(tr::lng_share_wrong_user(tr::now)));
|
||||
return;
|
||||
}
|
||||
|
||||
auto channelId = ChannelId(hashDataInts[1]);
|
||||
auto msgId = MsgId(int64(hashDataInts[2]));
|
||||
if (const auto item = session->data().message(channelId, msgId)) {
|
||||
const auto msgId = MsgId(int64(hashDataInts[2]));
|
||||
if (const auto item = session->data().message(peerId, msgId)) {
|
||||
FastShareMessage(item);
|
||||
} else {
|
||||
auto resolveMessageAndShareScore = [=](ChannelData *channel) {
|
||||
session->api().requestMessageData(channel, msgId, [=](
|
||||
ChannelData *channel,
|
||||
MsgId msgId) {
|
||||
if (const auto item = session->data().message(channel, msgId)) {
|
||||
auto resolveMessageAndShareScore = [=](PeerData *peer) {
|
||||
session->api().requestMessageData(peer, msgId, [=] {
|
||||
const auto item = session->data().message(peerId, msgId);
|
||||
if (item) {
|
||||
FastShareMessage(item);
|
||||
} else {
|
||||
Ui::show(Box<Ui::InformBox>(
|
||||
@@ -1223,24 +1216,24 @@ void ShareGameScoreByHash(
|
||||
});
|
||||
};
|
||||
|
||||
const auto channel = channelId
|
||||
? session->data().channelLoaded(channelId)
|
||||
const auto peer = peerIsChannel(peerId)
|
||||
? session->data().peerLoaded(peerId)
|
||||
: nullptr;
|
||||
if (channel || !channelId) {
|
||||
resolveMessageAndShareScore(channel);
|
||||
if (peer || !peerIsChannel(peerId)) {
|
||||
resolveMessageAndShareScore(peer);
|
||||
} else {
|
||||
session->api().request(MTPchannels_GetChannels(
|
||||
MTP_vector<MTPInputChannel>(
|
||||
1,
|
||||
MTP_inputChannel(
|
||||
MTP_long(channelId.bare),
|
||||
MTP_long(peerToChannel(peerId).bare),
|
||||
MTP_long(channelAccessHash)))
|
||||
)).done([=](const MTPmessages_Chats &result) {
|
||||
result.match([&](const auto &data) {
|
||||
session->data().processChats(data.vchats());
|
||||
});
|
||||
if (const auto channel = session->data().channelLoaded(channelId)) {
|
||||
resolveMessageAndShareScore(channel);
|
||||
if (const auto peer = session->data().peerLoaded(peerId)) {
|
||||
resolveMessageAndShareScore(peer);
|
||||
}
|
||||
}).send();
|
||||
}
|
||||
|
Reference in New Issue
Block a user