diff options
| author | Callum Prentice <callum@lindenlab.com> | 2025-10-13 14:57:01 -0700 |
|---|---|---|
| committer | Callum Prentice <callum@lindenlab.com> | 2025-10-13 14:57:01 -0700 |
| commit | 53d83104522fc683126ba764b3e2101dc7442547 (patch) | |
| tree | ae860b4b886e071c4cedb0a323186f6926716ca5 /indra/newview/llnearbyvoicemoderation.cpp | |
| parent | 219da2a16b3ae6e1d2e02b05159b37fa1aca1f47 (diff) | |
Improve robustness of when moderator options appear and add some initial code for muting indivudual / everyone via the capability
Diffstat (limited to 'indra/newview/llnearbyvoicemoderation.cpp')
| -rw-r--r-- | indra/newview/llnearbyvoicemoderation.cpp | 97 |
1 files changed, 68 insertions, 29 deletions
diff --git a/indra/newview/llnearbyvoicemoderation.cpp b/indra/newview/llnearbyvoicemoderation.cpp index d714fc36b4..5ae8feba08 100644 --- a/indra/newview/llnearbyvoicemoderation.cpp +++ b/indra/newview/llnearbyvoicemoderation.cpp @@ -50,53 +50,92 @@ LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id) } } -void LLNearbyVoiceModeration::requestMuteChange(const LLUUID& agent_id, bool mute) +const std::string LLNearbyVoiceModeration::getCapUrlFromRegion(LLViewerRegion* region) +{ + if (! region || ! region->capabilitiesReceived()) + { + // TODO: Retry if fails since the capabilities may not have been received + // if this is called early into a region entry + LL_INFOS() << "Region or region capabilities unavailable." << LL_ENDL; + return std::string(); + } + LL_INFOS() << "Capabilities for region " << region->getName() << " received." << LL_ENDL; + + std::string url = region->getCapability("SpatialVoiceModerationRequest"); + if (url.empty()) + { + // TODO: Retry if fails since URL may not have not be available + // if this is called early into a region entry + LL_INFOS() << "Capability URL for region " << region->getName() << " is empty" << LL_ENDL; + return std::string(); + } + LL_INFOS() << "Capability URL for region " << region->getName() << " is " << url << LL_ENDL; + + return url; +} + +void LLNearbyVoiceModeration::requestMuteIndividual(const LLUUID& agent_id, bool mute) { LLVOAvatar* avatar = getVOAvatarFromId(agent_id); if (avatar) { - LLViewerRegion* region = avatar->getRegion(); - if (! region || ! region->capabilitiesReceived()) + const std::string cap_url = getCapUrlFromRegion(avatar->getRegion()); + if (cap_url.length()) { - // TODO: Retry if fails since the capabilities may not have been received - // if this is called early into a region entry - LL_INFOS() << "Region or region capabilities unavailable" << LL_ENDL; - return; - } - LL_INFOS() << "Region name is " << region->getName() << LL_ENDL; + const std::string operand = mute ? "mute" : "unmute"; - std::string url = region->getCapability("SpatialVoiceModerationRequest"); - if (url.empty()) - { - // TODO: Retry if fails since URL may not have not be available - // if this is called early into a region entry - LL_INFOS() << "Capability URL is empty" << LL_ENDL; - return; + LLSD body; + body["operand"] = operand; + body["agent_id"] = agent_id; + body["moderator_id"] = gAgent.getID(); + + const std::string agent_name = avatar->getFullname(); + LL_INFOS() << "Resident " << agent_name + << " (" << agent_id << ")" << " applying " << operand << LL_ENDL; + + std::string success_msg = + STRINGIZE("Resident " << agent_name + << " (" << agent_id << ")" << " nearby voice was set to " << operand); + + std::string failure_msg = + STRINGIZE("Unable to change voice muting for resident " + << agent_name << " (" << agent_id << ")"); + + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost( + cap_url, + body, + success_msg, + failure_msg); } - LL_INFOS() << "Capability URL is " << url << LL_ENDL; + } +} - const std::string agent_name = avatar->getFullname(); +void LLNearbyVoiceModeration::requestMuteAll(bool mute) +{ + // Use our own avatar to get the region name + LLViewerRegion* region = gAgent.getRegion(); - const std::string operand = mute ? "mute" : "unmute"; + const std::string cap_url = getCapUrlFromRegion(region); + if (cap_url.length()) + { + const std::string operand = mute ? "mute_all" : "unmute_all"; LLSD body; body["operand"] = operand; - body["agent_id"] = agent_id; body["moderator_id"] = gAgent.getID(); - LL_INFOS() << "Resident " << agent_name - << " (" << agent_id << ")" << " applying " << operand << LL_ENDL; + LL_INFOS() << "For all residents in this region, applying: " << operand << LL_ENDL; std::string success_msg = - STRINGIZE("Resident " << agent_name - << " (" << agent_id << ")" << " nearby voice was set to " << operand); + STRINGIZE("Nearby voice for all residents was set to: " << operand); std::string failure_msg = - STRINGIZE("Unable to change voice muting for resident " - << agent_name << " (" << agent_id << ")"); + STRINGIZE("Unable to set nearby voice for all residents to: " << operand); - LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost(url, body, - success_msg, - failure_msg); + LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost( + cap_url, + body, + success_msg, + failure_msg); } } |
