From cccd45caa71393c060c9021e3e998897ef3a4298 Mon Sep 17 00:00:00 2001 From: RakVhalate Date: Wed, 14 Dec 2022 20:32:54 +0500 Subject: [PATCH] small changes --- APIControllers/PostPost.cs | 6 +++++- APIControllers/TestPosting.cs | 19 ------------------- BufferControllers/AccessController.cs | 15 +++++++++++++++ DBControllers/DBchat.cs | 1 - Models/Post.cs | 2 +- Program.cs | 1 + 6 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 APIControllers/TestPosting.cs create mode 100644 BufferControllers/AccessController.cs diff --git a/APIControllers/PostPost.cs b/APIControllers/PostPost.cs index 72dad22..4aa664b 100644 --- a/APIControllers/PostPost.cs +++ b/APIControllers/PostPost.cs @@ -2,7 +2,6 @@ using NeDvachAPI.BufferControllers; using NeDvachAPI.DBControllers; using NeDvachAPI.Models; -using System.Text.Json; namespace NeDvachAPI.Controllers { @@ -15,6 +14,11 @@ namespace NeDvachAPI.Controllers { string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString(); ReceivedPost.Ip = ipAddress; + + if(ReceivedPost.Text.Length == 0) + { + return new JsonResult("Вы отправили пустое сообщение!"); + } try { DBchat.SendPost(ReceivedPost); diff --git a/APIControllers/TestPosting.cs b/APIControllers/TestPosting.cs deleted file mode 100644 index 68c0748..0000000 --- a/APIControllers/TestPosting.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using System.Net; -using System.Text.Json; - -namespace NeDvachAPI.Controllers -{ - [ApiController] - [Route("[controller]")] - public class TestPostingController : ControllerBase - { - [HttpPost] - public int Area([FromForm] int height , int altitude) - { - //DBchat.SendPost(ReceivedPost); - Console.WriteLine("Received! " + height + " " + altitude ); - return 200; - } - } -} diff --git a/BufferControllers/AccessController.cs b/BufferControllers/AccessController.cs new file mode 100644 index 0000000..9a1c9ed --- /dev/null +++ b/BufferControllers/AccessController.cs @@ -0,0 +1,15 @@ +using NeDvachAPI.Models; +using Npgsql; + +namespace NeDvachAPI.DBControllers +{ + public class BanList + { + public static string[] GetBanned() + { + string[] bannedIPs = new string[0]; + // + return bannedIPs; + } + } +} \ No newline at end of file diff --git a/DBControllers/DBchat.cs b/DBControllers/DBchat.cs index 3e6b597..a65f215 100644 --- a/DBControllers/DBchat.cs +++ b/DBControllers/DBchat.cs @@ -55,7 +55,6 @@ namespace NeDvachAPI.DBControllers public static List ThreadsList(string boardName) { List posts = new List(); - string received = ""; string connString = string.Format( "Server={0}; User Id={1}; Database={2}; Port={3}; Password={4};SSLMode=Prefer", diff --git a/Models/Post.cs b/Models/Post.cs index 4021309..dd63af7 100644 --- a/Models/Post.cs +++ b/Models/Post.cs @@ -5,7 +5,7 @@ namespace NeDvachAPI.Models public string Timestamp { get; set; } public int Id { get; set; } public string Text { get; set; } - public string[] ImgURL { get; set; } + public string[]? ImgURL { get; set; } public int Thread_Id { get; set; } public bool Is_OP { get; set; } public bool Is_Deleted { get; set; } diff --git a/Program.cs b/Program.cs index b8b1785..a816a30 100644 --- a/Program.cs +++ b/Program.cs @@ -34,4 +34,5 @@ if (BufferFill.FillBuffer("b")) { app.Run(); } +else Console.WriteLine("Ошибка буферизации, проверьте доступность базы данных.");