diff options
| author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2025-11-07 17:19:56 +0200 |
|---|---|---|
| committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2025-11-07 17:19:56 +0200 |
| commit | c39135cd848305c3acfcbd6dd2fc817cd09951de (patch) | |
| tree | 35955a2a802e6f0a8cfdf2b4039a961f006bed54 | |
| parent | cf048cf9c3ebd9ca8ee1e606b69bc459b62ed1c5 (diff) | |
#4013 add simple voice moderation permission check
| -rw-r--r-- | indra/newview/llnearbyvoicemoderation.cpp | 56 | ||||
| -rw-r--r-- | indra/newview/llnearbyvoicemoderation.h | 7 | ||||
| -rw-r--r-- | indra/newview/llviewerparcelmgr.cpp | 10 | ||||
| -rw-r--r-- | indra/newview/llviewerparcelmgr.h | 6 |
4 files changed, 21 insertions, 58 deletions
diff --git a/indra/newview/llnearbyvoicemoderation.cpp b/indra/newview/llnearbyvoicemoderation.cpp index ec0e1c0431..2b4fd26afc 100644 --- a/indra/newview/llnearbyvoicemoderation.cpp +++ b/indra/newview/llnearbyvoicemoderation.cpp @@ -31,22 +31,17 @@ #include "llvoavatar.h" #include "llvoiceclient.h" #include "llviewerobjectlist.h" +#include "llviewerparcelmgr.h" +#include "roles_constants.h" #include "llnearbyvoicemoderation.h" LLNearbyVoiceModeration::LLNearbyVoiceModeration() { - // TODO: default to false, when appropriate info cap is added - mIsNearbyChatModerator = true; - mParcelCallbackConnection = gAgent.addParcelChangedCallback([this]() { updateModeratorStatus(); }); } LLNearbyVoiceModeration::~LLNearbyVoiceModeration() { - if (mParcelCallbackConnection.connected()) - { - mParcelCallbackConnection.disconnect(); - } } LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id) @@ -192,51 +187,8 @@ void LLNearbyVoiceModeration::showMutedNotification(bool is_muted) } } -void LLNearbyVoiceModeration::updateModeratorStatus() -{ - LL_WARNS() << "Request moderator status info" << LL_ENDL; - // TODO: Uncomment and set correct capability name, when appropriate info cap is added - /* - if (LLViewerRegion* region = gAgent.getRegion()) - { - - std::string url = region->getCapability("SpatialVoiceModerationInfoRequest"); - if (!url.empty()) - { - LLCoros::instance().launch("getModeratorStatusCoro", [url]() { getModeratorStatusCoro(url); }); - } - } - */ -} - -void LLNearbyVoiceModeration::getModeratorStatusCoro(std::string cap_url) +bool LLNearbyVoiceModeration::isNearbyChatModerator() { - LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID); - LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getModeratorStatusCoro", httpPolicy)); - LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest); - LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions); - LLCore::HttpHeaders::ptr_t httpHeaders; - - httpOpts->setFollowRedirects(true); - - LLSD result = httpAdapter->getAndSuspend(httpRequest, cap_url, httpOpts, httpHeaders); - - LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; - LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); - - if (!status) - { - LL_WARNS() << "Failed to get nearby voice moderator info" << LL_ENDL; - return; - } - else if (!result["success"].asBoolean()) - { - LL_WARNS() << "Failed to get nearby voice moderator info: " << result["message"] << LL_ENDL; - return; - } - - // TODO: update the field, when appropriate info cap is added - bool is_moderator = result["moderator"].asBoolean(); - LLNearbyVoiceModeration::getInstance()->setNearbyChatModerator(is_moderator); + return gAgent.canManageEstate() || LLViewerParcelMgr::getInstance()->allowVoiceModeration(); } diff --git a/indra/newview/llnearbyvoicemoderation.h b/indra/newview/llnearbyvoicemoderation.h index 21d185db54..95bae9ca2a 100644 --- a/indra/newview/llnearbyvoicemoderation.h +++ b/indra/newview/llnearbyvoicemoderation.h @@ -39,11 +39,7 @@ class LLNearbyVoiceModeration : public LLSingleton <LLNearbyVoiceModeration> { void showMutedNotification(bool is_muted); void showNotificationIfNeeded(); - void updateModeratorStatus(); - static void getModeratorStatusCoro(std::string cap_url); - - bool isNearbyChatModerator() { return mIsNearbyChatModerator; }; - void setNearbyChatModerator(bool moderator) { mIsNearbyChatModerator = moderator; } + bool isNearbyChatModerator(); private: LLVOAvatar* getVOAvatarFromId(const LLUUID& id); @@ -51,5 +47,4 @@ class LLNearbyVoiceModeration : public LLSingleton <LLNearbyVoiceModeration> { boost::signals2::connection mParcelCallbackConnection; std::map<std::string, bool> mChannelMuteMap; - bool mIsNearbyChatModerator; }; diff --git a/indra/newview/llviewerparcelmgr.cpp b/indra/newview/llviewerparcelmgr.cpp index 432da2e990..452c666652 100644 --- a/indra/newview/llviewerparcelmgr.cpp +++ b/indra/newview/llviewerparcelmgr.cpp @@ -702,6 +702,16 @@ bool LLViewerParcelMgr::allowAgentVoice() const return allowAgentVoice(gAgent.getRegion(), mAgentParcel); } +bool LLViewerParcelMgr::isVoiceRestricted() const +{ + return mAgentParcel && !mAgentParcel->getParcelFlagUseEstateVoiceChannel(); +} + +bool LLViewerParcelMgr::allowVoiceModeration() const +{ + return isVoiceRestricted() && isParcelOwnedByAgent(mAgentParcel, GP_SESSION_MODERATOR); +} + bool LLViewerParcelMgr::allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const { return region && region->isVoiceEnabled() diff --git a/indra/newview/llviewerparcelmgr.h b/indra/newview/llviewerparcelmgr.h index 1925cd23ed..8863bc7a06 100644 --- a/indra/newview/llviewerparcelmgr.h +++ b/indra/newview/llviewerparcelmgr.h @@ -173,6 +173,12 @@ public: bool allowAgentVoice() const; bool allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const; + // Returns true if this parcel is using private voice channel + bool isVoiceRestricted() const; + + // Can this agent moderate Nearby voice chat on this parcel? + bool allowVoiceModeration() const; + // Can this agent start flying on this parcel? // Used for parcel property icons in nav bar. bool allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const; |
