1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-25 19:50:22 +08:00
Files
osu-lazer/osu.Game/Overlays/Chat/ReportChatPopover.cs
T
Krzysztof Gutkowski 2006485d60 Allow reporting users from their profile page (#36335)
This PR refactors the report popover to have an optional confirmation
message after completing the request. This was initially meant for
#32584, but then I realized I can first test it out on the user
profiles, so I've implemented it here as well. Can be reviewed commit by
commit.



https://github.com/user-attachments/assets/cd59c560-c824-4a5e-bab6-5ecbf5125af1

---------

Co-authored-by: Dean Herbert <pe@ppy.sh>
2026-05-05 19:49:24 +09:00

57 lines
2.3 KiB
C#

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web;
namespace osu.Game.Overlays.Chat
{
public partial class ReportChatPopover : ReportPopover<ChatReportReason>
{
[Resolved]
private ChannelManager channelManager { get; set; } = null!;
private readonly Message message;
public ReportChatPopover(Message message)
: base(ReportStrings.UserTitle(message.Sender?.Username ?? @"Someone"), false)
{
this.message = message;
}
[BackgroundDependencyLoader]
private void load()
{
Success += () =>
{
string thanksMessage;
switch (channelManager.CurrentChannel.Value.Type)
{
case ChannelType.PM:
thanksMessage = """
Chat moderators have been alerted. You have reported a private message so they will not be able to read history to maintain your privacy. Please make sure to include as much details as you can.
You can submit a second report with more details if required, or contact abuse@ppy.sh if a user is being extremely offensive.
You can also block a user via the block button on their user profile, or by right-clicking on their name in the chat and selecting "Block".
""";
break;
default:
thanksMessage = @"Chat moderators have been alerted. Thanks for your help.";
break;
}
channelManager.CurrentChannel.Value.AddNewMessages(new InfoMessage(thanksMessage));
};
}
protected override APIRequest GetRequest(ChatReportReason reason, string comments) => new ChatReportRequest(message.Id, reason, comments);
protected override bool IsCommentRequired(ChatReportReason reason) => reason == ChatReportReason.Other;
}
}