Subscription: fix
This commit is contained in:
parent
bef7c923db
commit
e7dfa142d6
@ -35,7 +35,7 @@ using ASC.Core.Data;
|
||||
namespace ASC.Core.Caching
|
||||
{
|
||||
[Singletone]
|
||||
class SubscriptionServiceCache
|
||||
public class SubscriptionServiceCache
|
||||
{
|
||||
internal ICache Cache { get; }
|
||||
internal ICacheNotify<SubscriptionRecord> NotifyRecord { get; }
|
||||
@ -103,7 +103,7 @@ namespace ASC.Core.Caching
|
||||
}
|
||||
|
||||
[Scope]
|
||||
class CachedSubscriptionService : ISubscriptionService
|
||||
public class CachedSubscriptionService : ISubscriptionService
|
||||
{
|
||||
private readonly ISubscriptionService service;
|
||||
private readonly ICache cache;
|
||||
@ -243,7 +243,7 @@ namespace ASC.Core.Caching
|
||||
public SubscriptionRecord GetSubscription(string recipientId, string objectId)
|
||||
{
|
||||
return recordsByRec.ContainsKey(recipientId) ?
|
||||
recordsByRec[recipientId].Where(s => s.ObjectId == objectId).FirstOrDefault() :
|
||||
recordsByRec[recipientId].Where(s => s.ObjectId == (objectId ?? "")).FirstOrDefault() :
|
||||
null;
|
||||
}
|
||||
|
||||
@ -269,7 +269,7 @@ namespace ASC.Core.Caching
|
||||
|
||||
public void RemoveSubscriptions(string objectId)
|
||||
{
|
||||
records.RemoveAll(s => s.ObjectId == objectId);
|
||||
records.RemoveAll(s => s.ObjectId == (objectId ?? ""));
|
||||
BuildSubscriptionsIndex(records);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,7 @@ using System.Linq;
|
||||
using ASC.Common;
|
||||
using ASC.Common.Caching;
|
||||
using ASC.Common.Security.Authorizing;
|
||||
using ASC.Core.Caching;
|
||||
|
||||
namespace ASC.Core
|
||||
{
|
||||
@ -56,7 +57,7 @@ namespace ASC.Core
|
||||
};
|
||||
}
|
||||
|
||||
public SubscriptionManager(ISubscriptionService service, TenantManager tenantManager, ICache cache)
|
||||
public SubscriptionManager(CachedSubscriptionService service, TenantManager tenantManager, ICache cache)
|
||||
{
|
||||
this.service = service ?? throw new ArgumentNullException("subscriptionManager");
|
||||
TenantManager = tenantManager;
|
||||
@ -69,12 +70,29 @@ namespace ASC.Core
|
||||
var s = new SubscriptionRecord
|
||||
{
|
||||
Tenant = GetTenant(),
|
||||
SourceId = sourceID,
|
||||
ActionId = actionID,
|
||||
RecipientId = recipientID,
|
||||
ObjectId = objectID,
|
||||
Subscribed = true,
|
||||
};
|
||||
};
|
||||
|
||||
if (sourceID != null)
|
||||
{
|
||||
s.SourceId = sourceID;
|
||||
}
|
||||
|
||||
if (actionID != null)
|
||||
{
|
||||
s.ActionId = actionID;
|
||||
}
|
||||
|
||||
if (recipientID != null)
|
||||
{
|
||||
s.RecipientId = recipientID;
|
||||
}
|
||||
|
||||
if (objectID != null)
|
||||
{
|
||||
s.ObjectId = objectID;
|
||||
}
|
||||
|
||||
service.SaveSubscription(s);
|
||||
}
|
||||
|
||||
@ -83,12 +101,29 @@ namespace ASC.Core
|
||||
var s = new SubscriptionRecord
|
||||
{
|
||||
Tenant = GetTenant(),
|
||||
SourceId = sourceID,
|
||||
ActionId = actionID,
|
||||
RecipientId = recipientID,
|
||||
ObjectId = objectID,
|
||||
Subscribed = false,
|
||||
};
|
||||
};
|
||||
|
||||
if (sourceID != null)
|
||||
{
|
||||
s.SourceId = sourceID;
|
||||
}
|
||||
|
||||
if (actionID != null)
|
||||
{
|
||||
s.ActionId = actionID;
|
||||
}
|
||||
|
||||
if (recipientID != null)
|
||||
{
|
||||
s.RecipientId = recipientID;
|
||||
}
|
||||
|
||||
if (objectID != null)
|
||||
{
|
||||
s.ObjectId = objectID;
|
||||
}
|
||||
|
||||
service.SaveSubscription(s);
|
||||
}
|
||||
|
||||
@ -150,12 +185,30 @@ namespace ASC.Core
|
||||
{
|
||||
var m = new SubscriptionMethod
|
||||
{
|
||||
Tenant = GetTenant(),
|
||||
SourceId = sourceID,
|
||||
ActionId = actionID,
|
||||
RecipientId = recipientID,
|
||||
Methods = senderNames,
|
||||
};
|
||||
Tenant = GetTenant()
|
||||
};
|
||||
|
||||
if (sourceID != null)
|
||||
{
|
||||
m.SourceId = sourceID;
|
||||
}
|
||||
|
||||
if (actionID != null)
|
||||
{
|
||||
m.ActionId = actionID;
|
||||
}
|
||||
|
||||
if (recipientID != null)
|
||||
{
|
||||
m.RecipientId = recipientID;
|
||||
}
|
||||
|
||||
if (senderNames != null)
|
||||
{
|
||||
m.Methods = senderNames;
|
||||
}
|
||||
|
||||
|
||||
service.SetSubscriptionMethod(m);
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ using ASC.Core.Tenants;
|
||||
namespace ASC.Core.Data
|
||||
{
|
||||
[Scope]
|
||||
class DbSubscriptionService : ISubscriptionService
|
||||
public class DbSubscriptionService : ISubscriptionService
|
||||
{
|
||||
private Expression<Func<Subscription, SubscriptionRecord>> FromSubscriptionToSubscriptionRecord { get; set; }
|
||||
private Expression<Func<DbSubscriptionMethod, SubscriptionMethod>> FromDbSubscriptionMethodToSubscriptionMethod { get; set; }
|
||||
|
Loading…
Reference in New Issue
Block a user