|
|
|
@ -3,6 +3,8 @@ using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using SixLabors.ImageSharp.Formats.Gif; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Authorization; |
|
|
|
using Volo.Abp.Data; |
|
|
|
@ -13,6 +15,7 @@ using Volo.Abp.Users; |
|
|
|
using Volo.CmsKit.Comments; |
|
|
|
using Volo.CmsKit.Features; |
|
|
|
using Volo.CmsKit.GlobalFeatures; |
|
|
|
using Volo.CmsKit.Public.Application.Security.VoloCaptcha; |
|
|
|
using Volo.CmsKit.Users; |
|
|
|
|
|
|
|
namespace Volo.CmsKit.Public.Comments; |
|
|
|
@ -26,16 +29,20 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli |
|
|
|
public IDistributedEventBus DistributedEventBus { get; } |
|
|
|
protected CommentManager CommentManager { get; } |
|
|
|
|
|
|
|
public SimpleMathsCaptchaGenerator SimpleMathsCaptchaGenerator { get; } |
|
|
|
|
|
|
|
public CommentPublicAppService( |
|
|
|
ICommentRepository commentRepository, |
|
|
|
ICmsUserLookupService cmsUserLookupService, |
|
|
|
IDistributedEventBus distributedEventBus, |
|
|
|
CommentManager commentManager) |
|
|
|
CommentManager commentManager, |
|
|
|
SimpleMathsCaptchaGenerator simpleMathsCaptchaGenerator) |
|
|
|
{ |
|
|
|
CommentRepository = commentRepository; |
|
|
|
CmsUserLookupService = cmsUserLookupService; |
|
|
|
DistributedEventBus = distributedEventBus; |
|
|
|
CommentManager = commentManager; |
|
|
|
SimpleMathsCaptchaGenerator = simpleMathsCaptchaGenerator; |
|
|
|
} |
|
|
|
|
|
|
|
public virtual async Task<ListResultDto<CommentWithDetailsDto>> GetListAsync(string entityType, string entityId) |
|
|
|
@ -51,6 +58,11 @@ public class CommentPublicAppService : CmsKitPublicAppServiceBase, ICommentPubli |
|
|
|
[Authorize] |
|
|
|
public virtual async Task<CommentDto> CreateAsync(string entityType, string entityId, CreateCommentInput input) |
|
|
|
{ |
|
|
|
if (input.RepliedCommentId.HasValue) |
|
|
|
{ |
|
|
|
SimpleMathsCaptchaGenerator.Validate(input.CaptchaToken.Value, input.CaptchaAnswer); |
|
|
|
} |
|
|
|
|
|
|
|
var user = await CmsUserLookupService.GetByIdAsync(CurrentUser.GetId()); |
|
|
|
|
|
|
|
if (input.RepliedCommentId.HasValue) |
|
|
|
|