Fileattachment search workaround

This commit is contained in:
2020-05-21 22:54:57 +00:00
parent aefe722b10
commit 39b3b007a3

View File

@@ -173,9 +173,24 @@ namespace AyaNova.Biz
List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>(); List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>();
foreach (AyaTypeId t in MatchingObjects) 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 TranslationId { get; set; }
public long ObjectId { get; set; } public long ObjectId { get; set; }
public AyaType ObjectType { get; set; } public AyaType ObjectType { get; set; }
// public string Name { get; set; }
public List<string> Words { get; set; } public List<string> Words { get; set; }
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType) public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType)
{ {
Words = new List<string>(); Words = new List<string>();
TranslationId = translationId; TranslationId = translationId;
ObjectId = objectID; ObjectId = objectID;
ObjectType = objectType; ObjectType = objectType;
} }
//format used for getsummmary by biz objects //format used for getsummmary by biz objects
@@ -656,10 +666,10 @@ namespace AyaNova.Biz
/// </summary> /// </summary>
private static async Task ProcessKeywordsAsync(SearchIndexProcessObjectParameters p, bool newRecord) private static async Task ProcessKeywordsAsync(SearchIndexProcessObjectParameters p, bool newRecord)
{ {
// #if (DEBUG) // #if (DEBUG)
// if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute))) // if (!p.ObjectType.HasAttribute(typeof(CoreBizObjectAttribute)))
// throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}"); // throw new System.NotSupportedException($"Search::ProcessKeywords - Invalid type presented {p.ObjectType}");
// #endif // #endif
List<string> KeyWordList = await BreakAsync(p.TranslationId, p.Words); List<string> KeyWordList = await BreakAsync(p.TranslationId, p.Words);
if (KeyWordList.Count == 0) return; if (KeyWordList.Count == 0) return;