This repository has been archived on 2023-06-30. You can view files and clone it, but cannot push or open issues or pull requests.
2chBackAPI/Controllers/PostPost.cs
RakVhalate 50a3c94af8
All checks were successful
continuous-integration/drone/push Build is passing
added buffer and some error handling
2022-11-25 12:37:26 +10:00

28 lines
861 B
C#

using Microsoft.AspNetCore.Mvc;
using System.Text.Json;
namespace NeDvachAPI.Controllers
{
[ApiController]
[Route("[controller]")]
public class PostToController : ControllerBase
{
[HttpPost(Name = "PostPosts")]
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
{
string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
ReceivedPost.Ip = ipAddress;
try
{
DBchat.SendPost(ReceivedPost);
APIThreadBuffer.RefreshThread(ReceivedPost.Thread_Id);
return new JsonResult("Сообщение успешно добавлено.");
}
catch
{
return new JsonResult("Произошла ошибка постинга");
}
}
}
}