committed by
GitHub
69 changed files with 5580 additions and 5238 deletions
@ -0,0 +1,23 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.Messages |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 消息处理器
|
||||
|
/// </summary>
|
||||
|
public interface IMessageProcessor |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// 撤回
|
||||
|
/// </summary>
|
||||
|
/// <param name="message"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task ReCallAsync(ChatMessage message); |
||||
|
/// <summary>
|
||||
|
/// 消息已读
|
||||
|
/// </summary>
|
||||
|
/// <param name="message"></param>
|
||||
|
/// <returns></returns>
|
||||
|
Task ReadAsync(ChatMessage message); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.Messages |
||||
|
{ |
||||
|
[Dependency(TryRegister = true)] |
||||
|
public class NullMessageProcessor : IMessageProcessor, ISingletonDependency |
||||
|
{ |
||||
|
public Task ReadAsync(ChatMessage message) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
|
||||
|
public Task ReCallAsync(ChatMessage message) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace LINGYUN.Abp.IM.Settings |
||||
|
{ |
||||
|
public static class AbpIMSettingNames |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using LINGYUN.Abp.MessageService.Localization; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Settings; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Settings |
||||
|
{ |
||||
|
public class MessageServiceSettingDefinitionProvider : SettingDefinitionProvider |
||||
|
{ |
||||
|
public override void Define(ISettingDefinitionContext context) |
||||
|
{ |
||||
|
context.Add( |
||||
|
new SettingDefinition( |
||||
|
MessageServiceSettingNames.Messages.RecallExpirationTime, |
||||
|
"2", |
||||
|
L("DisplayName:RecallExpirationTime"), |
||||
|
L("Description:RecallExpirationTime"), |
||||
|
isVisibleToClients: false, |
||||
|
isEncrypted: false) |
||||
|
.WithProviders( |
||||
|
GlobalSettingValueProvider.ProviderName, |
||||
|
TenantSettingValueProvider.ProviderName) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
protected ILocalizableString L(string name) |
||||
|
{ |
||||
|
return LocalizableString.Create<MessageServiceResource>(name); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
using LINGYUN.Abp.IM.Messages; |
||||
|
using LINGYUN.Abp.MessageService.Settings; |
||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Settings; |
||||
|
using Volo.Abp.Timing; |
||||
|
|
||||
|
namespace LINGYUN.Abp.MessageService.Chat |
||||
|
{ |
||||
|
[Dependency(ReplaceServices = true)] |
||||
|
public class MessageProcessor : IMessageProcessor, ITransientDependency |
||||
|
{ |
||||
|
private readonly IClock _clock; |
||||
|
private readonly IMessageRepository _repository; |
||||
|
private readonly ISettingProvider _settingProvider; |
||||
|
|
||||
|
public MessageProcessor(IMessageRepository repository) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
} |
||||
|
|
||||
|
public virtual async Task ReadAsync(ChatMessage message) |
||||
|
{ |
||||
|
if (!message.GroupId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
long groupId = long.Parse(message.GroupId); |
||||
|
var groupMessage = await _repository.GetGroupMessageAsync(groupId); |
||||
|
groupMessage.ChangeSendState(MessageState.Read); |
||||
|
|
||||
|
await _repository.UpdateGroupMessageAsync(groupMessage); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
long messageId = long.Parse(message.MessageId); |
||||
|
var userMessage = await _repository.GetUserMessageAsync(messageId); |
||||
|
userMessage.ChangeSendState(MessageState.Read); |
||||
|
|
||||
|
await _repository.UpdateUserMessageAsync(userMessage); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public virtual async Task ReCallAsync(ChatMessage message) |
||||
|
{ |
||||
|
var expiration = await _settingProvider.GetAsync( |
||||
|
MessageServiceSettingNames.Messages.RecallExpirationTime, 2d); |
||||
|
|
||||
|
Func<Message, bool> hasExpiredMessage = (Message msg) => |
||||
|
msg.CreationTime.AddMinutes(expiration) < _clock.Now; |
||||
|
|
||||
|
if (!message.GroupId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
long groupId = long.Parse(message.GroupId); |
||||
|
var groupMessage = await _repository.GetGroupMessageAsync(groupId); |
||||
|
if (hasExpiredMessage(groupMessage)) |
||||
|
{ |
||||
|
throw new BusinessException(MessageServiceErrorCodes.ExpiredMessageCannotBeReCall) |
||||
|
.WithData("Time", expiration); |
||||
|
} |
||||
|
|
||||
|
groupMessage.ChangeSendState(MessageState.ReCall); |
||||
|
|
||||
|
await _repository.UpdateGroupMessageAsync(groupMessage); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
long messageId = long.Parse(message.MessageId); |
||||
|
var userMessage = await _repository.GetUserMessageAsync(messageId); |
||||
|
if (hasExpiredMessage(userMessage)) |
||||
|
{ |
||||
|
throw new BusinessException(MessageServiceErrorCodes.ExpiredMessageCannotBeReCall) |
||||
|
.WithData("Time", expiration); |
||||
|
} |
||||
|
|
||||
|
userMessage.ChangeSendState(MessageState.ReCall); |
||||
|
|
||||
|
await _repository.UpdateUserMessageAsync(userMessage); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
# COMMON PATHS |
||||
|
|
||||
|
$rootFolder = (Get-Item -Path "./" -Verbose).FullName |
||||
|
|
||||
|
# List of solutions used only in development mode |
||||
|
$dependenciesFile = Join-Path $rootFolder "../build/modules.dependencies.json" |
||||
|
|
||||
|
function ReadFile($path) { |
||||
|
return (Get-Content -Raw -Encoding "UTF8" -Path "$path" ) |
||||
|
} |
||||
|
|
||||
|
function ReadJsonFile($path) { |
||||
|
$content = ReadFile $path |
||||
|
return ConvertFrom-Json -InputObject $content |
||||
|
} |
||||
|
|
||||
|
$modules = (ReadJsonFile -path $dependenciesFile) |
||||
|
|
||||
|
foreach ($module in $modules) { |
||||
|
foreach ($dependencieRoot in $module.dependencies) { |
||||
|
foreach ($dependencie in $dependencieRoot.dependencies) { |
||||
|
$thisPath = Join-Path $rootFolder $dependencieRoot.depPath |
||||
|
$modulePath = Join-Path $rootFolder $dependencieRoot.path |
||||
|
Write-host $thisPath |
||||
|
if (!(Test-Path $modulePath)) { |
||||
|
New-Item -ItemType Directory -Force -Path $modulePath |
||||
|
} |
||||
|
Copy-Item (Join-Path $thisPath $dependencie) -Destination $modulePath |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
[ |
||||
|
{ |
||||
|
"tag": "net5.0", |
||||
|
"dependencies": [ |
||||
|
{ |
||||
|
"service": "Backend-Admin", |
||||
|
"path": "/../aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Modules/", |
||||
|
"depPath": "/../aspnet-core/LocalNuget/net5.0/", |
||||
|
"dependencies": [ |
||||
|
"LINGYUN.ApiGateway.Application.Contracts.dll", |
||||
|
"LINGYUN.ApiGateway.Domain.Shared.dll", |
||||
|
"LINGYUN.Abp.Aliyun.SettingManagement.dll", |
||||
|
"LINGYUN.Abp.Sms.Aliyun.dll", |
||||
|
"LINGYUN.Abp.Aliyun.dll", |
||||
|
"LINGYUN.Abp.WeChat.MiniProgram.dll", |
||||
|
"LINGYUN.Abp.WeChat.Official.dll", |
||||
|
"LINGYUN.Abp.WeChat.dll", |
||||
|
"LINGYUN.Abp.WeChat.SettingManagement.dll", |
||||
|
"LINGYUN.Abp.LocalizationManagement.Application.Contracts.dll", |
||||
|
"LINGYUN.Abp.LocalizationManagement.Domain.Shared.dll", |
||||
|
"LINGYUN.Abp.OssManagement.Application.Contracts.dll", |
||||
|
"LINGYUN.Abp.OssManagement.Domain.Shared.dll", |
||||
|
"LINGYUN.Abp.MessageService.Application.Contracts.dll", |
||||
|
"LINGYUN.Abp.IM.dll", |
||||
|
"LINGYUN.Abp.MessageService.Domain.Shared.dll", |
||||
|
"LINGYUN.Abp.RealTime.dll", |
||||
|
"LINGYUN.Abp.Notifications.dll", |
||||
|
"LINGYUN.Platform.Application.Contracts.dll", |
||||
|
"LINGYUN.Platform.Domain.Shared.dll" |
||||
|
] |
||||
|
}, |
||||
|
{ |
||||
|
"service": "Backend-Admin", |
||||
|
"path": "/../aspnet-core/services/admin/LINGYUN.Abp.BackendAdmin.HttpApi.Host/Modules/", |
||||
|
"depPath": "/../aspnet-core/services/identity-server/LINGYUN.Abp.IdentityServer4.HttpApi.Host/bin/Debug/net5.0", |
||||
|
"dependencies": [ |
||||
|
"LINGYUN.Abp.Account.Application.Contracts.dll", |
||||
|
"Volo.Abp.Account.Application.Contracts.dll", |
||||
|
"Volo.Abp.Identity.Application.Contracts.dll", |
||||
|
"LINGYUN.Abp.Identity.Application.Contracts.dll", |
||||
|
"LINGYUN.Abp.Identity.Domain.Shared.dll", |
||||
|
"Volo.Abp.Identity.Domain.Shared.dll", |
||||
|
"Volo.Abp.Users.Domain.Shared.dll", |
||||
|
"Volo.Abp.Users.Abstractions.dll", |
||||
|
"LINGYUN.Abp.IdentityServer.Application.Contracts.dll", |
||||
|
"Volo.Abp.IdentityServer.Domain.Shared.dll" |
||||
|
] |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
] |
||||
Loading…
Reference in new issue