#81 api for getting reported comments
This commit is contained in:
parent
73dbb50da5
commit
78cea13652
@ -452,7 +452,7 @@ namespace RMuseum.Controllers
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorCommentFullViewModel>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
|
||||
public async Task<IActionResult> Get([FromQuery] PagingParameterModel paging)
|
||||
public async Task<IActionResult> GetRecentComments([FromQuery] PagingParameterModel paging)
|
||||
{
|
||||
var comments = await _ganjoorService.GetRecentComments(paging);
|
||||
if (!string.IsNullOrEmpty(comments.ExceptionString))
|
||||
@ -466,6 +466,30 @@ namespace RMuseum.Controllers
|
||||
return Ok(comments.Result.Items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get list of reported comments
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[Route("comments/reported")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable<GanjoorCommentFullViewModel>))]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> GetReportedComments([FromQuery] PagingParameterModel paging)
|
||||
{
|
||||
var comments = await _ganjoorService.GetReportedComments(paging);
|
||||
if (!string.IsNullOrEmpty(comments.ExceptionString))
|
||||
{
|
||||
return BadRequest(comments.ExceptionString);
|
||||
}
|
||||
|
||||
// Paging Header
|
||||
HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(comments.Result.PagingMeta));
|
||||
|
||||
return Ok(comments.Result.Items);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// post new comment
|
||||
/// </summary>
|
||||
|
||||
@ -152,6 +152,7 @@ namespace RMuseum.Models.Auth.Memory
|
||||
new SecurableItemOperation(ReviewSongs, "بازبینی آهنگهای پیشنهادی", false),
|
||||
new SecurableItemOperation(AddSongs, "افزودن آهنگ از هر منبع", false),
|
||||
new SecurableItemOperation(ImportOperationShortName, "ورود اطلاعات از منابع خارجی", false),
|
||||
new SecurableItemOperation(ModerateOperationShortName, "مدیریت حاشیهها", false),
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
namespace RMuseum.Models.Ganjoor.ViewModels
|
||||
{
|
||||
/// <summary>
|
||||
/// GanjoorCommentAbuseReport View Model
|
||||
/// </summary>
|
||||
public class GanjoorCommentAbuseReportViewModel
|
||||
{
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
public int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// reason code for better grouping: offensive, bogus, other
|
||||
/// </summary>
|
||||
public string ReasonCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// some explanotory text provided by reporter
|
||||
/// </summary>
|
||||
public string ReasonText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// comment
|
||||
/// </summary>
|
||||
public GanjoorCommentFullViewModel Comment { get; set; }
|
||||
}
|
||||
}
|
||||
@ -758,13 +758,20 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.Get(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetRecentComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<summary>
|
||||
get recent comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.GetReportedComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<summary>
|
||||
get list of reported comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.NewComment(RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentPostViewModel)">
|
||||
<summary>
|
||||
post new comment
|
||||
@ -4273,6 +4280,31 @@
|
||||
poems
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentAbuseReportViewModel">
|
||||
<summary>
|
||||
GanjoorCommentAbuseReport View Model
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentAbuseReportViewModel.Id">
|
||||
<summary>
|
||||
id
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentAbuseReportViewModel.ReasonCode">
|
||||
<summary>
|
||||
reason code for better grouping: offensive, bogus, other
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentAbuseReportViewModel.ReasonText">
|
||||
<summary>
|
||||
some explanotory text provided by reporter
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentAbuseReportViewModel.Comment">
|
||||
<summary>
|
||||
comment
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCommentFullViewModel.Id">
|
||||
<summary>
|
||||
Id
|
||||
@ -6192,6 +6224,13 @@
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetReportedComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<summary>
|
||||
Get list of reported comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.Faal">
|
||||
<summary>
|
||||
get a random poem from hafez
|
||||
@ -7039,6 +7078,13 @@
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetReportedComments(RSecurityBackend.Models.Generic.PagingParameterModel)">
|
||||
<summary>
|
||||
Get list of reported comments
|
||||
</summary>
|
||||
<param name="paging"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemImages(System.Int32)">
|
||||
<summary>
|
||||
get poem images by id (some fields are intentionally field with blank or null),
|
||||
|
||||
@ -194,6 +194,12 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentFullViewModel[] Items)>> GetRecentComments(PagingParameterModel paging);
|
||||
|
||||
/// <summary>
|
||||
/// Get list of reported comments
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentAbuseReportViewModel[] Items)>> GetReportedComments(PagingParameterModel paging);
|
||||
|
||||
/// <summary>
|
||||
/// get a random poem from hafez
|
||||
|
||||
@ -699,7 +699,69 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get list of reported comments
|
||||
/// </summary>
|
||||
/// <param name="paging"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentAbuseReportViewModel[] Items)>> GetReportedComments(PagingParameterModel paging)
|
||||
{
|
||||
try
|
||||
{
|
||||
var source =
|
||||
from report in _context.GanjoorReportedComments
|
||||
join comment in _context.GanjoorComments.Include(c => c.Poem).Include(c => c.User).Include(c => c.InReplyTo).ThenInclude(r => r.User)
|
||||
on report.GanjoorCommentId equals comment.Id
|
||||
orderby report.Id descending
|
||||
select
|
||||
new GanjoorCommentAbuseReportViewModel()
|
||||
{
|
||||
Id = report.Id,
|
||||
ReasonCode = report.ReasonCode,
|
||||
ReasonText = report.ReasonText,
|
||||
Comment = new GanjoorCommentFullViewModel()
|
||||
{
|
||||
Id = comment.Id,
|
||||
AuthorName = comment.User == null ? comment.AuthorName : $"{comment.User.FirstName} {comment.User.SureName}".Trim(),
|
||||
AuthorUrl = comment.AuthorUrl,
|
||||
CommentDate = comment.CommentDate,
|
||||
HtmlComment = comment.HtmlComment,
|
||||
InReplayTo = comment.InReplyTo == null ? null :
|
||||
new GanjoorCommentSummaryViewModel()
|
||||
{
|
||||
Id = comment.InReplyTo.Id,
|
||||
AuthorName = comment.InReplyTo.User == null ? comment.InReplyTo.AuthorName : $"{comment.InReplyTo.User.FirstName} {comment.InReplyTo.User.SureName}".Trim(),
|
||||
AuthorUrl = comment.InReplyTo.AuthorUrl,
|
||||
CommentDate = comment.InReplyTo.CommentDate,
|
||||
HtmlComment = comment.InReplyTo.HtmlComment,
|
||||
PublishStatus = ""
|
||||
},
|
||||
Poem = new GanjoorPoemSummaryViewModel()
|
||||
{
|
||||
Id = comment.Poem.Id,
|
||||
Title = comment.Poem.FullTitle,
|
||||
UrlSlug = comment.Poem.FullUrl,
|
||||
Excerpt = ""
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(PaginationMetadata PagingMeta, GanjoorCommentAbuseReportViewModel[] Items) paginatedResult =
|
||||
await QueryablePaginator<GanjoorCommentAbuseReportViewModel>.Paginate(source, paging);
|
||||
|
||||
|
||||
foreach (GanjoorCommentAbuseReportViewModel report in paginatedResult.Items)
|
||||
{
|
||||
report.Comment.AuthorName = report.Comment.AuthorName.ToPersianNumbers().ApplyCorrectYeKe();
|
||||
}
|
||||
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentAbuseReportViewModel[] Items)>(paginatedResult);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
return new RServiceResult<(PaginationMetadata PagingMeta, GanjoorCommentAbuseReportViewModel[] Items)>((PagingMeta: null, Items: null), exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user