2022-12-20 22:46:05 +08:00
|
|
|
// 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.
|
|
|
|
|
2023-05-05 12:58:13 +08:00
|
|
|
using osu.Framework.Allocation;
|
2022-12-20 22:46:05 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2023-05-05 12:58:13 +08:00
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
using osu.Game.Online.Chat;
|
2022-12-20 22:46:05 +08:00
|
|
|
using osu.Game.Resources.Localisation.Web;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Chat
|
|
|
|
{
|
2022-12-21 00:37:16 +08:00
|
|
|
public partial class ReportChatPopover : ReportPopover<ChatReportReason>
|
2022-12-20 22:46:05 +08:00
|
|
|
{
|
2023-05-05 12:58:13 +08:00
|
|
|
[Resolved]
|
|
|
|
private IAPIProvider api { get; set; } = null!;
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private ChannelManager channelManager { get; set; } = null!;
|
|
|
|
|
|
|
|
private readonly Message message;
|
|
|
|
|
|
|
|
public ReportChatPopover(Message message)
|
|
|
|
: base(ReportStrings.UserTitle(message.Sender?.Username ?? @"Someone"))
|
2022-12-20 22:46:05 +08:00
|
|
|
{
|
2023-05-05 12:58:13 +08:00
|
|
|
this.message = message;
|
|
|
|
Action = report;
|
2023-03-28 20:32:28 +08:00
|
|
|
}
|
|
|
|
|
2023-05-06 21:34:55 +08:00
|
|
|
protected override bool IsCommentRequired(ChatReportReason reason) => reason == ChatReportReason.Other;
|
2023-05-05 12:58:13 +08:00
|
|
|
|
|
|
|
private void report(ChatReportReason reason, string comments)
|
|
|
|
{
|
|
|
|
var request = new ChatReportRequest(message.Id, reason, comments);
|
|
|
|
|
2023-05-06 21:27:27 +08:00
|
|
|
request.Success += () => channelManager.CurrentChannel.Value.AddNewMessages(new InfoMessage(UsersStrings.ReportThanks.ToString()));
|
2023-05-05 12:58:13 +08:00
|
|
|
|
|
|
|
api.Queue(request);
|
|
|
|
}
|
2022-12-20 22:46:05 +08:00
|
|
|
}
|
|
|
|
}
|