Skip to content

Commit 13fb582

Browse files
committed
Add missing handler
1 parent ea00697 commit 13fb582

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using Umbraco.Cms.Core.Cache;
2+
using Umbraco.Cms.Core.Events;
3+
using Umbraco.Cms.Core.Notifications;
4+
using Umbraco.Cms.Core.Sync;
5+
using Umbraco.Extensions;
6+
7+
namespace Umbraco.Cms.Integrations.Search.Algolia.Handlers
8+
{
9+
public class AlgoliaContentPublishedHandler : INotificationAsyncHandler<ContentPublishedNotification>
10+
{
11+
private readonly IServerRoleAccessor _serverRoleAccessor;
12+
private readonly DistributedCache _distributedCache;
13+
14+
public AlgoliaContentPublishedHandler(
15+
IServerRoleAccessor serverRoleAccessor,
16+
DistributedCache distributedCache)
17+
{
18+
_serverRoleAccessor = serverRoleAccessor;
19+
_distributedCache = distributedCache;
20+
}
21+
22+
public Task HandleAsync(ContentPublishedNotification notification, CancellationToken cancellationToken)
23+
{
24+
if (_serverRoleAccessor.CurrentServerRole == ServerRole.SchedulingPublisher)
25+
{
26+
_distributedCache.RefreshAllContentCache();
27+
}
28+
return Task.CompletedTask;
29+
}
30+
}
31+
}

0 commit comments

Comments
 (0)