diff --git a/RMuseum/Controllers/ArtifactController.cs b/RMuseum/Controllers/ArtifactController.cs index 6b3d458e..98afe250 100644 --- a/RMuseum/Controllers/ArtifactController.cs +++ b/RMuseum/Controllers/ArtifactController.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Caching.Memory; +using Microsoft.Extensions.Configuration; using Newtonsoft.Json; using RMuseum.Models.Artifact; using RMuseum.Models.Artifact.ViewModels; @@ -39,8 +40,8 @@ namespace RMuseum.Controllers [AllowAnonymous] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - - public async Task Get([FromQuery]PagingParameterModel paging) + + public async Task Get([FromQuery] PagingParameterModel paging) { var cacheKey = $"artifacts/all/{paging.PageSize}/{paging.PageNumber}"; if (!_memoryCache.TryGetValue(cacheKey, out RServiceResult<(PaginationMetadata PagingMeta, RArtifactMasterRecord[] Items)> itemsInfo)) @@ -49,12 +50,12 @@ namespace RMuseum.Controllers if (!string.IsNullOrEmpty(itemsInfo.ExceptionString)) { return BadRequest(itemsInfo.ExceptionString); - } + } _memoryCache.Set(cacheKey, itemsInfo); - } + } - if(itemsInfo.Result.Items.Count() > 0) + if (itemsInfo.Result.Items.Count() > 0) { DateTime lastModification = itemsInfo.Result.Items.Max(i => i.LastModified); Response.GetTypedHeaders().LastModified = lastModification; @@ -123,7 +124,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetUserVisible([FromQuery]PagingParameterModel paging) + public async Task GetUserVisible([FromQuery] PagingParameterModel paging) { RServiceResult v = await _GetUserVisibleArtifactStatusSet ( @@ -170,7 +171,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] public async Task GetByTagValue(string tagUrl, string valueUrl) { - RServiceResult itemsInfo = await _artifactService.GetByTagValue(tagUrl, valueUrl, new PublishStatus[] { PublishStatus.Published } ); + RServiceResult itemsInfo = await _artifactService.GetByTagValue(tagUrl, valueUrl, new PublishStatus[] { PublishStatus.Published }); if (!string.IsNullOrEmpty(itemsInfo.ExceptionString)) { return BadRequest(itemsInfo.ExceptionString); @@ -217,7 +218,7 @@ namespace RMuseum.Controllers return NotFound(); _memoryCache.Set(cacheKey, itemInfo); - } + } Response.GetTypedHeaders().LastModified = itemInfo.Result.LastModified; @@ -264,7 +265,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] public async Task GetByFriendlyUrlFilterItemsByTag(string friendlyUrl, string tagFriendlyUrl) - { + { return await GetByFriendlyUrlFilterItemsByTag(friendlyUrl, tagFriendlyUrl, null); } @@ -283,7 +284,7 @@ namespace RMuseum.Controllers public async Task GetByFriendlyUrlFilterItemsByTag(string friendlyUrl, string tagFriendlyUrl, string valueFriendlyUrl) { var cacheKey = $"{friendlyUrl}/filteritemsbytag/{tagFriendlyUrl}"; - if(valueFriendlyUrl != null) + if (valueFriendlyUrl != null) { cacheKey += $"/{valueFriendlyUrl}"; } @@ -295,10 +296,10 @@ namespace RMuseum.Controllers return BadRequest(itemInfo.ExceptionString); } if (itemInfo.Result == null) - return NotFound(); + return NotFound(); _memoryCache.Set(cacheKey, itemInfo); - } + } Response.GetTypedHeaders().LastModified = itemInfo.Result.LastModified; @@ -349,11 +350,11 @@ namespace RMuseum.Controllers _memoryCache.Set(cacheKey, itemInfo); } } - if(itemInfo == null) + if (itemInfo == null) { itemInfo = await _artifactService.GetByFriendlyUrl(friendlyUrl, visibleItems); } - + if (!string.IsNullOrEmpty(itemInfo.ExceptionString)) { return BadRequest(itemInfo.ExceptionString); @@ -412,7 +413,7 @@ namespace RMuseum.Controllers if (!string.IsNullOrEmpty(v.ExceptionString)) return BadRequest(v.ExceptionString); PublishStatus[] visibleItems = v.Result; - if(visibleItems.Length == 1 && visibleItems[0] == PublishStatus.Published) + if (visibleItems.Length == 1 && visibleItems[0] == PublishStatus.Published) { return await GetByFriendlyUrlFilterItemsByTag(friendlyUrl, tagFriendlyUrl, valueFriendlyUrl); } @@ -450,7 +451,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task Put(Guid id, [FromBody]RArtifactMasterRecord item) + public async Task Put(Guid id, [FromBody] RArtifactMasterRecord item) { if (id != item.Id) { @@ -490,12 +491,12 @@ namespace RMuseum.Controllers return BadRequest(itemInfo.ExceptionString); } - if(itemInfo == null) + if (itemInfo == null) { return NotFound(); } - return Ok();; + return Ok(); ; } /// @@ -508,7 +509,7 @@ namespace RMuseum.Controllers [Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task SetArtifactCoverItemIndex(Guid id, [FromBody]int itemIndex) + public async Task SetArtifactCoverItemIndex(Guid id, [FromBody] int itemIndex) { RServiceResult res = await _artifactService.SetArtifactCoverItemIndex(id, itemIndex); if (!string.IsNullOrEmpty(res.ExceptionString)) @@ -546,7 +547,7 @@ namespace RMuseum.Controllers RServiceResult lastModified = await _artifactService.GetMaxArtifactLastModified(); - if(!string.IsNullOrEmpty(lastModified.ExceptionString)) + if (!string.IsNullOrEmpty(lastModified.ExceptionString)) { return BadRequest(lastModified.ExceptionString); } @@ -573,7 +574,7 @@ namespace RMuseum.Controllers [Authorize(Policy = RMuseumSecurableItem.TagEntityShortName + ":" + SecurableItem.ModifyOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RTag))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task NewTag([FromBody]RTag tag) + public async Task NewTag([FromBody] RTag tag) { RServiceResult res = await _artifactService.AddTag(tag.Name); if (!string.IsNullOrEmpty(res.ExceptionString)) @@ -590,7 +591,7 @@ namespace RMuseum.Controllers [AllowAnonymous] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetTags([FromQuery]PagingParameterModel paging) + public async Task GetTags([FromQuery] PagingParameterModel paging) { RServiceResult<(PaginationMetadata PagingMeta, RTag[] Items)> itemsInfo = await _artifactService.GetAllTags(paging); if (!string.IsNullOrEmpty(itemsInfo.ExceptionString)) @@ -613,7 +614,7 @@ namespace RMuseum.Controllers if (!string.IsNullOrEmpty(tag.ExceptionString)) { return BadRequest(tag.ExceptionString); - } + } return Ok(tag.Result); } @@ -633,7 +634,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task PutTag(Guid tagid, [FromBody]RTag tag) + public async Task PutTag(Guid tagid, [FromBody] RTag tag) { if (tagid != tag.Id) { @@ -651,7 +652,7 @@ namespace RMuseum.Controllers return NotFound(); } - return Ok();; + return Ok(); ; } /// @@ -756,7 +757,7 @@ namespace RMuseum.Controllers [Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + RMuseumSecurableItem.EditTagValueOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RTagValue))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task NewArtifactTagValue(Guid artifactId, [FromBody]RTag tag) + public async Task NewArtifactTagValue(Guid artifactId, [FromBody] RTag tag) { RServiceResult res = await _artifactService.TagArtifact(artifactId, tag); if (!string.IsNullOrEmpty(res.ExceptionString)) @@ -780,7 +781,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task PutAttributeValue(Guid artifactid, bool global, [FromBody]RTagValue tagvalue) + public async Task PutAttributeValue(Guid artifactid, bool global, [FromBody] RTagValue tagvalue) { RServiceResult itemInfo = await _artifactService.EditTagValue(artifactid, tagvalue, global); @@ -794,7 +795,7 @@ namespace RMuseum.Controllers return NotFound(); } - return Ok();; + return Ok(); ; } /// @@ -828,7 +829,7 @@ namespace RMuseum.Controllers [Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + RMuseumSecurableItem.EditTagValueOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RTagValue))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task NewItemTagValue(Guid itemId, [FromBody]RTag tag) + public async Task NewItemTagValue(Guid itemId, [FromBody] RTag tag) { RServiceResult res = await _artifactService.TagItem(itemId, tag); if (!string.IsNullOrEmpty(res.ExceptionString)) @@ -851,7 +852,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.OK)] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] [ProducesResponseType((int)HttpStatusCode.NotFound)] - public async Task PutItemTagValue(Guid itemId, bool global, [FromBody]RTagValue tagvalue) + public async Task PutItemTagValue(Guid itemId, bool global, [FromBody] RTagValue tagvalue) { RServiceResult itemInfo = await _artifactService.EditItemTagValue(itemId, tagvalue, global); @@ -865,7 +866,7 @@ namespace RMuseum.Controllers return NotFound(); } - return Ok();; + return Ok(); ; } /// @@ -1040,7 +1041,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] public virtual async Task Post() { - + try { NewArtifact newArtifactInfo = @@ -1067,11 +1068,11 @@ namespace RMuseum.Controllers return BadRequest(result.ExceptionString); return Ok(result.Result); } - catch(Exception exp) + catch (Exception exp) { return BadRequest(exp.ToString()); } - + } /// @@ -1140,7 +1141,7 @@ namespace RMuseum.Controllers [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] public async Task ReExamineLocDownloads(string pass) { - if(pass != "123456") //this is a heavy processor consuming call, so prevent mistaken call of it from swagger ui + if (pass != "123456") //this is a heavy processor consuming call, so prevent mistaken call of it from swagger ui return BadRequest("invalid password"); RServiceResult res = await _artifactService.ReExamineLocDownloads(); if (!string.IsNullOrEmpty(res.ExceptionString)) @@ -1153,7 +1154,7 @@ namespace RMuseum.Controllers [Authorize(Policy = RMuseumSecurableItem.ArtifactEntityShortName + ":" + SecurableItem.AddOperationShortName)] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetImportJobs([FromQuery]PagingParameterModel paging) + public async Task GetImportJobs([FromQuery] PagingParameterModel paging) { RServiceResult<(PaginationMetadata PagingMeta, ImportJob[] Items)> itemsInfo = await _artifactService.GetImportJobs(paging); if (!string.IsNullOrEmpty(itemsInfo.ExceptionString)) @@ -1250,7 +1251,7 @@ namespace RMuseum.Controllers [HttpPost] [Route("fav/item/{itemId}")] [Authorize] - [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserBookmark))] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserBookmark))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] public async Task FavItem(Guid itemId) { @@ -1308,7 +1309,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserBookmark[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetUserBookmarks([FromQuery]PagingParameterModel paging) + public async Task GetUserBookmarks([FromQuery] PagingParameterModel paging) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult v = await _GetUserVisibleArtifactStatusSet @@ -1320,7 +1321,7 @@ namespace RMuseum.Controllers return BadRequest(v.ExceptionString); PublishStatus[] visibleItems = v.Result; - + RServiceResult<(PaginationMetadata PagingMeta, RUserBookmarkViewModel[] Bookmarks)> res = await _artifactService.GetBookmarks(paging, loggedOnUserId, RBookmarkType.Bookmark, visibleItems); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); @@ -1338,7 +1339,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserBookmarkViewModel[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetUserFavorites([FromQuery]PagingParameterModel paging) + public async Task GetUserFavorites([FromQuery] PagingParameterModel paging) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult v = await _GetUserVisibleArtifactStatusSet @@ -1368,13 +1369,13 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task AddUserNoteToArtifact([FromBody]PostUserNote note) + public async Task AddUserNoteToArtifact([FromBody] PostUserNote note) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult res = await _artifactService.AddUserNoteToArtifact(note.EntityId, loggedOnUserId, note.NoteType, note.Contents, note.ReferenceNoteId); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); - + return Ok(res.Result); } @@ -1388,7 +1389,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task AddUserNoteToArtifactItem([FromBody]PostUserNote note) + public async Task AddUserNoteToArtifactItem([FromBody] PostUserNote note) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult res = await _artifactService.AddUserNoteToArtifactItem(note.EntityId, loggedOnUserId, note.NoteType, note.Contents, note.ReferenceNoteId); @@ -1411,7 +1412,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task EditUserNote(Guid noteId, [FromBody]PostUserNote note) + public async Task EditUserNote(Guid noteId, [FromBody] PostUserNote note) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); @@ -1558,7 +1559,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetUserPublicNotes([FromQuery]PagingParameterModel paging) + public async Task GetUserPublicNotes([FromQuery] PagingParameterModel paging) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult v = await _GetUserVisibleArtifactStatusSet @@ -1588,7 +1589,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetUserPrivateNotes([FromQuery]PagingParameterModel paging) + public async Task GetUserPrivateNotes([FromQuery] PagingParameterModel paging) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult v = await _GetUserVisibleArtifactStatusSet @@ -1618,8 +1619,8 @@ namespace RMuseum.Controllers [AllowAnonymous] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(RUserNoteViewModel[]))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task GetAllPublicNotes([FromQuery]PagingParameterModel paging) - { + public async Task GetAllPublicNotes([FromQuery] PagingParameterModel paging) + { RServiceResult<(PaginationMetadata PagingMeta, RUserNoteViewModel[] Notes)> res = await _artifactService.GetAllPublicNotes(paging); if (!string.IsNullOrEmpty(res.ExceptionString)) return BadRequest(res.ExceptionString); @@ -1628,6 +1629,116 @@ namespace RMuseum.Controllers return Ok(res.Result.Notes); } + /// + /// report a public note + /// + /// + /// id of saved report + [HttpPost] + [Route("note/report")] + [Authorize] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(Guid))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.Forbidden)] + public async Task ReportPublicNote([FromBody] PostRUserNoteAbuseReportViewModel report) + { + if (ReadOnlyMode) + return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید."); + + Guid userId = + new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); + Guid sessionId = + new Guid(User.Claims.FirstOrDefault(c => c.Type == "SessionId").Value); + RServiceResult sessionCheckResult = await _appUserService.SessionExists(userId, sessionId); + if (!string.IsNullOrEmpty(sessionCheckResult.ExceptionString)) + { + return StatusCode((int)HttpStatusCode.Forbidden); + } + + RServiceResult res = await _artifactService.ReportPublicNote(userId, report.NoteId, report.ReasonText); + if (!string.IsNullOrEmpty(res.ExceptionString)) + { + return BadRequest(res.ExceptionString); + } + return Ok(res.Result); + } + + /// + /// Get a list of reported notes + /// + /// + /// + [HttpGet] + [Route("notes/reported")] + [Authorize(Policy = RMuseumSecurableItem.NoteEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(IEnumerable))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + public async Task GetReportedPublicNotes([FromQuery] PagingParameterModel paging) + { + var notes = await _artifactService.GetReportedPublicNotes(paging); + if (!string.IsNullOrEmpty(notes.ExceptionString)) + { + return BadRequest(notes.ExceptionString); + } + + // Paging Header + HttpContext.Response.Headers.Add("paging-headers", JsonConvert.SerializeObject(notes.Result.PagingMeta)); + + return Ok(notes.Result.Items); + } + + /// + /// delete a report for abuse in public user notes + /// + /// + /// + [HttpDelete] + [Route("note/report/{id}")] + [Authorize(Policy = RMuseumSecurableItem.NoteEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(int))] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.Forbidden)] + public async Task DeclinePublicNoteReport(Guid id) + { + if (ReadOnlyMode) + return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید."); + RServiceResult res = await _artifactService.DeclinePublicNoteReport(id); + if (!string.IsNullOrEmpty(res.ExceptionString)) + { + return BadRequest(res.ExceptionString); + } + if (!res.Result) + { + return NotFound(); + } + return Ok(); + } + + /// + /// delete a reported user note (accept the complaint) + /// + /// + /// + [HttpDelete] + [Route("note/reported/moderate/{reportid}")] + [Authorize(Policy = RMuseumSecurableItem.NoteEntityShortName + ":" + RMuseumSecurableItem.ModerateOperationShortName)] + [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] + [ProducesResponseType((int)HttpStatusCode.NotFound)] + [ProducesResponseType((int)HttpStatusCode.Forbidden)] + public async Task AcceptPublicNoteReport(Guid reportid) + { + if (ReadOnlyMode) + return BadRequest("سایت به دلایل فنی مثل انتقال سرور موقتاً در حالت فقط خواندنی قرار دارد. لطفاً ساعاتی دیگر مجدداً تلاش کنید."); + var res = + await _artifactService.AcceptPublicNoteReport(reportid); + if (!string.IsNullOrEmpty(res.ExceptionString)) + return BadRequest(res.ExceptionString); + if (!res.Result) + return NotFound(); + return Ok(); + } + + /// /// suggest ganjoor link @@ -1639,7 +1750,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(GanjoorLinkViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task SuggestGanjoorLink([FromBody]LinkSuggestion link) + public async Task SuggestGanjoorLink([FromBody] LinkSuggestion link) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult suggestion = await _artifactService.SuggestGanjoorLink(loggedOnUserId, link); @@ -1789,7 +1900,7 @@ namespace RMuseum.Controllers [Authorize] [ProducesResponseType((int)HttpStatusCode.OK, Type = typeof(PinterestLinkViewModel))] [ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))] - public async Task SuggestPinterestLink([FromBody]PinterestSuggestion suggestion) + public async Task SuggestPinterestLink([FromBody] PinterestSuggestion suggestion) { Guid loggedOnUserId = new Guid(User.Claims.FirstOrDefault(c => c.Type == "UserId").Value); RServiceResult res = await _artifactService.SuggestPinterestLink(loggedOnUserId, suggestion); @@ -1863,23 +1974,44 @@ namespace RMuseum.Controllers return BadRequest(exp.ToString()); } } + /// + /// readonly mode + /// + public bool ReadOnlyMode + { + get + { + try + { + return bool.Parse(Configuration["ReadOnlyMode"]); + } + catch + { + return false; + } + } + } /// /// constructor /// - /// - /// + /// /// /// /// - public ArtifactController(IArtifactService artifactService, IUserPermissionChecker userPermissionChecker, IMemoryCache memoryCache, ICaptchaService captchaService) + /// + /// + public ArtifactController(IArtifactService artifactService, IUserPermissionChecker userPermissionChecker, IMemoryCache memoryCache, ICaptchaService captchaService, IAppUserService appUserService, IConfiguration configuration) { _artifactService = artifactService; _userPermissionChecker = userPermissionChecker; _memoryCache = memoryCache; _captchaService = captchaService; + _appUserService = appUserService; + Configuration = configuration; + } /// @@ -1902,6 +2034,16 @@ namespace RMuseum.Controllers /// protected readonly ICaptchaService _captchaService; - + /// + /// IAppUserService instance + /// + protected IAppUserService _appUserService; + + /// + /// Configuration + /// + protected IConfiguration Configuration { get; } + + } } diff --git a/RMuseum/Models/Note/ViewModels/PostRUserNoteAbuseReportViewModel.cs b/RMuseum/Models/Note/ViewModels/PostRUserNoteAbuseReportViewModel.cs new file mode 100644 index 00000000..ef2da8c3 --- /dev/null +++ b/RMuseum/Models/Note/ViewModels/PostRUserNoteAbuseReportViewModel.cs @@ -0,0 +1,20 @@ +using System; + +namespace RMuseum.Models.Note.ViewModels +{ + /// + /// user note report view model + /// + public class PostRUserNoteAbuseReportViewModel + { + /// + /// note Id + /// + public Guid NoteId { get; set; } + + /// + /// reason text + /// + public string ReasonText { get; set; } + } +} diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index aea66a49..0f63752c 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -463,6 +463,34 @@ + + + report a public note + + + id of saved report + + + + Get a list of reported notes + + + + + + + delete a report for abuse in public user notes + + + + + + + delete a reported user note (accept the complaint) + + + + suggest ganjoor link @@ -548,15 +576,21 @@ - + + + readonly mode + + + constructor - - + + + @@ -578,6 +612,16 @@ Captcha service + + + IAppUserService instance + + + + + Configuration + + Audit Log Controller Base @@ -7880,6 +7924,21 @@ reporting user + + + user note report view model + + + + + note Id + + + + + reason text + + New User Note For Artifact