@@ -50,53 +50,92 @@ LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id)
5050 }
5151}
5252
53- void LLNearbyVoiceModeration::requestMuteChange (const LLUUID& agent_id, bool mute)
53+ const std::string LLNearbyVoiceModeration::getCapUrlFromRegion (LLViewerRegion* region)
54+ {
55+ if (! region || ! region->capabilitiesReceived ())
56+ {
57+ // TODO: Retry if fails since the capabilities may not have been received
58+ // if this is called early into a region entry
59+ LL_INFOS () << " Region or region capabilities unavailable." << LL_ENDL;
60+ return std::string ();
61+ }
62+ LL_INFOS () << " Capabilities for region " << region->getName () << " received." << LL_ENDL;
63+
64+ std::string url = region->getCapability (" SpatialVoiceModerationRequest" );
65+ if (url.empty ())
66+ {
67+ // TODO: Retry if fails since URL may not have not be available
68+ // if this is called early into a region entry
69+ LL_INFOS () << " Capability URL for region " << region->getName () << " is empty" << LL_ENDL;
70+ return std::string ();
71+ }
72+ LL_INFOS () << " Capability URL for region " << region->getName () << " is " << url << LL_ENDL;
73+
74+ return url;
75+ }
76+
77+ void LLNearbyVoiceModeration::requestMuteIndividual (const LLUUID& agent_id, bool mute)
5478{
5579 LLVOAvatar* avatar = getVOAvatarFromId (agent_id);
5680 if (avatar)
5781 {
58- LLViewerRegion* region = avatar->getRegion ();
59- if (! region || ! region-> capabilitiesReceived ())
82+ const std::string cap_url = getCapUrlFromRegion ( avatar->getRegion () );
83+ if (cap_url. length ())
6084 {
61- // TODO: Retry if fails since the capabilities may not have been received
62- // if this is called early into a region entry
63- LL_INFOS () << " Region or region capabilities unavailable" << LL_ENDL;
64- return ;
65- }
66- LL_INFOS () << " Region name is " << region->getName () << LL_ENDL;
85+ const std::string operand = mute ? " mute" : " unmute" ;
6786
68- std::string url = region->getCapability (" SpatialVoiceModerationRequest" );
69- if (url.empty ())
70- {
71- // TODO: Retry if fails since URL may not have not be available
72- // if this is called early into a region entry
73- LL_INFOS () << " Capability URL is empty" << LL_ENDL;
74- return ;
87+ LLSD body;
88+ body[" operand" ] = operand;
89+ body[" agent_id" ] = agent_id;
90+ body[" moderator_id" ] = gAgent .getID ();
91+
92+ const std::string agent_name = avatar->getFullname ();
93+ LL_INFOS () << " Resident " << agent_name
94+ << " (" << agent_id << " )" << " applying " << operand << LL_ENDL;
95+
96+ std::string success_msg =
97+ STRINGIZE (" Resident " << agent_name
98+ << " (" << agent_id << " )" << " nearby voice was set to " << operand);
99+
100+ std::string failure_msg =
101+ STRINGIZE (" Unable to change voice muting for resident "
102+ << agent_name << " (" << agent_id << " )" );
103+
104+ LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost (
105+ cap_url,
106+ body,
107+ success_msg,
108+ failure_msg);
75109 }
76- LL_INFOS () << " Capability URL is " << url << LL_ENDL;
110+ }
111+ }
77112
78- const std::string agent_name = avatar->getFullname ();
113+ void LLNearbyVoiceModeration::requestMuteAll (bool mute)
114+ {
115+ // Use our own avatar to get the region name
116+ LLViewerRegion* region = gAgent .getRegion ();
79117
80- const std::string operand = mute ? " mute" : " unmute" ;
118+ const std::string cap_url = getCapUrlFromRegion (region);
119+ if (cap_url.length ())
120+ {
121+ const std::string operand = mute ? " mute_all" : " unmute_all" ;
81122
82123 LLSD body;
83124 body[" operand" ] = operand;
84- body[" agent_id" ] = agent_id;
85125 body[" moderator_id" ] = gAgent .getID ();
86126
87- LL_INFOS () << " Resident " << agent_name
88- << " (" << agent_id << " )" << " applying " << operand << LL_ENDL;
127+ LL_INFOS () << " For all residents in this region, applying: " << operand << LL_ENDL;
89128
90129 std::string success_msg =
91- STRINGIZE (" Resident " << agent_name
92- << " (" << agent_id << " )" << " nearby voice was set to " << operand);
130+ STRINGIZE (" Nearby voice for all residents was set to: " << operand);
93131
94132 std::string failure_msg =
95- STRINGIZE (" Unable to change voice muting for resident "
96- << agent_name << " (" << agent_id << " )" );
133+ STRINGIZE (" Unable to set nearby voice for all residents to: " << operand);
97134
98- LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost (url, body,
99- success_msg,
100- failure_msg);
135+ LLCoreHttpUtil::HttpCoroutineAdapter::messageHttpPost (
136+ cap_url,
137+ body,
138+ success_msg,
139+ failure_msg);
101140 }
102141}
0 commit comments