Fileattachment search workaround
This commit is contained in:
@@ -173,9 +173,24 @@ namespace AyaNova.Biz
|
||||
List<AyaTypeId> CanReadMatchingObjects = new List<AyaTypeId>();
|
||||
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<string> Words { get; set; }
|
||||
|
||||
|
||||
|
||||
public SearchIndexProcessObjectParameters(long translationId, long objectID, AyaType objectType)
|
||||
{
|
||||
Words = new List<string>();
|
||||
|
||||
TranslationId = translationId;
|
||||
ObjectId = objectID;
|
||||
ObjectType = objectType;
|
||||
|
||||
|
||||
}
|
||||
|
||||
//format used for getsummmary by biz objects
|
||||
@@ -656,10 +666,10 @@ namespace AyaNova.Biz
|
||||
/// </summary>
|
||||
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<string> KeyWordList = await BreakAsync(p.TranslationId, p.Words);
|
||||
|
||||
if (KeyWordList.Count == 0) return;
|
||||
|
||||
Reference in New Issue
Block a user