feat: made accounts deleteable, other changes

Signed-off-by: limited_dev <loginakkisativ@gmail.com>
This commit is contained in:
limited_dev 2023-06-13 16:24:38 +02:00
parent c20c5c9343
commit 8f38879294
10 changed files with 116 additions and 35 deletions

View file

@ -6,7 +6,6 @@ namespace ImageBoardServerApp.Util;
public class TheManager
{
private static long getDiff(PostData post)
{
return (DateTimeOffset.Now.ToUnixTimeMilliseconds() - post.CreatedAt);
@ -21,10 +20,12 @@ public class TheManager
{
return num < 0 ? num * -1 : num;
}
public static long getBumpValue(PostData post)
{
return (post.IsSticky ? 999999999999999999 + getDiff(post) : 10 * 60000 - getDiff(post) + ( 60000 * (post.Comments.Count + 1))) ;
return (post.IsSticky
? 999999999999999999 + getDiff(post)
: 10 * 60000 - getDiff(post) + (60000 * (post.Comments.Count + 1)));
}
public static async Task<List<PostData>> getPostList(string boardTag)
@ -46,18 +47,18 @@ public class TheManager
}
}
}
public static async Task deleteThread(PostData post)
{
foreach(var c in post.Comments)
foreach (var c in post.Comments)
{
if (c.Image != null)
{
deleteImage(c.Image);
await deleteImage(c.Image);
}
}
deleteImage(post.Image);
await deleteImage(post.Image);
await PostsRepository.deletePostAsync(post.PostID);
}
@ -66,16 +67,16 @@ public class TheManager
{
if (comment.Image != null)
{
deleteImage(comment.Image);
await deleteImage(comment.Image);
}
await CommentsRepository.deleteCommentAsync(comment.CommentID);
}
public static void deleteImage(ImageData imageData)
public static async Task deleteImage(ImageData imageData)
{
string path = $"./wwwroot{imageData.ImageLocation}";
Console.WriteLine(path);
try
{
File.Delete(path);
@ -102,7 +103,7 @@ public class TheManager
{
rng.GetBytes(bytes);
}
return BitConverter.ToString(bytes).Replace("-", "").ToLower();
}
}