diff --git a/.idea/NeDvachAPI.iml b/.idea/NeDvachAPI.iml
new file mode 100644
index 0000000..0c8867d
--- /dev/null
+++ b/.idea/NeDvachAPI.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..4d319ec
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..d47bf8d
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1668991859805
+
+
+ 1668991859805
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Controllers/GetPosts.cs b/Controllers/GetPosts.cs
index ef66f63..0c5f257 100644
--- a/Controllers/GetPosts.cs
+++ b/Controllers/GetPosts.cs
@@ -12,10 +12,11 @@ namespace NeDvachAPI.Controllers
{
[HttpGet(Name = "GetPosts")]
public string Get([FromUri] string board, int thread)
- {
+ {
+ string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
List posts = DBchat.DbList(board, thread);
string postsJson = JsonSerializer.Serialize(posts);
- Console.WriteLine("Запрошен список постов из борды " + board + " и треда# " + thread );
+ Console.WriteLine("С адреса " + ipAddress + " запрошен список постов из борды " + board + " и треда# " + thread);
return postsJson ;
}
}
diff --git a/Controllers/PostPost.cs b/Controllers/PostPost.cs
index 764651b..7b174f6 100644
--- a/Controllers/PostPost.cs
+++ b/Controllers/PostPost.cs
@@ -10,7 +10,8 @@ namespace NeDvachAPI.Controllers
[HttpPost(Name = "PostPosts")]
public JsonResult ReceivePost([FromBody] Post ReceivedPost)
{
- Console.WriteLine("Принят пост");
+ string ipAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
+ ReceivedPost.Ip = ipAddress;
DBchat.SendPost(ReceivedPost);
return new JsonResult("Posted Successfully!");
}
diff --git a/DBchat.cs b/DBchat.cs
index 37f21a1..2371c51 100644
--- a/DBchat.cs
+++ b/DBchat.cs
@@ -127,13 +127,14 @@ namespace NeDvachAPI
int postNum = 14;
using (var command = new NpgsqlCommand(@"
- INSERT INTO posts (post_id, post_text, post_number, content, thread_id, post_timestamp)
+ INSERT INTO posts (post_id, post_text, post_number, content, thread_id, auth_ip, post_timestamp)
VALUES (
DEFAULT,
@postText,
@postNum,
@postImgUrl,
@threadId,
+ @ip,
(
SELECT date_trunc(
'second',
@@ -145,6 +146,7 @@ namespace NeDvachAPI
command.Parameters.AddWithValue("postNum", postNum);
command.Parameters.AddWithValue("postImgUrl", postToSend.ImgURL);
command.Parameters.AddWithValue("threadId", postToSend.Thread_Id);
+ command.Parameters.AddWithValue("ip", postToSend.Ip);
//command.Parameters.AddWithValue("postTimeStamp", DateTime.Now.ToString("dd/MM/yyyy HH:mm"));
int nRows = command.ExecuteNonQuery();
Console.Out.WriteLine("Добавлен пост с текстом " + postToSend.Text + " номером " + 22);
diff --git a/Post.cs b/Post.cs
index 3572cd0..ecd5e59 100644
--- a/Post.cs
+++ b/Post.cs
@@ -9,5 +9,6 @@ namespace NeDvachAPI
public int Thread_Id { get; set; }
public bool Is_OP { get; set; }
public bool Is_Deleted { get; set; }
+ public string? Ip { get; set; }
}
}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index 385a68e..92c7979 100644
--- a/Program.cs
+++ b/Program.cs
@@ -12,8 +12,8 @@ builder.Services.AddCors(setup =>
setup.AddDefaultPolicy(policyBuilder =>
{
- policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
- //policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
+ //policyBuilder.WithOrigins("http://www.vdk2ch.ru:4200").WithMethods("GET", "POST").WithHeaders("*");
+ policyBuilder.WithOrigins("http://localhost:4200").WithMethods("GET", "POST").WithHeaders("*");
});
});