Fix creating a scheduled voice chat.
This commit is contained in:
parent
99501d844d
commit
e5ac7a1416
|
@ -406,13 +406,6 @@ void GroupCall::join(const MTPInputGroupCall &inputCall) {
|
|||
_accessHash = data.vaccess_hash().v;
|
||||
});
|
||||
setState(_scheduleDate ? State::Waiting : State::Joining);
|
||||
if (const auto chat = _peer->asChat()) {
|
||||
chat->setGroupCall(inputCall);
|
||||
} else if (const auto group = _peer->asChannel()) {
|
||||
group->setGroupCall(inputCall);
|
||||
} else {
|
||||
Unexpected("Peer type in GroupCall::join.");
|
||||
}
|
||||
|
||||
if (_scheduleDate) {
|
||||
return;
|
||||
|
@ -835,7 +828,18 @@ void GroupCall::handlePossibleCreateOrJoinResponse(
|
|||
}
|
||||
if (_acceptFields) {
|
||||
if (!_instance && !_id) {
|
||||
join(MTP_inputGroupCall(data.vid(), data.vaccess_hash()));
|
||||
const auto input = MTP_inputGroupCall(
|
||||
data.vid(),
|
||||
data.vaccess_hash());
|
||||
const auto scheduleDate = data.vschedule_date().value_or_empty();
|
||||
if (const auto chat = _peer->asChat()) {
|
||||
chat->setGroupCall(input, scheduleDate);
|
||||
} else if (const auto group = _peer->asChannel()) {
|
||||
group->setGroupCall(input, scheduleDate);
|
||||
} else {
|
||||
Unexpected("Peer type in GroupCall::join.");
|
||||
}
|
||||
join(input);
|
||||
}
|
||||
return;
|
||||
} else if (_id != data.vid().v || !_instance) {
|
||||
|
|
|
@ -411,6 +411,14 @@ void Instance::handleCallUpdate(
|
|||
void Instance::handleGroupCallUpdate(
|
||||
not_null<Main::Session*> session,
|
||||
const MTPUpdate &update) {
|
||||
if (_currentGroupCall
|
||||
&& (&_currentGroupCall->peer()->session() == session)) {
|
||||
update.match([&](const MTPDupdateGroupCall &data) {
|
||||
_currentGroupCall->handlePossibleCreateOrJoinResponse(data);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
|
||||
const auto callId = update.match([](const MTPDupdateGroupCall &data) {
|
||||
return data.vcall().match([](const auto &data) {
|
||||
return data.vid().v;
|
||||
|
@ -427,14 +435,6 @@ void Instance::handleGroupCallUpdate(
|
|||
} else {
|
||||
applyGroupCallUpdateChecked(session, update);
|
||||
}
|
||||
|
||||
if (_currentGroupCall
|
||||
&& (&_currentGroupCall->peer()->session() == session)) {
|
||||
update.match([&](const MTPDupdateGroupCall &data) {
|
||||
_currentGroupCall->handlePossibleCreateOrJoinResponse(data);
|
||||
}, [](const auto &) {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void Instance::applyGroupCallUpdateChecked(
|
||||
|
|
|
@ -697,7 +697,9 @@ void ChannelData::migrateCall(std::unique_ptr<Data::GroupCall> call) {
|
|||
addFlags(MTPDchannel::Flag::f_call_active);
|
||||
}
|
||||
|
||||
void ChannelData::setGroupCall(const MTPInputGroupCall &call) {
|
||||
void ChannelData::setGroupCall(
|
||||
const MTPInputGroupCall &call,
|
||||
TimeId scheduleDate) {
|
||||
call.match([&](const MTPDinputGroupCall &data) {
|
||||
if (_call && _call->id() == data.vid().v) {
|
||||
return;
|
||||
|
@ -714,7 +716,8 @@ void ChannelData::setGroupCall(const MTPInputGroupCall &call) {
|
|||
_call = std::make_unique<Data::GroupCall>(
|
||||
this,
|
||||
data.vid().v,
|
||||
data.vaccess_hash().v);
|
||||
data.vaccess_hash().v,
|
||||
scheduleDate);
|
||||
owner().registerGroupCall(_call.get());
|
||||
session().changes().peerUpdated(this, UpdateFlag::GroupCall);
|
||||
addFlags(MTPDchannel::Flag::f_call_active);
|
||||
|
|
|
@ -410,7 +410,9 @@ public:
|
|||
return _call.get();
|
||||
}
|
||||
void migrateCall(std::unique_ptr<Data::GroupCall> call);
|
||||
void setGroupCall(const MTPInputGroupCall &call);
|
||||
void setGroupCall(
|
||||
const MTPInputGroupCall &call,
|
||||
TimeId scheduleDate = 0);
|
||||
void clearGroupCall();
|
||||
void setGroupCallDefaultJoinAs(PeerId peerId);
|
||||
[[nodiscard]] PeerId groupCallDefaultJoinAs() const;
|
||||
|
|
|
@ -194,7 +194,9 @@ void ChatData::setMigrateToChannel(ChannelData *channel) {
|
|||
}
|
||||
}
|
||||
|
||||
void ChatData::setGroupCall(const MTPInputGroupCall &call) {
|
||||
void ChatData::setGroupCall(
|
||||
const MTPInputGroupCall &call,
|
||||
TimeId scheduleDate) {
|
||||
if (migrateTo()) {
|
||||
return;
|
||||
}
|
||||
|
@ -214,7 +216,8 @@ void ChatData::setGroupCall(const MTPInputGroupCall &call) {
|
|||
_call = std::make_unique<Data::GroupCall>(
|
||||
this,
|
||||
data.vid().v,
|
||||
data.vaccess_hash().v);
|
||||
data.vaccess_hash().v,
|
||||
scheduleDate);
|
||||
owner().registerGroupCall(_call.get());
|
||||
session().changes().peerUpdated(this, UpdateFlag::GroupCall);
|
||||
addFlags(MTPDchat::Flag::f_call_active);
|
||||
|
|
|
@ -166,7 +166,9 @@ public:
|
|||
[[nodiscard]] Data::GroupCall *groupCall() const {
|
||||
return _call.get();
|
||||
}
|
||||
void setGroupCall(const MTPInputGroupCall &call);
|
||||
void setGroupCall(
|
||||
const MTPInputGroupCall &call,
|
||||
TimeId scheduleDate = 0);
|
||||
void clearGroupCall();
|
||||
void setGroupCallDefaultJoinAs(PeerId peerId);
|
||||
[[nodiscard]] PeerId groupCallDefaultJoinAs() const;
|
||||
|
|
|
@ -38,12 +38,14 @@ constexpr auto kWaitForUpdatesTimeout = 3 * crl::time(1000);
|
|||
GroupCall::GroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
uint64 id,
|
||||
uint64 accessHash)
|
||||
uint64 accessHash,
|
||||
TimeId scheduleDate)
|
||||
: _id(id)
|
||||
, _accessHash(accessHash)
|
||||
, _peer(peer)
|
||||
, _reloadByQueuedUpdatesTimer([=] { reload(); })
|
||||
, _speakingByActiveFinishTimer([=] { checkFinishSpeakingByActive(); }) {
|
||||
, _speakingByActiveFinishTimer([=] { checkFinishSpeakingByActive(); })
|
||||
, _scheduleDate(scheduleDate) {
|
||||
}
|
||||
|
||||
GroupCall::~GroupCall() {
|
||||
|
|
|
@ -38,7 +38,11 @@ struct GroupCallParticipant {
|
|||
|
||||
class GroupCall final {
|
||||
public:
|
||||
GroupCall(not_null<PeerData*> peer, uint64 id, uint64 accessHash);
|
||||
GroupCall(
|
||||
not_null<PeerData*> peer,
|
||||
uint64 id,
|
||||
uint64 accessHash,
|
||||
TimeId scheduleDate);
|
||||
~GroupCall();
|
||||
|
||||
[[nodiscard]] uint64 id() const;
|
||||
|
|
|
@ -856,13 +856,6 @@ void History::applyServiceChanges(
|
|||
not_null<HistoryItem*> item,
|
||||
const MTPDmessageService &data) {
|
||||
const auto replyTo = data.vreply_to();
|
||||
const auto setGroupCallFrom = [&](const auto &data) {
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
channel->setGroupCall(data.vcall());
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
chat->setGroupCall(data.vcall());
|
||||
}
|
||||
};
|
||||
data.vaction().match([&](const MTPDmessageActionChatAddUser &data) {
|
||||
if (const auto megagroup = peer->asMegagroup()) {
|
||||
const auto mgInfo = megagroup->mgInfo.get();
|
||||
|
@ -1015,9 +1008,17 @@ void History::applyServiceChanges(
|
|||
});
|
||||
}
|
||||
}, [&](const MTPDmessageActionGroupCall &data) {
|
||||
setGroupCallFrom(data);
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
channel->setGroupCall(data.vcall());
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
chat->setGroupCall(data.vcall());
|
||||
}
|
||||
}, [&](const MTPDmessageActionGroupCallScheduled &data) {
|
||||
setGroupCallFrom(data);
|
||||
if (const auto channel = peer->asChannel()) {
|
||||
channel->setGroupCall(data.vcall(), data.vschedule_date().v);
|
||||
} else if (const auto chat = peer->asChat()) {
|
||||
chat->setGroupCall(data.vcall(), data.vschedule_date().v);
|
||||
}
|
||||
}, [&](const MTPDmessageActionPaymentSent &data) {
|
||||
if (const auto payment = item->Get<HistoryServicePayment>()) {
|
||||
if (const auto message = payment->msg) {
|
||||
|
|
Loading…
Reference in New Issue