Merge branch 'master' of http://195.88.208.142:3000/mmr/_Hushian
This commit is contained in:
@@ -5,6 +5,6 @@ namespace Common.Contracts.Infrastructure
|
||||
{
|
||||
public interface IMessageSender
|
||||
{
|
||||
Task<bool> SendMassage(Message message);
|
||||
Task<bool> SendMessageVerification(string To, string Code);
|
||||
}
|
||||
}
|
||||
|
@@ -6,6 +6,12 @@ namespace Hushian.Application.Models.Message
|
||||
{
|
||||
public class Message
|
||||
{
|
||||
public Message(string to, string msg)
|
||||
{
|
||||
To = to;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public string To { get; set; }
|
||||
public string msg { get; set; }
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ using Hushian.Application.Contracts.Persistence;
|
||||
using Hushian.Application.Models;
|
||||
using Hushian.Domain.Entites;
|
||||
using Hushian.WebApi;
|
||||
using Microsoft.AspNetCore.Components.Routing;
|
||||
using Microsoft.AspNetCore.Routing.Constraints;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@@ -280,20 +281,20 @@ namespace Hushian.Application.Services
|
||||
await _ConversationRepository.UPDATE(convModel);
|
||||
}
|
||||
if (dto.Type != ConversationType.UE)
|
||||
await WriteInHubFromCompany(Response.Value, convModel.UserID);
|
||||
await WriteInHubFromCompany(Response.Value, "U"+convModel.UserID);
|
||||
else
|
||||
{
|
||||
var modelA = convModel.ConversationResponses.OrderBy(o => o.ID)
|
||||
.LastOrDefault(l => l.Type == ConversationType.EU || l.Type == ConversationType.CU);
|
||||
if (modelA != null)
|
||||
{
|
||||
int userid = 0;
|
||||
string user ="";
|
||||
|
||||
if (modelA.Type == ConversationType.EU) userid = modelA.ExperID.Value;
|
||||
if (modelA.Type == ConversationType.EU) user = modelA.ExperID.Value.ToString();
|
||||
|
||||
else if (modelA.Type == ConversationType.CU) userid = modelA.conversation.CompanyID;
|
||||
else if (modelA.Type == ConversationType.CU) user = "C"+modelA.conversation.CompanyID;
|
||||
|
||||
await WriteInHubFromUser(Response.Value, userid);
|
||||
await WriteInHubFromUser(Response.Value, user);
|
||||
|
||||
}
|
||||
|
||||
@@ -386,14 +387,14 @@ namespace Hushian.Application.Services
|
||||
|
||||
if( (await _ConversationResponseRepository.UPDATE(item)) != null)
|
||||
{
|
||||
int userID = 0;
|
||||
if (item.Type == ConversationType.EU) userID = item.ExperID.Value;
|
||||
string user = "";
|
||||
if (item.Type == ConversationType.EU) user = item.ExperID.Value.ToString();
|
||||
|
||||
else if (item.Type == ConversationType.CU) userID = item.conversation.CompanyID;
|
||||
else if (item.Type == ConversationType.CU) user = "C" + item.conversation.CompanyID;
|
||||
|
||||
else if (item.Type == ConversationType.UE) userID = item.conversation.UserID;
|
||||
else if (item.Type == ConversationType.UE) user = "U"+ item.conversation.UserID;
|
||||
|
||||
await CheckMarkAsReadInHub(item.ID, userID);
|
||||
await CheckMarkAsReadInHub(item.ID, user);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -486,9 +487,9 @@ namespace Hushian.Application.Services
|
||||
if (Response.Value != null) Response.Success = true;
|
||||
return Response;
|
||||
}
|
||||
public async Task WriteInHubFromCompany(ChatItemResponseDto item, int UserID)
|
||||
public async Task WriteInHubFromCompany(ChatItemResponseDto item, string ToUser)
|
||||
{
|
||||
await _hubContext.Clients.User(UserID.ToString())
|
||||
await _hubContext.Clients.User(ToUser)
|
||||
.SendAsync("ReceiveNewChatItemFromCompany", item);
|
||||
|
||||
//// فرض: لیستی از کاربرانی که به گفتگو دسترسی دارند
|
||||
@@ -500,14 +501,14 @@ namespace Hushian.Application.Services
|
||||
// // .SendAsync("ReceiveNewConversation", conv.Id, conv.Title);
|
||||
//}
|
||||
}
|
||||
public async Task WriteInHubFromUser(ChatItemResponseDto item, int UserID)
|
||||
public async Task WriteInHubFromUser(ChatItemResponseDto item, string ToUser)
|
||||
{
|
||||
await _hubContext.Clients.User(UserID.ToString())
|
||||
await _hubContext.Clients.User(ToUser)
|
||||
.SendAsync("ReceiveNewChatItemFromUser", item);
|
||||
}
|
||||
public async Task CheckMarkAsReadInHub(int item, int UserID)
|
||||
public async Task CheckMarkAsReadInHub(int item, string ToUser)
|
||||
{
|
||||
await _hubContext.Clients.User(UserID.ToString())
|
||||
await _hubContext.Clients.User(ToUser)
|
||||
.SendAsync("CheckMarkAsRead", item);
|
||||
}
|
||||
public async Task NewChatInHub(int CompanyID)
|
||||
|
@@ -27,7 +27,10 @@ namespace Hushian.Application.Services
|
||||
{
|
||||
var claims = new[]
|
||||
{
|
||||
new Claim(JwtRegisteredClaimNames.Sub,userId.ToString()),
|
||||
new Claim(JwtRegisteredClaimNames.Sub,
|
||||
Role=="User" ? "U"+userId.ToString()
|
||||
:Role=="Company" ? "C"+userId.ToString()
|
||||
:userId.ToString()),
|
||||
new Claim(ClaimTypes.NameIdentifier, UserName),
|
||||
new Claim(CustomClaimTypes.Uid,userId.ToString()),
|
||||
new Claim(ClaimTypes.Role, Role)
|
||||
|
@@ -45,11 +45,7 @@ namespace Hushian.Application.Services
|
||||
string Code = await GenerateCode();
|
||||
var response= await _VerificationCodeRepository.ADD
|
||||
(new Identity.Models.VerificationCode(VerificationCodeType.Login, Code, Mobile));
|
||||
await _messageSender.SendMassage(new Models.Message.Message()
|
||||
{
|
||||
msg = Code,
|
||||
To = Mobile
|
||||
});
|
||||
await _messageSender.SendMessageVerification(Mobile, Code);
|
||||
return response.ID;
|
||||
}
|
||||
public async Task<int> GenerateCodeByPhoneNumberConfirmed(string Mobile)
|
||||
@@ -57,11 +53,7 @@ namespace Hushian.Application.Services
|
||||
string Code = await GenerateCode();
|
||||
var response = await _VerificationCodeRepository.ADD
|
||||
(new Identity.Models.VerificationCode(VerificationCodeType.PhoneNumberConfirmed, Code, Mobile));
|
||||
await _messageSender.SendMassage(new Models.Message.Message()
|
||||
{
|
||||
msg = Code,
|
||||
To = Mobile
|
||||
});
|
||||
await _messageSender.SendMessageVerification(Mobile, Code);
|
||||
return response.ID;
|
||||
}
|
||||
public async Task<int> GenerateCodeByForgetPassword(string Mobile)
|
||||
@@ -69,11 +61,7 @@ namespace Hushian.Application.Services
|
||||
string Code = await GenerateCode();
|
||||
var response = await _VerificationCodeRepository.ADD
|
||||
(new Identity.Models.VerificationCode(VerificationCodeType.ForgetPassword, Code, Mobile));
|
||||
await _messageSender.SendMassage(new Models.Message.Message()
|
||||
{
|
||||
msg = Code,
|
||||
To = Mobile
|
||||
});
|
||||
await _messageSender.SendMessageVerification(Mobile, Code);
|
||||
return response.ID;
|
||||
}
|
||||
public async Task<ResponseBase<AuthResponse>> VerificationCode(ConfirmedCodeDto model)
|
||||
@@ -193,11 +181,7 @@ namespace Hushian.Application.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
return await _messageSender.SendMassage(new Models.Message.Message()
|
||||
{
|
||||
msg = model.Code,
|
||||
To = model.Mobile
|
||||
});
|
||||
return await _messageSender.SendMessageVerification(model.Mobile, model.Code);
|
||||
}
|
||||
}
|
||||
private async Task<string> GenerateCode()
|
||||
|
@@ -14,11 +14,14 @@ namespace Hushian.Infrastructure
|
||||
_restClient = restClient;
|
||||
_msgSettings = msgSettings.Value;
|
||||
}
|
||||
|
||||
public Task<bool> SendMassage(Message message)
|
||||
public async Task<bool> SendMessageVerification(string To,string Code)
|
||||
{
|
||||
return await SendMassage(new Message(To,$"برای ادامه از کد {Code} استفاده کنید"));
|
||||
}
|
||||
private Task<bool> SendMassage(Message message)
|
||||
{
|
||||
string From = _msgSettings.From;
|
||||
// _restClient.Send(message.To, From, message.msg, false);
|
||||
_restClient.Send(message.To, From, message.msg, false);
|
||||
return Task.Run(()=>true);
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,10 @@
|
||||
@using HushianWebApp.Services
|
||||
@using Microsoft.AspNetCore.SignalR.Client;
|
||||
@using System.Threading;
|
||||
<PageTitle>گفتگو با @CompanyInfo.FullName</PageTitle>
|
||||
@if(CompanyInfo!=null)
|
||||
{
|
||||
<PageTitle>گفتگو با @CompanyInfo?.FullName</PageTitle>
|
||||
}
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ChatService ChatService
|
||||
@inject ILocalStorageService localStorageService;
|
||||
@@ -131,12 +134,12 @@
|
||||
هوشیان
|
||||
</p>
|
||||
|
||||
@if (CompanyGroups != null && CompanyGroups.Any())
|
||||
@if (CompanyGroups != null && CompanyGroups.Any(w => w.Available))
|
||||
{
|
||||
<div class="groups-container mt-4">
|
||||
<h6 class="text-center mb-3 text-muted">انتخاب گروه:</h6>
|
||||
<div class="groups-grid">
|
||||
@foreach (var group in CompanyGroups)
|
||||
@foreach (var group in CompanyGroups.Where(w=>w.Available))
|
||||
{
|
||||
<div class="group-card @(GroupID == group.ID ? "selected" : "")"
|
||||
@onclick="() => SelectGroup(group.ID)">
|
||||
@@ -162,7 +165,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
@if (LastOpenChat == null || (LastOpenChat != null && LastOpenChat.status != Common.Enums.ConversationStatus.Finished && LastOpenChat.Responses != null))
|
||||
@if (CompanyInfo != null && (LastOpenChat == null || (LastOpenChat != null && LastOpenChat.status != Common.Enums.ConversationStatus.Finished && LastOpenChat.Responses != null)))
|
||||
{
|
||||
<!-- B2: Message input -->
|
||||
<div class="message-input-container" id="B2">
|
||||
@@ -270,7 +273,7 @@
|
||||
ReadANDUpdate_CompanyDto? CompanyInfo = new();
|
||||
Common.Dtos.CurrentUserInfo CurrentUser = new();
|
||||
List<Read_GroupDto> CompanyGroups = new();
|
||||
ChatItemDto? LastOpenChat = new();
|
||||
ChatItemDto? LastOpenChat = null;
|
||||
string MsgInput = string.Empty;
|
||||
IBrowserFile? SelectedImageFile = null;
|
||||
byte[]? SelectedImageBytes = null;
|
||||
@@ -367,7 +370,7 @@
|
||||
IsRecording = false;
|
||||
recordingTimer?.Dispose();
|
||||
recordingTimer = null;
|
||||
await ClearSelectedImage();
|
||||
await ClearSelectedImage();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -566,8 +569,8 @@
|
||||
{
|
||||
CompanyInfo = await companyService.GetCompany(CompanyID);
|
||||
if (CompanyInfo != null)
|
||||
CompanyGroups = await groupService.GetGroupsCompany(CompanyID);
|
||||
await IsLastChat();
|
||||
{ CompanyGroups = await groupService.GetGroupsCompany(CompanyID);
|
||||
await IsLastChat();}
|
||||
}
|
||||
async Task IsLastChat()
|
||||
{
|
||||
@@ -594,6 +597,7 @@
|
||||
[JSInvokable]
|
||||
public async Task MarkAsRead(int id)
|
||||
{
|
||||
if (LastOpenChat == null) return;
|
||||
var msg = LastOpenChat.Responses.FirstOrDefault(m => m.ID == id);
|
||||
if (msg != null && !msg.IsRead && msg.Type != Common.Enums.ConversationType.UE)
|
||||
{
|
||||
|
Reference in New Issue
Block a user