bulletboards/ImageBoardServerApp/Shared/Components/ReportEntry.razor

81 lines
2.5 KiB
Text
Raw Normal View History

@using System.ComponentModel.DataAnnotations
@using ImageBoardServerApp.Data.Repository
2023-02-17 21:54:13 +00:00
@inject NavigationManager navigationManager
<div>
@if (report.Type == "op")
{
<span> /@report.ReportedPost.Board/ </span>
}
else
{
<span> /@report.ReportedComment.Board/ </span>
}
<span>#@report.ReportID</span>
<span>@report.Type</span>
<br/>
<span>Reason: @report.ReportReason</span>
<br/>
<span>Explaination: @report.ReportExlaination</span>
<br/>
<span>Ban User: </span>
<a @onclick="() => banTarget(1)" href="javascript:void(0)">1d</a>
<span> </span>
<a @onclick="() => banTarget(7)" href="javascript:void(0)">1w</a>
<span> </span>
<a @onclick="() => banTarget(31)" href="javascript:void(0)">1m</a>
<span> </span>
<a @onclick="() => banTarget(365)" href="javascript:void(0)">1yr</a>
<span> </span>
<a @onclick="() => banTarget(99999999)" href="javascript:void(0)">273,972.6 yrs</a>
<br/>
<span>Ban Reporter: </span>
<a @onclick="() => banReporter(1)" href="javascript:void(0)">1d</a>
<span> </span>
<a @onclick="() => banReporter(7)" href="javascript:void(0)">1w</a>
<span> </span>
<a @onclick="() => banReporter(31)" href="javascript:void(0)">1m</a>
<span> </span>
<a @onclick="() => banReporter(365)" href="javascript:void(0)">1yr</a>
<span> </span>
<a @onclick="() => banReporter(99999999)" href="javascript:void(0)">273,972.6 yrs</a>
<br/>
2023-02-17 21:54:13 +00:00
<a @onclick="@removeReport" href="javascript:void(0)" >Done</a>
<br/>
@if (report.Type == "op")
{
<Post post="report.ReportedPost" showOpenThread="true"></Post>
}
else
{
<Comment comment="report.ReportedComment"></Comment>
}
</div>
@code {
[Parameter]
[Required]
public ReportData report { get; set; }
private async Task banTarget(int days)
{
UserData user = report.UserReported;
user.TimeBanned = DateTimeOffset.Now.AddDays(days).ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(user);
2023-02-17 21:54:13 +00:00
await removeReport();
}
private async Task banReporter(int days)
{
UserData user = report.UserReporter;
user.TimeBanned = DateTimeOffset.Now.AddDays(days).ToUnixTimeMilliseconds();
await UsersRepository.updateUserAsync(user);
2023-02-17 21:54:13 +00:00
await removeReport();
}
private async Task removeReport()
{
await ReportsRepository.deleteReportAsync(report.ReportID);
navigationManager.NavigateTo("/sys/reports", true, true);
}
}