aboutsummaryrefslogtreecommitdiff
path: root/Backend/Api
diff options
context:
space:
mode:
authorJelena Petrovic <jelenapetrovic.7119@gmail.com>2022-11-20 23:45:29 +0100
committerJelena Petrovic <jelenapetrovic.7119@gmail.com>2022-11-20 23:45:29 +0100
commitf7a12cb67dd4d9e041534a04633d633582f6e0a2 (patch)
tree3f73af9131b9deaeb8ca615655f9b8ade421f40f /Backend/Api
parent688987e855a1a5adbf319759b9d0eea813104cbf (diff)
parentf101c0461ac1ff0b0a910313bdde155fbb61f8bd (diff)
Merge branch 'develop' of http://gitlab.pmf.kg.ac.rs/BrzoDoLokacije2022/odyssey/brzodolokacije into develop
Diffstat (limited to 'Backend/Api')
-rw-r--r--Backend/Api/Api/Controllers/UserController.cs10
-rw-r--r--Backend/Api/Api/Interfaces/IPostService.cs1
-rw-r--r--Backend/Api/Api/Models/Location.cs5
-rw-r--r--Backend/Api/Api/Services/ChatHub.cs7
-rw-r--r--Backend/Api/Api/Services/PostService.cs16
5 files changed, 34 insertions, 5 deletions
diff --git a/Backend/Api/Api/Controllers/UserController.cs b/Backend/Api/Api/Controllers/UserController.cs
index 94e4b41..1bc395f 100644
--- a/Backend/Api/Api/Controllers/UserController.cs
+++ b/Backend/Api/Api/Controllers/UserController.cs
@@ -64,5 +64,15 @@ namespace Api.Controllers
return Ok(rez);
return BadRequest();
}
+ [HttpGet("history")]
+ [Authorize(Roles = "User")]
+ public async Task<ActionResult<List<PostSend>>> ViewHistory()
+ {
+ var id = await _userService.UserIdFromJwt();
+ var rez = await _postService.UserHistory(id);
+ if (rez != null)
+ return Ok(rez);
+ return BadRequest();
+ }
}
}
diff --git a/Backend/Api/Api/Interfaces/IPostService.cs b/Backend/Api/Api/Interfaces/IPostService.cs
index fc2ae03..12a5fe8 100644
--- a/Backend/Api/Api/Interfaces/IPostService.cs
+++ b/Backend/Api/Api/Interfaces/IPostService.cs
@@ -18,5 +18,6 @@ namespace Api.Interfaces
Task<PostSendPage> SearchPosts(string locid, int page = 0, int sorttype = 1, int filterdate = 1);
int DateEnumToDays(int filterdate);
Task<List<PostSend>> GetUsersPosts(string id);
+ Task<List<PostSend>> UserHistory(string userid);
}
} \ No newline at end of file
diff --git a/Backend/Api/Api/Models/Location.cs b/Backend/Api/Api/Models/Location.cs
index 3402f6c..b2f0aad 100644
--- a/Backend/Api/Api/Models/Location.cs
+++ b/Backend/Api/Api/Models/Location.cs
@@ -22,8 +22,9 @@ namespace Api.Models
public enum LocationType
{
GRAD,ULICA,JEZERO,REKA,PLAZA,OKEAN, MORE, MOREUZ, MOST,BANJA,
- PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG,
- ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN
+ PLANINA, VISORAVAN, PIRAMIDA, LIVADA, SELO, OSTRVO, POLUOSTRVO, KLISURA, ARHIPELAG,
+ ADA, DELTA, FJORD, GEJZIR, IZVOR, KOTLINA, MINERALNI_IZVOR, PECINA ,SUMA, VODOPAD,VULKAN,
+ MUZEJ,ZAMAK,TRG,SPOMENIK,PARK,ZGRADA
}
public class Coords
diff --git a/Backend/Api/Api/Services/ChatHub.cs b/Backend/Api/Api/Services/ChatHub.cs
index 4092d8f..e0bf5df 100644
--- a/Backend/Api/Api/Services/ChatHub.cs
+++ b/Backend/Api/Api/Services/ChatHub.cs
@@ -1,12 +1,13 @@
-using Microsoft.AspNetCore.SignalR;
+using Api.Interfaces;
+using Microsoft.AspNetCore.SignalR;
namespace Api.Services
{
public class ChatHub:Hub
{
static public readonly Dictionary<string, string> Users = new Dictionary<string, string>();
- private readonly JwtService _jwtService;
- public ChatHub(JwtService jwtService)
+ private readonly IJwtService _jwtService;
+ public ChatHub(IJwtService jwtService)
{
_jwtService = jwtService;
}
diff --git a/Backend/Api/Api/Services/PostService.cs b/Backend/Api/Api/Services/PostService.cs
index 2d62f49..cc4d064 100644
--- a/Backend/Api/Api/Services/PostService.cs
+++ b/Backend/Api/Api/Services/PostService.cs
@@ -349,5 +349,21 @@ namespace Api.Services
}
return tosend;
}
+ public async Task<List<PostSend>> UserHistory(string userid)
+ {
+ var posts = await _posts.Find(_ => true).ToListAsync();
+ if (posts == null)
+ return null;
+ var tosend = new List<PostSend>();
+ foreach (var post in posts)
+ {
+ if (post.views.Any(x => x.Equals(userid)))
+ {
+ var x = await postToPostSend(post);
+ tosend.Add(x);
+ }
+ }
+ return tosend;
+ }
}
}