This commit is contained in:
2020-07-17 13:53:45 +00:00
parent 0658632459
commit a8a50b15c0
4 changed files with 25 additions and 6 deletions

View File

@@ -110,7 +110,7 @@ namespace AyaNova.Biz
//then *this* code will go through and look for subscriptions related to that event
//this way the biz object code can be "dumb" about notifications in general and just let this code handle it as needed
//will iterate the subscriptions and see if any apply here
internal static async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel newObject, ICoreBizObjectModel currentObject)
internal static async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel newObject, ICoreBizObjectModel dbObject)
{
@@ -141,7 +141,13 @@ namespace AyaNova.Biz
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ObjectCreated && z.AyaType == newObject.AyaType).ToListAsync();
foreach (var sub in subs)
{
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectCreated, UserId = sub.UserId, AyaType=newObject.AyaType,ObjectId=newObject.Id, SubscriptionId = sub.Id };
//todo: match tags if necessary
if (sub.Tags.Count > 0)
{
if (!sub.Tags.All(z => newObject.Tags.Any(x => x == z)))
continue;
}
NotifyEvent n = new NotifyEvent() { EventType = NotifyEventType.ObjectCreated, UserId = sub.UserId, AyaType = newObject.AyaType, ObjectId = newObject.Id, SubscriptionId = sub.Id };
await ct.NotifyEvent.AddAsync(n);
}
if (subs.Count > 0)
@@ -267,6 +273,22 @@ namespace AyaNova.Biz
}
}//eom
private static bool TagsMatch(List<string> objectTags, List<string> subTags){
//no subscription tags? Then it always will match
if(subTags.Count==0) return true;
//have sub tags but object has none? Then it's never going to match
if(objectTags.Count==0) return false;
//not enought tags on object to match sub tags?
if(subTags.Count > objectTags.Count) return false;
//ok, here it's worth checking it out
if (!sub.Tags.All(z => newObject.Tags.Any(x => x == z)))
continue;
}
}//eoc

View File

@@ -18,8 +18,7 @@ namespace AyaNova.Models
public string Wiki { get => throw new System.NotImplementedException(); set => throw new System.NotImplementedException(); }
public string CustomFields { get; set; }
public List<string> Tags { get; set; }
[NotMapped, JsonIgnore]
public AyaNova.Biz.AyaType AyaType { get;}
public AyaNova.Biz.AyaType AyaType { get; }
}

View File

@@ -23,7 +23,6 @@ namespace AyaNova.Models
public WorkOrderItem WorkOrderItem { get; set; }
[NotMapped, JsonIgnore]
[JsonIgnore]
public AyaType AyaType { get => AyaType.WorkOrderItemScheduledUser; }
}//eoc

View File

@@ -23,7 +23,6 @@ namespace AyaNova.Models
public WorkOrderItem WorkOrderItem { get; set; }
[NotMapped, JsonIgnore]
[JsonIgnore]
public AyaType AyaType { get => AyaType.WorkOrderItemTask; }
}//eoc