mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Pass correct response timestamp to tgcalls.
This commit is contained in:
parent
267e5fd9e0
commit
74c21039b3
5 changed files with 32 additions and 31 deletions
|
@ -68,6 +68,10 @@ constexpr auto kPlayConnectingEach = crl::time(1056) + 2 * crl::time(1000);
|
||||||
return (i != end(participants)) ? &*i : nullptr;
|
return (i != end(participants)) ? &*i : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] double TimestampFromMsgId(mtpMsgId msgId) {
|
||||||
|
return msgId / double(1ULL << 32);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class GroupCall::LoadPartTask final : public tgcalls::BroadcastPartTask {
|
class GroupCall::LoadPartTask final : public tgcalls::BroadcastPartTask {
|
||||||
|
@ -102,7 +106,7 @@ private:
|
||||||
not_null<PeerData*> participantPeer) {
|
not_null<PeerData*> participantPeer) {
|
||||||
const auto user = participantPeer->asUser();
|
const auto user = participantPeer->asUser();
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return false; // #TODO calls
|
return false;
|
||||||
}
|
}
|
||||||
if (const auto chat = peer->asChat()) {
|
if (const auto chat = peer->asChat()) {
|
||||||
return chat->admins.contains(user)
|
return chat->admins.contains(user)
|
||||||
|
@ -509,13 +513,17 @@ void GroupCall::applyMeInCallLocally() {
|
||||||
: Group::kDefaultVolume;
|
: Group::kDefaultVolume;
|
||||||
const auto canSelfUnmute = (muted() != MuteState::ForceMuted)
|
const auto canSelfUnmute = (muted() != MuteState::ForceMuted)
|
||||||
&& (muted() != MuteState::RaisedHand);
|
&& (muted() != MuteState::RaisedHand);
|
||||||
|
const auto raisedHandRating = (i != end(participants))
|
||||||
|
? i->raisedHandRating
|
||||||
|
: uint64(0);
|
||||||
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
|
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
|
||||||
| (lastActive ? Flag::f_active_date : Flag(0))
|
| (lastActive ? Flag::f_active_date : Flag(0))
|
||||||
| (_mySsrc ? Flag(0) : Flag::f_left)
|
| (_mySsrc ? Flag(0) : Flag::f_left)
|
||||||
| Flag::f_self
|
| Flag::f_self
|
||||||
| Flag::f_volume // Without flag the volume is reset to 100%.
|
| Flag::f_volume // Without flag the volume is reset to 100%.
|
||||||
| Flag::f_volume_by_admin // Self volume can only be set by admin.
|
| Flag::f_volume_by_admin // Self volume can only be set by admin.
|
||||||
| ((muted() != MuteState::Active) ? Flag::f_muted : Flag(0));
|
| ((muted() != MuteState::Active) ? Flag::f_muted : Flag(0))
|
||||||
|
| (raisedHandRating > 0 ? Flag::f_raise_hand_rating : Flag(0));
|
||||||
call->applyUpdateChecked(
|
call->applyUpdateChecked(
|
||||||
MTP_updateGroupCallParticipants(
|
MTP_updateGroupCallParticipants(
|
||||||
inputCall(),
|
inputCall(),
|
||||||
|
@ -528,8 +536,8 @@ void GroupCall::applyMeInCallLocally() {
|
||||||
MTP_int(lastActive),
|
MTP_int(lastActive),
|
||||||
MTP_int(_mySsrc),
|
MTP_int(_mySsrc),
|
||||||
MTP_int(volume),
|
MTP_int(volume),
|
||||||
MTPstring(), // #TODO calls about
|
MTPstring(), // Don't update about text in local updates.
|
||||||
MTPlong())), // #TODO calls raise hand rating
|
MTP_long(raisedHandRating))),
|
||||||
MTP_int(0)).c_updateGroupCallParticipants());
|
MTP_int(0)).c_updateGroupCallParticipants());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -557,7 +565,10 @@ void GroupCall::applyParticipantLocally(
|
||||||
| (participant->lastActive ? Flag::f_active_date : Flag(0))
|
| (participant->lastActive ? Flag::f_active_date : Flag(0))
|
||||||
| (isMuted ? Flag::f_muted : Flag(0))
|
| (isMuted ? Flag::f_muted : Flag(0))
|
||||||
| (isMutedByYou ? Flag::f_muted_by_you : Flag(0))
|
| (isMutedByYou ? Flag::f_muted_by_you : Flag(0))
|
||||||
| (participantPeer == _joinAs ? Flag::f_self : Flag(0));
|
| (participantPeer == _joinAs ? Flag::f_self : Flag(0))
|
||||||
|
| (participant->raisedHandRating
|
||||||
|
? Flag::f_raise_hand_rating
|
||||||
|
: Flag(0));
|
||||||
_peer->groupCall()->applyUpdateChecked(
|
_peer->groupCall()->applyUpdateChecked(
|
||||||
MTP_updateGroupCallParticipants(
|
MTP_updateGroupCallParticipants(
|
||||||
inputCall(),
|
inputCall(),
|
||||||
|
@ -570,8 +581,8 @@ void GroupCall::applyParticipantLocally(
|
||||||
MTP_int(participant->lastActive),
|
MTP_int(participant->lastActive),
|
||||||
MTP_int(participant->ssrc),
|
MTP_int(participant->ssrc),
|
||||||
MTP_int(volume.value_or(participant->volume)),
|
MTP_int(volume.value_or(participant->volume)),
|
||||||
MTPstring(), // #TODO calls about
|
MTPstring(), // Don't update about text in local updates.
|
||||||
MTPlong())), // #TODO calls raise hand rating
|
MTP_long(participant->raisedHandRating))),
|
||||||
MTP_int(0)).c_updateGroupCallParticipants());
|
MTP_int(0)).c_updateGroupCallParticipants());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,14 +1039,16 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
MTP_int(scale)),
|
MTP_int(scale)),
|
||||||
MTP_int(0),
|
MTP_int(0),
|
||||||
MTP_int(128 * 1024)
|
MTP_int(128 * 1024)
|
||||||
)).done([=](const MTPupload_File &result) {
|
)).done([=](
|
||||||
|
const MTPupload_File &result,
|
||||||
|
const MTP::Response &response) {
|
||||||
result.match([&](const MTPDupload_file &data) {
|
result.match([&](const MTPDupload_file &data) {
|
||||||
const auto size = data.vbytes().v.size();
|
const auto size = data.vbytes().v.size();
|
||||||
auto bytes = std::vector<uint8_t>(size);
|
auto bytes = std::vector<uint8_t>(size);
|
||||||
memcpy(bytes.data(), data.vbytes().v.constData(), size);
|
memcpy(bytes.data(), data.vbytes().v.constData(), size);
|
||||||
finish({
|
finish({
|
||||||
.timestampMilliseconds = time,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = TimestampFromMsgId(response.outerMsgId),
|
||||||
.status = Status::Success,
|
.status = Status::Success,
|
||||||
.oggData = std::move(bytes),
|
.oggData = std::move(bytes),
|
||||||
});
|
});
|
||||||
|
@ -1043,11 +1056,11 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
LOG(("Voice Chat Stream Error: fileCdnRedirect received."));
|
LOG(("Voice Chat Stream Error: fileCdnRedirect received."));
|
||||||
finish({
|
finish({
|
||||||
.timestampMilliseconds = time,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = TimestampFromMsgId(response.outerMsgId),
|
||||||
.status = Status::ResyncNeeded,
|
.status = Status::ResyncNeeded,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error, const MTP::Response &response) {
|
||||||
if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) {
|
if (error.type() == u"GROUPCALL_JOIN_MISSING"_q) {
|
||||||
for (const auto &[task, part] : _broadcastParts) {
|
for (const auto &[task, part] : _broadcastParts) {
|
||||||
_api.request(part.requestId).cancel();
|
_api.request(part.requestId).cancel();
|
||||||
|
@ -1061,7 +1074,7 @@ void GroupCall::broadcastPartStart(std::shared_ptr<LoadPartTask> task) {
|
||||||
: Status::ResyncNeeded;
|
: Status::ResyncNeeded;
|
||||||
finish({
|
finish({
|
||||||
.timestampMilliseconds = time,
|
.timestampMilliseconds = time,
|
||||||
.responseTimestamp = (time / 1000.) + 1., // #TODO calls extract from mtproto
|
.responseTimestamp = TimestampFromMsgId(response.outerMsgId),
|
||||||
.status = status,
|
.status = status,
|
||||||
});
|
});
|
||||||
}).handleAllErrors().toDC(
|
}).handleAllErrors().toDC(
|
||||||
|
@ -1368,7 +1381,7 @@ void GroupCall::editParticipant(
|
||||||
inputCall(),
|
inputCall(),
|
||||||
participantPeer->input,
|
participantPeer->input,
|
||||||
MTP_int(std::clamp(volume.value_or(0), 1, Group::kMaxVolume)),
|
MTP_int(std::clamp(volume.value_or(0), 1, Group::kMaxVolume)),
|
||||||
MTPBool() // #TODO calls raise_hand
|
MTPBool()
|
||||||
)).done([=](const MTPUpdates &result) {
|
)).done([=](const MTPUpdates &result) {
|
||||||
_peer->session().api().applyUpdates(result);
|
_peer->session().api().applyUpdates(result);
|
||||||
}).fail([=](const RPCError &error) {
|
}).fail([=](const RPCError &error) {
|
||||||
|
|
|
@ -1554,9 +1554,9 @@ base::unique_qptr<Ui::PopupMenu> MembersController::createRowContextMenu(
|
||||||
const auto canKick = [&] {
|
const auto canKick = [&] {
|
||||||
const auto user = participantPeer->asUser();
|
const auto user = participantPeer->asUser();
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return false; // #TODO calls can kick
|
return false;
|
||||||
}
|
} else if (static_cast<Row*>(row.get())->state()
|
||||||
if (static_cast<Row*>(row.get())->state() == Row::State::Invited) {
|
== Row::State::Invited) {
|
||||||
return false;
|
return false;
|
||||||
} else if (const auto chat = _peer->asChat()) {
|
} else if (const auto chat = _peer->asChat()) {
|
||||||
return chat->amCreator()
|
return chat->amCreator()
|
||||||
|
@ -1801,7 +1801,7 @@ void GroupMembers::setupAddMember(not_null<GroupCall*> call) {
|
||||||
|
|
||||||
const auto peer = call->peer();
|
const auto peer = call->peer();
|
||||||
if (peer->isBroadcast()) {
|
if (peer->isBroadcast()) {
|
||||||
_canAddMembers = false; // #TODO calls invite members?
|
_canAddMembers = false;
|
||||||
} else {
|
} else {
|
||||||
_canAddMembers = Data::CanWriteValue(peer.get());
|
_canAddMembers = Data::CanWriteValue(peer.get());
|
||||||
SubscribeToMigration(
|
SubscribeToMigration(
|
||||||
|
|
|
@ -496,7 +496,7 @@ void GroupPanel::initWithCall(GroupCall *call) {
|
||||||
_members->kickParticipantRequests(
|
_members->kickParticipantRequests(
|
||||||
) | rpl::start_with_next([=](not_null<PeerData*> participantPeer) {
|
) | rpl::start_with_next([=](not_null<PeerData*> participantPeer) {
|
||||||
if (const auto user = participantPeer->asUser()) {
|
if (const auto user = participantPeer->asUser()) {
|
||||||
kickMember(user); // #TODO calls kick
|
kickMember(user);
|
||||||
}
|
}
|
||||||
}, _callLifetime);
|
}, _callLifetime);
|
||||||
|
|
||||||
|
|
|
@ -5622,12 +5622,7 @@ void HistoryWidget::setupGroupCallTracker() {
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
const auto peer = _history->peer;
|
const auto peer = _history->peer;
|
||||||
const auto channel = peer->asChannel();
|
const auto channel = peer->asChannel();
|
||||||
/*if (channel && channel->amAnonymous()) { // #TODO calls
|
if (peer->groupCall()) {
|
||||||
Ui::ShowMultilineToast({
|
|
||||||
.text = { tr::lng_group_call_no_anonymous(tr::now) },
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
} else */if (peer->groupCall()) {
|
|
||||||
controller()->startOrJoinGroupCall(peer);
|
controller()->startOrJoinGroupCall(peer);
|
||||||
}
|
}
|
||||||
}, _groupCallBar->lifetime());
|
}, _groupCallBar->lifetime());
|
||||||
|
|
|
@ -950,13 +950,6 @@ void SessionController::startOrJoinGroupCall(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
QString joinHash,
|
QString joinHash,
|
||||||
bool confirmedLeaveOther) {
|
bool confirmedLeaveOther) {
|
||||||
//const auto channel = peer->asChannel(); // #TODO calls
|
|
||||||
//if (channel && channel->amAnonymous()) {
|
|
||||||
// Ui::ShowMultilineToast({
|
|
||||||
// .text = { tr::lng_group_call_no_anonymous(tr::now) },
|
|
||||||
// });
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
auto &calls = Core::App().calls();
|
auto &calls = Core::App().calls();
|
||||||
const auto confirm = [&](QString text, QString button) {
|
const auto confirm = [&](QString text, QString button) {
|
||||||
Ui::show(Box<ConfirmBox>(text, button, crl::guard(this, [=] {
|
Ui::show(Box<ConfirmBox>(text, button, crl::guard(this, [=] {
|
||||||
|
|
Loading…
Add table
Reference in a new issue