limited_dev
73be698399
fix: fixed bumping, fixed banning from Reports Menu feat: improved homepage, finilized comments and posts, moved version from nav menu to sidebar Signed-off-by: limited_dev <loginakkisativ@gmail.com>
141 lines
No EOL
4 KiB
Text
141 lines
No EOL
4 KiB
Text
@page "/sys/modtools/banandordel/{targetuserid}/{board}/{type}/{threadid}/{targetid}"
|
|
@using ImageBoardServerApp.Data.Repository
|
|
@using System.ComponentModel.DataAnnotations
|
|
@inject NavigationManager navManager
|
|
@inject IJSRuntime js
|
|
|
|
<AuthorizeView Roles="Admin,Mod">
|
|
<Authorized>
|
|
<div>
|
|
<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>
|
|
</div>
|
|
</Authorized>
|
|
<NotAuthorized>
|
|
<DeadLink></DeadLink>
|
|
</NotAuthorized>
|
|
</AuthorizeView>
|
|
|
|
@code {
|
|
|
|
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();
|
|
}
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public string targetuserid { get; set; }
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public string threadid { get; set; }
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public string type { get; set; }
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public string board { get; set; }
|
|
|
|
[Parameter]
|
|
[Required]
|
|
public string targetid { get; set; }
|
|
|
|
|
|
} |