diff --git a/server/AyaNova/biz/Search.cs b/server/AyaNova/biz/Search.cs index 43f3a328..5a64ee32 100644 --- a/server/AyaNova/biz/Search.cs +++ b/server/AyaNova/biz/Search.cs @@ -173,9 +173,24 @@ namespace AyaNova.Biz List CanReadMatchingObjects = new List(); foreach (AyaTypeId t in MatchingObjects) { - if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.ObjectType)) + if (t.ObjectType == AyaType.FileAttachment) { - CanReadMatchingObjects.Add(t); + //have to look up the actual underlying object type and id here + //check if it's readable for user + //then add the PARENT object type and id to the CanREadMatchingObjects list + //this means user will not see it return as an attachment, just as the object + FileAttachment f = await ct.FileAttachment.AsNoTracking().FirstOrDefaultAsync(z => z.Id == t.ObjectId); + if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, f.AttachToObjectType)) + { + CanReadMatchingObjects.Add(new AyaTypeId(f.AttachToObjectType, f.AttachToObjectId)); + } + } + else + { + if (AyaNova.Api.ControllerHelpers.Authorized.HasReadFullRole(currentUserRoles, t.ObjectType)) + { + CanReadMatchingObjects.Add(t); + } } } @@ -562,20 +577,15 @@ namespace AyaNova.Biz public long TranslationId { get; set; } public long ObjectId { get; set; } public AyaType ObjectType { get; set; } - // public string Name { get; set; } public List Words { get; set; } - public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType) { Words = new List(); - TranslationId = translationId; ObjectId = objectID; ObjectType = objectType; - - } //format used for getsummmary by biz objects @@ -656,10 +666,10 @@ namespace AyaNova.Biz /// private static async Task ProcessKeywordsAsync(SearchIndexProcessObjectParameters p, bool newRecord) { -// #if (DEBUG) -// if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute))) -// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}"); -// #endif + // #if (DEBUG) + // if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute))) + // throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}"); + // #endif List KeyWordList = await BreakAsync(p.TranslationId, p.Words); if (KeyWordList.Count == 0) return;