Browse Source

fix(webhooks): fix some errors

pull/896/head
colin 2 years ago
parent
commit
9ec5bcdf9e
  1. 4
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs
  2. 2
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs
  3. 7
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs
  4. 3
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs
  5. 12
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs

4
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs

@ -35,7 +35,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I
var subscription = new WebhookSubscription(
GuidGenerator.Create(),
input.WebhookUri,
input.ToWebhookHeadersString(),
input.ToSubscribedWebhooksString(),
input.ToWebhookHeadersString(),
input.Secret,
input.TenantId ?? CurrentTenant.Id)
@ -100,7 +100,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I
var inputHeaders = input.ToWebhookHeadersString();
if (!string.Equals(subscription.Headers, inputHeaders, StringComparison.InvariantCultureIgnoreCase))
{
subscription.SetHeaders(input.ToWebhookHeadersString());
subscription.SetHeaders(inputHeaders);
}
subscription.SetConcurrencyStampIfNotNull(input.ConcurrencyStamp);

2
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStore.cs

@ -127,7 +127,7 @@ public class DynamicWebhookDefinitionStore : IDynamicWebhookDefinitionStore, ITr
protected async virtual Task UpdateInMemoryStoreCache()
{
var webhookGroupRecords = await WebhookGroupRepository.GetListAsync();
var webhookRecords = await WebhookRepository.GetListAsync();
var webhookRecords = await WebhookRepository.GetAvailableListAsync();
await StoreCache.FillAsync(webhookGroupRecords, webhookRecords);
}

7
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/DynamicWebhookDefinitionStoreInMemoryCache.cs

@ -98,10 +98,15 @@ public class DynamicWebhookDefinitionStoreInMemoryCache :
WebhookGroupDefinition webhookGroup,
WebhookDefinitionRecord webhookRecord)
{
ILocalizableString description = null;
if (!webhookRecord.Description.IsNullOrWhiteSpace())
{
description = LocalizableStringSerializer.Deserialize(webhookRecord.Description);
}
var webhook = webhookGroup.AddWebhook(
webhookRecord.Name,
LocalizableStringSerializer.Deserialize(webhookRecord.DisplayName),
LocalizableStringSerializer.Deserialize(webhookRecord.Description)
description
);
WebhookDefinitions[webhook.Name] = webhook;

3
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/IWebhookDefinitionRecordRepository.cs

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
@ -10,4 +11,6 @@ public interface IWebhookDefinitionRecordRepository : IBasicRepository<WebhookDe
Task<WebhookDefinitionRecord> FindByNameAsync(
string name,
CancellationToken cancellationToken = default);
Task<List<WebhookDefinitionRecord>> GetAvailableListAsync(CancellationToken cancellationToken = default);
}

12
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore/LINGYUN/Abp/WebhooksManagement/EntityFrameworkCore/EfCoreWebhookDefinitionRecordRepository.cs

@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@ -18,12 +19,19 @@ public class EfCoreWebhookDefinitionRecordRepository :
{
}
public async Task<WebhookDefinitionRecord> FindByNameAsync(
public async virtual Task<WebhookDefinitionRecord> FindByNameAsync(
string name,
CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.OrderBy(x => x.Id)
.FirstOrDefaultAsync(r => r.Name == name, cancellationToken);
.FirstOrDefaultAsync(r => r.Name == name, GetCancellationToken(cancellationToken));
}
public async virtual Task<List<WebhookDefinitionRecord>> GetAvailableListAsync(CancellationToken cancellationToken = default)
{
return await (await GetDbSetAsync())
.Where(x => x.IsEnabled == true)
.ToListAsync(GetCancellationToken(cancellationToken));
}
}

Loading…
Cancel
Save