mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Update API scheme.
This commit is contained in:
parent
f41abe0a28
commit
ccd440ea0b
6 changed files with 62 additions and 32 deletions
|
@ -92,7 +92,7 @@ inputPhotoFileLocation#40181ffe id:long access_hash:long file_reference:bytes th
|
||||||
inputPhotoLegacyFileLocation#d83466f3 id:long access_hash:long file_reference:bytes volume_id:long local_id:int secret:long = InputFileLocation;
|
inputPhotoLegacyFileLocation#d83466f3 id:long access_hash:long file_reference:bytes volume_id:long local_id:int secret:long = InputFileLocation;
|
||||||
inputPeerPhotoFileLocation#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation;
|
inputPeerPhotoFileLocation#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation;
|
||||||
inputStickerSetThumb#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation;
|
inputStickerSetThumb#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation;
|
||||||
inputGroupCallStream#d1cc2a5f call:InputGroupCall date:int = InputFileLocation;
|
inputGroupCallStream#bba51639 call:InputGroupCall time_ms:long scale:int = InputFileLocation;
|
||||||
|
|
||||||
peerUser#9db1bc6d user_id:int = Peer;
|
peerUser#9db1bc6d user_id:int = Peer;
|
||||||
peerChat#bad0e5bb chat_id:int = Peer;
|
peerChat#bad0e5bb chat_id:int = Peer;
|
||||||
|
@ -1240,6 +1240,8 @@ messages.chatAdminsWithInvites#b69b72d7 admins:Vector<ChatAdminWithInvites> user
|
||||||
|
|
||||||
messages.checkedHistoryImportPeer#a24de717 confirm_text:string = messages.CheckedHistoryImportPeer;
|
messages.checkedHistoryImportPeer#a24de717 confirm_text:string = messages.CheckedHistoryImportPeer;
|
||||||
|
|
||||||
|
phone.joinAsPeers#afe5623f peers:Vector<Peer> chats:Vector<Chat> users:Vector<User> = phone.JoinAsPeers;
|
||||||
|
|
||||||
---functions---
|
---functions---
|
||||||
|
|
||||||
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
|
||||||
|
@ -1623,6 +1625,7 @@ phone.checkGroupCall#b74a7bea call:InputGroupCall source:int = Bool;
|
||||||
phone.toggleGroupCallRecord#c02a66d7 flags:# start:flags.0?true call:InputGroupCall title:flags.1?string = Updates;
|
phone.toggleGroupCallRecord#c02a66d7 flags:# start:flags.0?true call:InputGroupCall title:flags.1?string = Updates;
|
||||||
phone.editGroupCallParticipant#d975eb80 flags:# muted:flags.0?true call:InputGroupCall participant:InputPeer volume:flags.1?int raise_hand:flags.2?Bool = Updates;
|
phone.editGroupCallParticipant#d975eb80 flags:# muted:flags.0?true call:InputGroupCall participant:InputPeer volume:flags.1?int raise_hand:flags.2?Bool = Updates;
|
||||||
phone.editGroupCallTitle#1ca6ac0a call:InputGroupCall title:string = Updates;
|
phone.editGroupCallTitle#1ca6ac0a call:InputGroupCall title:string = Updates;
|
||||||
|
phone.getGroupCallJoinAs#ef7c213a peer:InputPeer = phone.JoinAsPeers;
|
||||||
|
|
||||||
langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference;
|
langpack.getLangPack#f2f2330a lang_pack:string lang_code:string = LangPackDifference;
|
||||||
langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector<string> = Vector<LangPackString>;
|
langpack.getStrings#efea3803 lang_pack:string lang_code:string keys:Vector<string> = Vector<LangPackString>;
|
||||||
|
|
|
@ -163,20 +163,18 @@ void ChooseJoinAsProcess::start(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Context context,
|
Context context,
|
||||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||||
|
Fn<void(QString)> showToast,
|
||||||
Fn<void(JoinInfo)> done,
|
Fn<void(JoinInfo)> done,
|
||||||
PeerData *currentJoinAs) {
|
PeerData *currentJoinAs) {
|
||||||
Expects(done != nullptr);
|
Expects(done != nullptr);
|
||||||
|
|
||||||
const auto session = &peer->session();
|
const auto session = &peer->session();
|
||||||
if (_request) {
|
if (_request) {
|
||||||
const auto already = _request->peer;
|
if (_request->peer == peer) {
|
||||||
_request->context = context;
|
_request->context = context;
|
||||||
_request->showBox = std::move(showBox);
|
_request->showBox = std::move(showBox);
|
||||||
_request->done = std::move(done);
|
_request->showToast = std::move(showToast);
|
||||||
if (already == peer) {
|
_request->done = std::move(done);
|
||||||
return;
|
|
||||||
} else if (&already->session() == session) {
|
|
||||||
_request->peer = peer;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session->api().request(_request->id).cancel();
|
session->api().request(_request->id).cancel();
|
||||||
|
@ -186,6 +184,7 @@ void ChooseJoinAsProcess::start(
|
||||||
ChannelsListRequest{
|
ChannelsListRequest{
|
||||||
.peer = peer,
|
.peer = peer,
|
||||||
.showBox = std::move(showBox),
|
.showBox = std::move(showBox),
|
||||||
|
.showToast = std::move(showToast),
|
||||||
.done = std::move(done),
|
.done = std::move(done),
|
||||||
.context = context });
|
.context = context });
|
||||||
session->account().sessionChanges(
|
session->account().sessionChanges(
|
||||||
|
@ -204,39 +203,52 @@ void ChooseJoinAsProcess::start(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
using Flag = MTPchannels_GetAdminedPublicChannels::Flag;
|
using Flag = MTPchannels_GetAdminedPublicChannels::Flag;
|
||||||
_request->id = session->api().request(
|
_request->id = session->api().request(MTPphone_GetGroupCallJoinAs(
|
||||||
MTPchannels_GetAdminedPublicChannels(
|
_request->peer->input
|
||||||
MTP_flags(Flag::f_for_groupcall))
|
)).done([=](const MTPphone_JoinAsPeers &result) {
|
||||||
).done([=](const MTPmessages_Chats &result) {
|
|
||||||
const auto &chats = result.match([](const auto &data) {
|
|
||||||
return data.vchats().v;
|
|
||||||
});
|
|
||||||
const auto peer = _request->peer;
|
const auto peer = _request->peer;
|
||||||
const auto self = peer->session().user();
|
const auto self = peer->session().user();
|
||||||
auto info = JoinInfo{ .peer = peer, .joinAs = self };
|
auto info = JoinInfo{ .peer = peer, .joinAs = self };
|
||||||
if (chats.size() == 1) {
|
auto list = result.match([&](const MTPDphone_joinAsPeers &data) {
|
||||||
|
session->data().processUsers(data.vusers());
|
||||||
|
session->data().processChats(data.vchats());
|
||||||
|
const auto &peers = data.vpeers().v;
|
||||||
|
auto list = std::vector<not_null<PeerData*>>();
|
||||||
|
list.reserve(peers.size());
|
||||||
|
for (const auto &peer : peers) {
|
||||||
|
const auto peerId = peerFromMTP(peer);
|
||||||
|
if (const auto peer = session->data().peerLoaded(peerId)) {
|
||||||
|
if (!ranges::contains(list, not_null{ peer })) {
|
||||||
|
list.push_back(peer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
});
|
||||||
|
if (list.empty()) {
|
||||||
|
_request->showToast("No way to join this voice chat :(");
|
||||||
|
return;
|
||||||
|
} else if (list.size() == 1 && list.front() == self) {
|
||||||
|
info.possibleJoinAs = std::move(list);
|
||||||
finish(info);
|
finish(info);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto list = std::vector<not_null<PeerData*>>();
|
info.joinAs = [&]() -> not_null<PeerData*> {
|
||||||
list.reserve(chats.size() + 1);
|
|
||||||
list.push_back(self);
|
|
||||||
for (const auto &chat : chats) {
|
|
||||||
list.push_back(session->data().processChat(chat));
|
|
||||||
}
|
|
||||||
const auto selected = [&]() -> PeerData* {
|
|
||||||
const auto selectedId = peer->groupCallDefaultJoinAs();
|
const auto selectedId = peer->groupCallDefaultJoinAs();
|
||||||
if (!selectedId) {
|
if (!selectedId) {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
const auto loaded = session->data().peerLoaded(selectedId);
|
const auto loaded = session->data().peerLoaded(selectedId);
|
||||||
return (loaded && ranges::contains(list, not_null{ loaded }))
|
return (currentJoinAs && ranges::contains(list, not_null{ currentJoinAs }))
|
||||||
|
? not_null(currentJoinAs)
|
||||||
|
: (loaded && ranges::contains(list, not_null{ loaded }))
|
||||||
? not_null(loaded)
|
? not_null(loaded)
|
||||||
: self;
|
: ranges::contains(list, self)
|
||||||
|
? self
|
||||||
|
: list.front();
|
||||||
}();
|
}();
|
||||||
|
|
||||||
info.joinAs = currentJoinAs ? currentJoinAs : selected;
|
|
||||||
info.possibleJoinAs = std::move(list);
|
info.possibleJoinAs = std::move(list);
|
||||||
|
|
||||||
auto box = Box(
|
auto box = Box(
|
||||||
ChooseJoinAsBox,
|
ChooseJoinAsBox,
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -35,6 +35,7 @@ public:
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
Context context,
|
Context context,
|
||||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
Fn<void(object_ptr<Ui::BoxContent>)> showBox,
|
||||||
|
Fn<void(QString)> showToast,
|
||||||
Fn<void(JoinInfo)> done,
|
Fn<void(JoinInfo)> done,
|
||||||
PeerData *currentJoinAs = nullptr);
|
PeerData *currentJoinAs = nullptr);
|
||||||
|
|
||||||
|
@ -42,6 +43,7 @@ private:
|
||||||
struct ChannelsListRequest {
|
struct ChannelsListRequest {
|
||||||
not_null<PeerData*> peer;
|
not_null<PeerData*> peer;
|
||||||
Fn<void(object_ptr<Ui::BoxContent>)> showBox;
|
Fn<void(object_ptr<Ui::BoxContent>)> showBox;
|
||||||
|
Fn<void(QString)> showToast;
|
||||||
Fn<void(JoinInfo)> done;
|
Fn<void(JoinInfo)> done;
|
||||||
base::has_weak_ptr guard;
|
base::has_weak_ptr guard;
|
||||||
QPointer<Ui::BoxContent> box;
|
QPointer<Ui::BoxContent> box;
|
||||||
|
|
|
@ -164,13 +164,18 @@ void GroupCallSettingsBox(
|
||||||
const auto callback = [=](Group::JoinInfo info) {
|
const auto callback = [=](Group::JoinInfo info) {
|
||||||
call->rejoinAs(info);
|
call->rejoinAs(info);
|
||||||
};
|
};
|
||||||
auto showBox = [=](object_ptr<Ui::BoxContent> next) {
|
const auto showBox = [=](object_ptr<Ui::BoxContent> next) {
|
||||||
box->getDelegate()->show(std::move(next));
|
box->getDelegate()->show(std::move(next));
|
||||||
};
|
};
|
||||||
|
const auto showToast = [=](QString text) {
|
||||||
|
const auto container = box->getDelegate()->outerContainer();
|
||||||
|
Ui::Toast::Show(container, text);
|
||||||
|
};
|
||||||
state->joinAsProcess.start(
|
state->joinAsProcess.start(
|
||||||
peer,
|
peer,
|
||||||
context,
|
context,
|
||||||
showBox,
|
showBox,
|
||||||
|
showToast,
|
||||||
callback,
|
callback,
|
||||||
call->joinAs());
|
call->joinAs());
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,6 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "data/data_session.h"
|
#include "data/data_session.h"
|
||||||
#include "media/audio/media_audio_track.h"
|
#include "media/audio/media_audio_track.h"
|
||||||
#include "platform/platform_specific.h"
|
#include "platform/platform_specific.h"
|
||||||
|
#include "ui/toast/toast.h"
|
||||||
#include "base/unixtime.h"
|
#include "base/unixtime.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mtproto/mtproto_config.h"
|
#include "mtproto/mtproto_config.h"
|
||||||
|
@ -66,6 +67,8 @@ void Instance::startOrJoinGroupCall(not_null<PeerData*> peer) {
|
||||||
: Group::ChooseJoinAsProcess::Context::Create;
|
: Group::ChooseJoinAsProcess::Context::Create;
|
||||||
_chooseJoinAs.start(peer, context, [=](object_ptr<Ui::BoxContent> box) {
|
_chooseJoinAs.start(peer, context, [=](object_ptr<Ui::BoxContent> box) {
|
||||||
Ui::show(std::move(box), Ui::LayerOption::KeepOther);
|
Ui::show(std::move(box), Ui::LayerOption::KeepOther);
|
||||||
|
}, [=](QString text) {
|
||||||
|
Ui::Toast::Show(text);
|
||||||
}, [=](Group::JoinInfo info) {
|
}, [=](Group::JoinInfo info) {
|
||||||
const auto call = info.peer->groupCall();
|
const auto call = info.peer->groupCall();
|
||||||
createGroupCall(
|
createGroupCall(
|
||||||
|
|
|
@ -172,7 +172,8 @@ StorageFileLocation::StorageFileLocation(
|
||||||
_id = data.vid().v;
|
_id = data.vid().v;
|
||||||
_accessHash = data.vaccess_hash().v;
|
_accessHash = data.vaccess_hash().v;
|
||||||
});
|
});
|
||||||
_localId = data.vdate().v;
|
_volumeId = data.vtime_ms().v;
|
||||||
|
_localId = data.vscale().v;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -260,6 +261,7 @@ MTPInputFileLocation StorageFileLocation::tl(int32 self) const {
|
||||||
case Type::GroupCallStream:
|
case Type::GroupCallStream:
|
||||||
return MTP_inputGroupCallStream(
|
return MTP_inputGroupCallStream(
|
||||||
MTP_inputGroupCall(MTP_long(_id), MTP_long(_accessHash)),
|
MTP_inputGroupCall(MTP_long(_id), MTP_long(_accessHash)),
|
||||||
|
MTP_long(_volumeId),
|
||||||
MTP_int(_localId));
|
MTP_int(_localId));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -372,7 +374,7 @@ bool StorageFileLocation::valid() const {
|
||||||
return (_dcId != 0) && (_id != 0);
|
return (_dcId != 0) && (_id != 0);
|
||||||
|
|
||||||
case Type::GroupCallStream:
|
case Type::GroupCallStream:
|
||||||
return (_dcId != 0) && (_id != 0) && (_localId != 0);
|
return (_dcId != 0) && (_id != 0) && (_volumeId != 0);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -419,7 +421,10 @@ Storage::Cache::Key StorageFileLocation::cacheKey() const {
|
||||||
|
|
||||||
case Type::GroupCallStream:
|
case Type::GroupCallStream:
|
||||||
return Key{
|
return Key{
|
||||||
shifted | sliced | (uint64(uint32(_localId)) << 16),
|
(shifted
|
||||||
|
| sliced
|
||||||
|
| (uint32(_localId) << 16)
|
||||||
|
| (_volumeId << 20)),
|
||||||
_id };
|
_id };
|
||||||
}
|
}
|
||||||
return Key();
|
return Key();
|
||||||
|
|
Loading…
Add table
Reference in a new issue