mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Invite by link in case of non-self voice chat join.
This commit is contained in:
parent
b487644355
commit
f6175e7b7c
5 changed files with 72 additions and 47 deletions
|
@ -596,7 +596,7 @@ GroupCall::GroupCall(
|
||||||
start(info.scheduleDate);
|
start(info.scheduleDate);
|
||||||
}
|
}
|
||||||
if (_scheduleDate) {
|
if (_scheduleDate) {
|
||||||
saveDefaultJoinAs(_joinAs);
|
saveDefaultJoinAs(joinAs());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ void GroupCall::subscribeToReal(not_null<Data::GroupCall*> real) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const auto peer = data.was ? data.was->peer : data.now->peer;
|
const auto peer = data.was ? data.was->peer : data.now->peer;
|
||||||
if (peer == _joinAs) {
|
if (peer == joinAs()) {
|
||||||
const auto working = data.now && data.now->videoJoined;
|
const auto working = data.now && data.now->videoJoined;
|
||||||
if (videoIsWorking() != working) {
|
if (videoIsWorking() != working) {
|
||||||
fillActiveVideoEndpoints();
|
fillActiveVideoEndpoints();
|
||||||
|
@ -1027,7 +1027,7 @@ void GroupCall::setScreenEndpoint(std::string endpoint) {
|
||||||
if (!_screenEndpoint.empty()) {
|
if (!_screenEndpoint.empty()) {
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Screen,
|
VideoEndpointType::Screen,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_screenEndpoint
|
_screenEndpoint
|
||||||
}, false, false);
|
}, false, false);
|
||||||
}
|
}
|
||||||
|
@ -1038,7 +1038,7 @@ void GroupCall::setScreenEndpoint(std::string endpoint) {
|
||||||
if (isSharingScreen()) {
|
if (isSharingScreen()) {
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Screen,
|
VideoEndpointType::Screen,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_screenEndpoint
|
_screenEndpoint
|
||||||
}, true, isScreenPaused());
|
}, true, isScreenPaused());
|
||||||
}
|
}
|
||||||
|
@ -1051,7 +1051,7 @@ void GroupCall::setCameraEndpoint(std::string endpoint) {
|
||||||
if (!_cameraEndpoint.empty()) {
|
if (!_cameraEndpoint.empty()) {
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Camera,
|
VideoEndpointType::Camera,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_cameraEndpoint
|
_cameraEndpoint
|
||||||
}, false, false);
|
}, false, false);
|
||||||
}
|
}
|
||||||
|
@ -1062,7 +1062,7 @@ void GroupCall::setCameraEndpoint(std::string endpoint) {
|
||||||
if (isSharingCamera()) {
|
if (isSharingCamera()) {
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Camera,
|
VideoEndpointType::Camera,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_cameraEndpoint
|
_cameraEndpoint
|
||||||
}, true, isCameraPaused());
|
}, true, isCameraPaused());
|
||||||
}
|
}
|
||||||
|
@ -1189,7 +1189,7 @@ void GroupCall::markTrackPaused(const VideoEndpoint &endpoint, bool paused) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::rejoin() {
|
void GroupCall::rejoin() {
|
||||||
rejoin(_joinAs);
|
rejoin(joinAs());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::rejoinWithHash(const QString &hash) {
|
void GroupCall::rejoinWithHash(const QString &hash) {
|
||||||
|
@ -1202,9 +1202,9 @@ void GroupCall::rejoinWithHash(const QString &hash) {
|
||||||
void GroupCall::setJoinAs(not_null<PeerData*> as) {
|
void GroupCall::setJoinAs(not_null<PeerData*> as) {
|
||||||
_joinAs = as;
|
_joinAs = as;
|
||||||
if (const auto chat = _peer->asChat()) {
|
if (const auto chat = _peer->asChat()) {
|
||||||
chat->setGroupCallDefaultJoinAs(_joinAs->id);
|
chat->setGroupCallDefaultJoinAs(joinAs()->id);
|
||||||
} else if (const auto channel = _peer->asChannel()) {
|
} else if (const auto channel = _peer->asChannel()) {
|
||||||
channel->setGroupCallDefaultJoinAs(_joinAs->id);
|
channel->setGroupCallDefaultJoinAs(joinAs()->id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1212,7 +1212,7 @@ void GroupCall::saveDefaultJoinAs(not_null<PeerData*> as) {
|
||||||
setJoinAs(as);
|
setJoinAs(as);
|
||||||
_api.request(MTPphone_SaveDefaultGroupCallJoinAs(
|
_api.request(MTPphone_SaveDefaultGroupCallJoinAs(
|
||||||
_peer->input,
|
_peer->input,
|
||||||
_joinAs->input
|
joinAs()->input
|
||||||
)).send();
|
)).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1225,7 +1225,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_joinAs != as) {
|
if (joinAs() != as) {
|
||||||
toggleVideo(false);
|
toggleVideo(false);
|
||||||
toggleScreenSharing(std::nullopt);
|
toggleScreenSharing(std::nullopt);
|
||||||
}
|
}
|
||||||
|
@ -1270,7 +1270,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
|
||||||
_api.request(MTPphone_JoinGroupCall(
|
_api.request(MTPphone_JoinGroupCall(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
inputCall(),
|
inputCall(),
|
||||||
_joinAs->input,
|
joinAs()->input,
|
||||||
MTP_string(_joinHash),
|
MTP_string(_joinHash),
|
||||||
MTP_dataJSON(MTP_bytes(json))
|
MTP_dataJSON(MTP_bytes(json))
|
||||||
)).done([=](const MTPUpdates &updates) {
|
)).done([=](const MTPUpdates &updates) {
|
||||||
|
@ -1451,7 +1451,7 @@ void GroupCall::applyMeInCallLocally() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
using Flag = MTPDgroupCallParticipant::Flag;
|
using Flag = MTPDgroupCallParticipant::Flag;
|
||||||
const auto participant = real->participantByPeer(_joinAs);
|
const auto participant = real->participantByPeer(joinAs());
|
||||||
const auto date = participant
|
const auto date = participant
|
||||||
? participant->date
|
? participant->date
|
||||||
: base::unixtime::now();
|
: base::unixtime::now();
|
||||||
|
@ -1483,7 +1483,7 @@ void GroupCall::applyMeInCallLocally() {
|
||||||
1,
|
1,
|
||||||
MTP_groupCallParticipant(
|
MTP_groupCallParticipant(
|
||||||
MTP_flags(flags),
|
MTP_flags(flags),
|
||||||
peerToMTP(_joinAs->id),
|
peerToMTP(joinAs()->id),
|
||||||
MTP_int(date),
|
MTP_int(date),
|
||||||
MTP_int(lastActive),
|
MTP_int(lastActive),
|
||||||
MTP_int(_joinState.ssrc),
|
MTP_int(_joinState.ssrc),
|
||||||
|
@ -1519,7 +1519,7 @@ 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
|
| (participant->raisedHandRating
|
||||||
? Flag::f_raise_hand_rating
|
? Flag::f_raise_hand_rating
|
||||||
: Flag(0));
|
: Flag(0));
|
||||||
|
@ -1566,11 +1566,11 @@ void GroupCall::discard() {
|
||||||
|
|
||||||
void GroupCall::rejoinAs(Group::JoinInfo info) {
|
void GroupCall::rejoinAs(Group::JoinInfo info) {
|
||||||
_possibleJoinAs = std::move(info.possibleJoinAs);
|
_possibleJoinAs = std::move(info.possibleJoinAs);
|
||||||
if (info.joinAs == _joinAs) {
|
if (info.joinAs == joinAs()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto event = Group::RejoinEvent{
|
const auto event = Group::RejoinEvent{
|
||||||
.wasJoinAs = _joinAs,
|
.wasJoinAs = joinAs(),
|
||||||
.nowJoinAs = info.joinAs,
|
.nowJoinAs = info.joinAs,
|
||||||
};
|
};
|
||||||
if (_scheduleDate) {
|
if (_scheduleDate) {
|
||||||
|
@ -1855,7 +1855,7 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||||
participant.match([&](const MTPDgroupCallParticipant &data) {
|
participant.match([&](const MTPDgroupCallParticipant &data) {
|
||||||
const auto isSelf = data.is_self()
|
const auto isSelf = data.is_self()
|
||||||
|| (data.is_min()
|
|| (data.is_min()
|
||||||
&& peerFromMTP(data.vpeer()) == _joinAs->id);
|
&& peerFromMTP(data.vpeer()) == joinAs()->id);
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
applyOtherParticipantUpdate(data);
|
applyOtherParticipantUpdate(data);
|
||||||
} else if (joined) {
|
} else if (joined) {
|
||||||
|
@ -2057,7 +2057,7 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
sendSelfUpdate(SendUpdateType::CameraPaused);
|
sendSelfUpdate(SendUpdateType::CameraPaused);
|
||||||
markTrackPaused({
|
markTrackPaused({
|
||||||
VideoEndpointType::Camera,
|
VideoEndpointType::Camera,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_cameraEndpoint
|
_cameraEndpoint
|
||||||
}, nowPaused);
|
}, nowPaused);
|
||||||
return;
|
return;
|
||||||
|
@ -2092,7 +2092,7 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
_isSharingCamera = nowActive;
|
_isSharingCamera = nowActive;
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Camera,
|
VideoEndpointType::Camera,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_cameraEndpoint
|
_cameraEndpoint
|
||||||
}, nowActive, nowPaused);
|
}, nowActive, nowPaused);
|
||||||
sendSelfUpdate(SendUpdateType::CameraStopped);
|
sendSelfUpdate(SendUpdateType::CameraStopped);
|
||||||
|
@ -2113,7 +2113,7 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
sendSelfUpdate(SendUpdateType::ScreenPaused);
|
sendSelfUpdate(SendUpdateType::ScreenPaused);
|
||||||
markTrackPaused({
|
markTrackPaused({
|
||||||
VideoEndpointType::Screen,
|
VideoEndpointType::Screen,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_screenEndpoint
|
_screenEndpoint
|
||||||
}, nowPaused);
|
}, nowPaused);
|
||||||
return;
|
return;
|
||||||
|
@ -2160,7 +2160,7 @@ void GroupCall::setupOutgoingVideo() {
|
||||||
_isSharingScreen = nowActive;
|
_isSharingScreen = nowActive;
|
||||||
markEndpointActive({
|
markEndpointActive({
|
||||||
VideoEndpointType::Screen,
|
VideoEndpointType::Screen,
|
||||||
_joinAs,
|
joinAs(),
|
||||||
_screenEndpoint
|
_screenEndpoint
|
||||||
}, nowActive, nowPaused);
|
}, nowActive, nowPaused);
|
||||||
_screenJoinState.nextActionPending = true;
|
_screenJoinState.nextActionPending = true;
|
||||||
|
@ -2607,7 +2607,7 @@ void GroupCall::fillActiveVideoEndpoints() {
|
||||||
const auto real = lookupReal();
|
const auto real = lookupReal();
|
||||||
Assert(real != nullptr);
|
Assert(real != nullptr);
|
||||||
|
|
||||||
const auto me = real->participantByPeer(_joinAs);
|
const auto me = real->participantByPeer(joinAs());
|
||||||
if (me && me->videoJoined) {
|
if (me && me->videoJoined) {
|
||||||
_videoIsWorking = true;
|
_videoIsWorking = true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2642,23 +2642,23 @@ void GroupCall::fillActiveVideoEndpoints() {
|
||||||
const auto camera = GetCameraEndpoint(participant.videoParams);
|
const auto camera = GetCameraEndpoint(participant.videoParams);
|
||||||
if (camera != _cameraEndpoint
|
if (camera != _cameraEndpoint
|
||||||
&& camera != _screenEndpoint
|
&& camera != _screenEndpoint
|
||||||
&& participant.peer != _joinAs) {
|
&& participant.peer != joinAs()) {
|
||||||
const auto paused = IsCameraPaused(participant.videoParams);
|
const auto paused = IsCameraPaused(participant.videoParams);
|
||||||
feedOne({ Type::Camera, participant.peer, camera }, paused);
|
feedOne({ Type::Camera, participant.peer, camera }, paused);
|
||||||
}
|
}
|
||||||
const auto screen = GetScreenEndpoint(participant.videoParams);
|
const auto screen = GetScreenEndpoint(participant.videoParams);
|
||||||
if (screen != _cameraEndpoint
|
if (screen != _cameraEndpoint
|
||||||
&& screen != _screenEndpoint
|
&& screen != _screenEndpoint
|
||||||
&& participant.peer != _joinAs) {
|
&& participant.peer != joinAs()) {
|
||||||
const auto paused = IsScreenPaused(participant.videoParams);
|
const auto paused = IsScreenPaused(participant.videoParams);
|
||||||
feedOne({ Type::Screen, participant.peer, screen }, paused);
|
feedOne({ Type::Screen, participant.peer, screen }, paused);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
feedOne(
|
feedOne(
|
||||||
{ Type::Camera, _joinAs, cameraSharingEndpoint() },
|
{ Type::Camera, joinAs(), cameraSharingEndpoint() },
|
||||||
isCameraPaused());
|
isCameraPaused());
|
||||||
feedOne(
|
feedOne(
|
||||||
{ Type::Screen, _joinAs, screenSharingEndpoint() },
|
{ Type::Screen, joinAs(), screenSharingEndpoint() },
|
||||||
isScreenPaused());
|
isScreenPaused());
|
||||||
if (large && !largeFound) {
|
if (large && !largeFound) {
|
||||||
setVideoEndpointLarge({});
|
setVideoEndpointLarge({});
|
||||||
|
@ -3013,7 +3013,7 @@ void GroupCall::sendSelfUpdate(SendUpdateType type) {
|
||||||
? Flag::f_presentation_paused
|
? Flag::f_presentation_paused
|
||||||
: Flag::f_muted),
|
: Flag::f_muted),
|
||||||
inputCall(),
|
inputCall(),
|
||||||
_joinAs->input,
|
joinAs()->input,
|
||||||
MTP_bool(muted() != MuteState::Active),
|
MTP_bool(muted() != MuteState::Active),
|
||||||
MTP_int(100000), // volume
|
MTP_int(100000), // volume
|
||||||
MTP_bool(muted() == MuteState::RaisedHand),
|
MTP_bool(muted() == MuteState::RaisedHand),
|
||||||
|
|
|
@ -220,7 +220,10 @@ public:
|
||||||
return _peer;
|
return _peer;
|
||||||
}
|
}
|
||||||
[[nodiscard]] not_null<PeerData*> joinAs() const {
|
[[nodiscard]] not_null<PeerData*> joinAs() const {
|
||||||
return _joinAs;
|
return _joinAs.current();
|
||||||
|
}
|
||||||
|
[[nodiscard]] rpl::producer<not_null<PeerData*>> joinAsValue() const {
|
||||||
|
return _joinAs.value();
|
||||||
}
|
}
|
||||||
[[nodiscard]] bool showChooseJoinAs() const;
|
[[nodiscard]] bool showChooseJoinAs() const;
|
||||||
[[nodiscard]] TimeId scheduleDate() const {
|
[[nodiscard]] TimeId scheduleDate() const {
|
||||||
|
@ -566,7 +569,7 @@ private:
|
||||||
MediaChannelDescriptionsTask>,
|
MediaChannelDescriptionsTask>,
|
||||||
base::pointer_comparator<MediaChannelDescriptionsTask>> _mediaChannelDescriptionses;
|
base::pointer_comparator<MediaChannelDescriptionsTask>> _mediaChannelDescriptionses;
|
||||||
|
|
||||||
not_null<PeerData*> _joinAs;
|
rpl::variable<not_null<PeerData*>> _joinAs;
|
||||||
std::vector<not_null<PeerData*>> _possibleJoinAs;
|
std::vector<not_null<PeerData*>> _possibleJoinAs;
|
||||||
QString _joinHash;
|
QString _joinHash;
|
||||||
|
|
||||||
|
|
|
@ -1605,30 +1605,47 @@ void Members::setupAddMember(not_null<GroupCall*> call) {
|
||||||
using namespace rpl::mappers;
|
using namespace rpl::mappers;
|
||||||
|
|
||||||
const auto peer = call->peer();
|
const auto peer = call->peer();
|
||||||
if (const auto channel = peer->asBroadcast()) {
|
const auto canAddByPeer = [=](not_null<PeerData*> peer) {
|
||||||
_canAddMembers = rpl::single(
|
if (peer->isBroadcast()) {
|
||||||
|
return rpl::single(false) | rpl::type_erased();
|
||||||
|
}
|
||||||
|
return rpl::combine(
|
||||||
|
Data::CanWriteValue(peer.get()),
|
||||||
|
_call->joinAsValue()
|
||||||
|
) | rpl::map([=](bool can, not_null<PeerData*> joinAs) {
|
||||||
|
return can && joinAs->isSelf();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const auto canInviteByLinkByPeer = [=](not_null<PeerData*> peer) {
|
||||||
|
const auto channel = peer->asChannel();
|
||||||
|
if (!channel) {
|
||||||
|
return rpl::single(false) | rpl::type_erased();
|
||||||
|
}
|
||||||
|
return rpl::single(
|
||||||
false
|
false
|
||||||
) | rpl::then(_call->real(
|
) | rpl::then(_call->real(
|
||||||
) | rpl::map([=] {
|
) | rpl::map([=] {
|
||||||
return Data::PeerFlagValue(
|
return Data::PeerFlagValue(
|
||||||
channel,
|
channel,
|
||||||
ChannelDataFlag::Username);
|
ChannelDataFlag::Username);
|
||||||
}) | rpl::flatten_latest());
|
}) | rpl::flatten_latest()) | rpl::type_erased();
|
||||||
} else {
|
};
|
||||||
_canAddMembers = Data::CanWriteValue(peer.get());
|
_canAddMembers = canAddByPeer(peer);
|
||||||
SubscribeToMigration(
|
_canInviteByLink = canInviteByLinkByPeer(peer);
|
||||||
peer,
|
SubscribeToMigration(
|
||||||
lifetime(),
|
peer,
|
||||||
[=](not_null<ChannelData*> channel) {
|
lifetime(),
|
||||||
_canAddMembers = Data::CanWriteValue(channel.get());
|
[=](not_null<ChannelData*> channel) {
|
||||||
});
|
_canAddMembers = canAddByPeer(channel);
|
||||||
}
|
_canInviteByLink = canInviteByLinkByPeer(channel);
|
||||||
|
});
|
||||||
|
|
||||||
rpl::combine(
|
rpl::combine(
|
||||||
_canAddMembers.value(),
|
_canAddMembers.value(),
|
||||||
|
_canInviteByLink.value(),
|
||||||
_mode.value()
|
_mode.value()
|
||||||
) | rpl::start_with_next([=](bool can, PanelMode mode) {
|
) | rpl::start_with_next([=](bool add, bool invite, PanelMode mode) {
|
||||||
if (!can) {
|
if (!add && !invite) {
|
||||||
if (const auto old = _addMemberButton.current()) {
|
if (const auto old = _addMemberButton.current()) {
|
||||||
delete old;
|
delete old;
|
||||||
_addMemberButton = nullptr;
|
_addMemberButton = nullptr;
|
||||||
|
|
|
@ -108,6 +108,7 @@ private:
|
||||||
ListWidget *_list = nullptr;
|
ListWidget *_list = nullptr;
|
||||||
rpl::event_stream<> _addMemberRequests;
|
rpl::event_stream<> _addMemberRequests;
|
||||||
|
|
||||||
|
rpl::variable<bool> _canInviteByLink;
|
||||||
rpl::variable<bool> _canAddMembers;
|
rpl::variable<bool> _canAddMembers;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -781,10 +781,14 @@ void Panel::setupMembers() {
|
||||||
|
|
||||||
_members->addMembersRequests(
|
_members->addMembersRequests(
|
||||||
) | rpl::start_with_next([=] {
|
) | rpl::start_with_next([=] {
|
||||||
if (_peer->isBroadcast() && _peer->asChannel()->hasUsername()) {
|
if (!_peer->isBroadcast()
|
||||||
_callShareLinkCallback();
|
&& _peer->canWrite()
|
||||||
} else {
|
&& _call->joinAs()->isSelf()) {
|
||||||
addMembers();
|
addMembers();
|
||||||
|
} else if (const auto channel = _peer->asChannel()) {
|
||||||
|
if (channel->hasUsername()) {
|
||||||
|
_callShareLinkCallback();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, _callLifetime);
|
}, _callLifetime);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue