Skip to content

Commit c39135c

Browse files
#4013 add simple voice moderation permission check
1 parent cf048cf commit c39135c

File tree

4 files changed

+21
-58
lines changed

4 files changed

+21
-58
lines changed

indra/newview/llnearbyvoicemoderation.cpp

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,17 @@
3131
#include "llvoavatar.h"
3232
#include "llvoiceclient.h"
3333
#include "llviewerobjectlist.h"
34+
#include "llviewerparcelmgr.h"
35+
#include "roles_constants.h"
3436

3537
#include "llnearbyvoicemoderation.h"
3638

3739
LLNearbyVoiceModeration::LLNearbyVoiceModeration()
3840
{
39-
// TODO: default to false, when appropriate info cap is added
40-
mIsNearbyChatModerator = true;
41-
mParcelCallbackConnection = gAgent.addParcelChangedCallback([this]() { updateModeratorStatus(); });
4241
}
4342

4443
LLNearbyVoiceModeration::~LLNearbyVoiceModeration()
4544
{
46-
if (mParcelCallbackConnection.connected())
47-
{
48-
mParcelCallbackConnection.disconnect();
49-
}
5045
}
5146

5247
LLVOAvatar* LLNearbyVoiceModeration::getVOAvatarFromId(const LLUUID& agent_id)
@@ -192,51 +187,8 @@ void LLNearbyVoiceModeration::showMutedNotification(bool is_muted)
192187
}
193188
}
194189

195-
void LLNearbyVoiceModeration::updateModeratorStatus()
196-
{
197-
LL_WARNS() << "Request moderator status info" << LL_ENDL;
198-
// TODO: Uncomment and set correct capability name, when appropriate info cap is added
199-
/*
200-
if (LLViewerRegion* region = gAgent.getRegion())
201-
{
202-
203-
std::string url = region->getCapability("SpatialVoiceModerationInfoRequest");
204-
if (!url.empty())
205-
{
206-
LLCoros::instance().launch("getModeratorStatusCoro", [url]() { getModeratorStatusCoro(url); });
207-
}
208-
}
209-
*/
210-
}
211-
212-
void LLNearbyVoiceModeration::getModeratorStatusCoro(std::string cap_url)
190+
bool LLNearbyVoiceModeration::isNearbyChatModerator()
213191
{
214-
LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
215-
LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("getModeratorStatusCoro", httpPolicy));
216-
LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
217-
LLCore::HttpOptions::ptr_t httpOpts(new LLCore::HttpOptions);
218-
LLCore::HttpHeaders::ptr_t httpHeaders;
219-
220-
httpOpts->setFollowRedirects(true);
221-
222-
LLSD result = httpAdapter->getAndSuspend(httpRequest, cap_url, httpOpts, httpHeaders);
223-
224-
LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
225-
LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
226-
227-
if (!status)
228-
{
229-
LL_WARNS() << "Failed to get nearby voice moderator info" << LL_ENDL;
230-
return;
231-
}
232-
else if (!result["success"].asBoolean())
233-
{
234-
LL_WARNS() << "Failed to get nearby voice moderator info: " << result["message"] << LL_ENDL;
235-
return;
236-
}
237-
238-
// TODO: update the field, when appropriate info cap is added
239-
bool is_moderator = result["moderator"].asBoolean();
240-
LLNearbyVoiceModeration::getInstance()->setNearbyChatModerator(is_moderator);
192+
return gAgent.canManageEstate() || LLViewerParcelMgr::getInstance()->allowVoiceModeration();
241193
}
242194

indra/newview/llnearbyvoicemoderation.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,12 @@ class LLNearbyVoiceModeration : public LLSingleton <LLNearbyVoiceModeration> {
3939
void showMutedNotification(bool is_muted);
4040
void showNotificationIfNeeded();
4141

42-
void updateModeratorStatus();
43-
static void getModeratorStatusCoro(std::string cap_url);
44-
45-
bool isNearbyChatModerator() { return mIsNearbyChatModerator; };
46-
void setNearbyChatModerator(bool moderator) { mIsNearbyChatModerator = moderator; }
42+
bool isNearbyChatModerator();
4743

4844
private:
4945
LLVOAvatar* getVOAvatarFromId(const LLUUID& id);
5046
const std::string getCapUrlFromRegion(LLViewerRegion* region);
5147

5248
boost::signals2::connection mParcelCallbackConnection;
5349
std::map<std::string, bool> mChannelMuteMap;
54-
bool mIsNearbyChatModerator;
5550
};

indra/newview/llviewerparcelmgr.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,16 @@ bool LLViewerParcelMgr::allowAgentVoice() const
702702
return allowAgentVoice(gAgent.getRegion(), mAgentParcel);
703703
}
704704

705+
bool LLViewerParcelMgr::isVoiceRestricted() const
706+
{
707+
return mAgentParcel && !mAgentParcel->getParcelFlagUseEstateVoiceChannel();
708+
}
709+
710+
bool LLViewerParcelMgr::allowVoiceModeration() const
711+
{
712+
return isVoiceRestricted() && isParcelOwnedByAgent(mAgentParcel, GP_SESSION_MODERATOR);
713+
}
714+
705715
bool LLViewerParcelMgr::allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const
706716
{
707717
return region && region->isVoiceEnabled()

indra/newview/llviewerparcelmgr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,12 @@ class LLViewerParcelMgr : public LLSingleton<LLViewerParcelMgr>
173173
bool allowAgentVoice() const;
174174
bool allowAgentVoice(const LLViewerRegion* region, const LLParcel* parcel) const;
175175

176+
// Returns true if this parcel is using private voice channel
177+
bool isVoiceRestricted() const;
178+
179+
// Can this agent moderate Nearby voice chat on this parcel?
180+
bool allowVoiceModeration() const;
181+
176182
// Can this agent start flying on this parcel?
177183
// Used for parcel property icons in nav bar.
178184
bool allowAgentFly(const LLViewerRegion* region, const LLParcel* parcel) const;

0 commit comments

Comments
 (0)