aboutsummaryrefslogtreecommitdiff
path: root/Backend
diff options
context:
space:
mode:
authorTAMARA JERINIC <tamara.jerinic@gmail.com>2022-12-13 03:42:01 +0100
committerTAMARA JERINIC <tamara.jerinic@gmail.com>2022-12-13 03:42:01 +0100
commit61f1cd36b0d2263cd1c19f9d44004131639ae776 (patch)
tree28add109b59248a9174e28bcb3c27cc2a18e8220 /Backend
parent7e322b41ab26c0b1b0a4c7bacca24d1e63530cd7 (diff)
parent5ffa30b80f06a87eef13dd830959a4289c787a35 (diff)
Merge branch 'develop' of http://gitlab.pmf.kg.ac.rs/BrzoDoLokacije2022/odyssey/brzodolokacije into develop
Diffstat (limited to 'Backend')
-rw-r--r--Backend/Api/Api/Services/MessageService.cs7
1 files changed, 6 insertions, 1 deletions
diff --git a/Backend/Api/Api/Services/MessageService.cs b/Backend/Api/Api/Services/MessageService.cs
index 9cc818b..71df70c 100644
--- a/Backend/Api/Api/Services/MessageService.cs
+++ b/Backend/Api/Api/Services/MessageService.cs
@@ -10,13 +10,15 @@ namespace Api.Services
{
private readonly IHttpContextAccessor _httpContext;
private readonly IMongoCollection<Message> _messages;
+ private readonly IUserService _userService;
private readonly IJwtService _jwtService;
private IConfiguration _configuration;
private readonly IHubContext<ChatHub> _chatHub;
- public MessageService(IDatabaseConnection settings, IMongoClient mongoClient, IJwtService jwtService, IHttpContextAccessor httpContextAccessor, IConfiguration configuration,IHubContext<ChatHub> chatHub)
+ public MessageService(IDatabaseConnection settings, IMongoClient mongoClient, IUserService userService, IJwtService jwtService, IHttpContextAccessor httpContextAccessor, IConfiguration configuration,IHubContext<ChatHub> chatHub)
{
var database = mongoClient.GetDatabase(settings.DatabaseName);
_messages = database.GetCollection<Message>(settings.MessageCollectionname);
+ _userService = userService;
_jwtService = jwtService;
_httpContext = httpContextAccessor;
_configuration = configuration;
@@ -29,6 +31,9 @@ namespace Api.Services
var senderId = _httpContext.HttpContext.User.FindFirstValue("id").ToString();
if (senderId == null)
return null;
+ var receiverCheck =await _userService.GetSelfUserData(msg.receiverId);
+ if (receiverCheck == null)
+ return null;
var tempMsg = new Message();
tempMsg._id = "";
tempMsg.receiverId = msg.receiverId;