2023-06-13 21:34:16 +00:00
|
|
|
@page "/sys/modtools/banandordel/{targetuserid}/{board}/{type}/{threadid}/{targetid}"
|
|
|
|
@using ImageBoardServerApp.Data.Repository
|
2023-06-13 15:43:52 +00:00
|
|
|
@using System.ComponentModel.DataAnnotations
|
2023-06-13 21:34:16 +00:00
|
|
|
@inject NavigationManager navManager
|
|
|
|
@inject IJSRuntime js
|
2023-06-13 15:43:52 +00:00
|
|
|
|
|
|
|
<AuthorizeView Roles="Admin,Mod">
|
|
|
|
<Authorized>
|
|
|
|
<div>
|
2023-06-13 21:34:16 +00:00
|
|
|
<UserEntry user="user"></UserEntry>
|
|
|
|
<p>
|
|
|
|
<a href="/@board/thread/@threadid">[View Thread]</a>
|
|
|
|
</p>
|
|
|
|
<div>
|
|
|
|
<br/>
|
|
|
|
@if (type == "op")
|
|
|
|
{
|
|
|
|
<Post post="post" showOpenThread="true"/>
|
|
|
|
}
|
|
|
|
else if (type == "comment")
|
|
|
|
{
|
|
|
|
<Comment comment="comment"/>
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
<p>This is not a valid type.</p>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<form>
|
|
|
|
<RadzenFormField Text="Reason" Variant="Variant.Outlined">
|
|
|
|
<RadzenTextBox @bind-Value="@reason"/>
|
|
|
|
</RadzenFormField>
|
|
|
|
<br/>
|
|
|
|
<br/>
|
|
|
|
<span>Ban User: </span>
|
|
|
|
<a @onclick="() => banTarget(1)" href="javascript:void(0)">1h</a>
|
|
|
|
<span> </span>
|
|
|
|
<a @onclick="() => banTarget(2)" href="javascript:void(0)">2h</a>
|
|
|
|
<span> </span>
|
|
|
|
<a @onclick="() => banTarget(1 * 24)" href="javascript:void(0)">1d</a>
|
|
|
|
<span> </span>
|
|
|
|
<a @onclick="() => banTarget(7 * 24)" href="javascript:void(0)">1w</a>
|
|
|
|
<span> </span>
|
|
|
|
<a @onclick="() => banTarget(31 * 24)" href="javascript:void(0)">1m</a>
|
|
|
|
<span> </span>
|
|
|
|
<a @onclick="() => banTarget(365 * 24)" href="javascript:void(0)">1yr</a>
|
|
|
|
<span> </span>
|
|
|
|
</form>
|
|
|
|
</div>
|
2023-06-13 15:43:52 +00:00
|
|
|
</div>
|
|
|
|
</Authorized>
|
|
|
|
<NotAuthorized>
|
|
|
|
<DeadLink></DeadLink>
|
|
|
|
</NotAuthorized>
|
|
|
|
</AuthorizeView>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
2023-06-13 21:34:16 +00:00
|
|
|
public string timetoBan { get; set; }
|
|
|
|
public string reason { get; set; }
|
|
|
|
|
|
|
|
public UserData user { get; set; }
|
|
|
|
public PostData post { get; set; }
|
|
|
|
public CommentData comment { get; set; }
|
|
|
|
|
|
|
|
private async Task banTarget(int hours)
|
|
|
|
{
|
|
|
|
UserData ud = await UsersRepository.getUserByIdAsync(int.Parse(targetuserid));
|
|
|
|
ud.TimeBanned = DateTimeOffset.Now.ToUnixTimeMilliseconds() + (hours * 3600000);
|
|
|
|
if (reason == "")
|
|
|
|
{
|
|
|
|
reason = "not specified";
|
|
|
|
}
|
|
|
|
ud.BanReason = reason;
|
|
|
|
await UsersRepository.updateUserAsync(ud);
|
|
|
|
navManager.NavigateTo("/@board/", true, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
|
|
{
|
|
|
|
if (!int.TryParse(targetid, out _) || !int.TryParse(targetuserid, out _))
|
|
|
|
{
|
|
|
|
navManager.NavigateTo("/sys/dead", true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var targeti = int.Parse(targetid);
|
|
|
|
|
|
|
|
var targetuseri = int.Parse(targetuserid);
|
|
|
|
|
|
|
|
var u = await UsersRepository.getUserByIdAsync(targetuseri);
|
|
|
|
if (u == null)
|
|
|
|
{
|
|
|
|
navManager.NavigateTo("/sys/dead", true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (targetuseri != u.UserID)
|
|
|
|
{
|
|
|
|
navManager.NavigateTo("/sys/dead", true);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
user = u;
|
|
|
|
|
|
|
|
var isPost = type == "op";
|
|
|
|
|
|
|
|
if (isPost)
|
|
|
|
{
|
|
|
|
post = await PostsRepository.getPostByIdAsync(targeti);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
comment = await CommentsRepository.getCommentByIdAsync(targeti);
|
|
|
|
}
|
|
|
|
await base.OnParametersSetAsync();
|
|
|
|
}
|
|
|
|
|
2023-06-13 15:43:52 +00:00
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string targetuserid { get; set; }
|
|
|
|
|
2023-06-13 21:34:16 +00:00
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string threadid { get; set; }
|
|
|
|
|
2023-06-13 15:43:52 +00:00
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string type { get; set; }
|
|
|
|
|
2023-06-13 21:34:16 +00:00
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string board { get; set; }
|
|
|
|
|
2023-06-13 15:43:52 +00:00
|
|
|
[Parameter]
|
|
|
|
[Required]
|
|
|
|
public string targetid { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
}
|