diff --git a/server/AyaNova/biz/NotifyEventProcessor.cs b/server/AyaNova/biz/NotifyEventProcessor.cs index 65c98979..de7cb44a 100644 --- a/server/AyaNova/biz/NotifyEventProcessor.cs +++ b/server/AyaNova/biz/NotifyEventProcessor.cs @@ -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 objectTags, List 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 diff --git a/server/AyaNova/models/ICoreBizObjectModel.cs b/server/AyaNova/models/ICoreBizObjectModel.cs index 5fab95da..a980c7a2 100644 --- a/server/AyaNova/models/ICoreBizObjectModel.cs +++ b/server/AyaNova/models/ICoreBizObjectModel.cs @@ -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 Tags { get; set; } - [NotMapped, JsonIgnore] - public AyaNova.Biz.AyaType AyaType { get;} + public AyaNova.Biz.AyaType AyaType { get; } } diff --git a/server/AyaNova/models/WorkOrderItemScheduledUser.cs b/server/AyaNova/models/WorkOrderItemScheduledUser.cs index e130c7d1..4964f1e9 100644 --- a/server/AyaNova/models/WorkOrderItemScheduledUser.cs +++ b/server/AyaNova/models/WorkOrderItemScheduledUser.cs @@ -23,7 +23,6 @@ namespace AyaNova.Models public WorkOrderItem WorkOrderItem { get; set; } [NotMapped, JsonIgnore] - [JsonIgnore] public AyaType AyaType { get => AyaType.WorkOrderItemScheduledUser; } }//eoc diff --git a/server/AyaNova/models/WorkOrderItemTask.cs b/server/AyaNova/models/WorkOrderItemTask.cs index 150d00cb..2754622c 100644 --- a/server/AyaNova/models/WorkOrderItemTask.cs +++ b/server/AyaNova/models/WorkOrderItemTask.cs @@ -23,7 +23,6 @@ namespace AyaNova.Models public WorkOrderItem WorkOrderItem { get; set; } [NotMapped, JsonIgnore] - [JsonIgnore] public AyaType AyaType { get => AyaType.WorkOrderItemTask; } }//eoc