From ca54d32fe4ee36a3294a634a0ac83de4a6fe01d8 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Wed, 24 Mar 2021 13:12:30 +0430 Subject: [PATCH] fix for new comments --- RMuseum/Services/Implementation/GanjoorService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 4c1ebb50..f7fc6ea8 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -613,7 +613,8 @@ namespace RMuseum.Services.Implementation HtmlComment = comment.HtmlComment, PublishStatus = comment.Status == PublishStatus.Awaiting ? "در انتظار تأیید" : "", InReplyToId = comment.InReplyToId, - UserId = comment.UserId + UserId = comment.UserId, + Replies = new GanjoorCommentSummaryViewModel[] { } } ); } @@ -730,7 +731,7 @@ namespace RMuseum.Services.Implementation var replies = await _FindReplies(comment); for (int i = replies.Count - 1; i >= 0; i--) { - if (replies[i].UserId != null) + if (replies[i].UserId != null && replies[i].UserId != userId) { await _notificationService.PushNotification((Guid)replies[i].UserId, "حذف پاسخ شما به حاشیه", @@ -756,9 +757,14 @@ namespace RMuseum.Services.Implementation private async Task> _FindReplies(GanjoorComment comment) { List replies = await _context.GanjoorComments.Where(c => c.InReplyToId == comment.Id).ToListAsync(); + List replyToReplies = new List(); foreach (GanjoorComment reply in replies) { - replies.AddRange(await _FindReplies(reply)); + replyToReplies.AddRange(await _FindReplies(reply)); + } + if(replyToReplies.Count > 0) + { + replies.AddRange(replyToReplies); } return replies; }