Browse Source

Merge pull request #566 from colinin/fix-webhook-host-manage

fix: 宿主端应可以改变webhook订阅租户.
pull/580/head
yx lin 4 years ago
committed by GitHub
parent
commit
dc1272251e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs
  2. 5
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs
  3. 5
      aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs

5
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Validation;
@ -25,6 +26,8 @@ public abstract class WebhookSubscriptionCreateOrUpdateInput
public bool IsActive { get; set; }
public Guid? TenantId { get; set; }
public List<string> Webhooks { get; set; } = new List<string>();
public Dictionary<string, string> Headers { get; set; } = new Dictionary<string, string>();

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

@ -37,7 +37,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I
JsonConvert.SerializeObject(input.Webhooks),
JsonConvert.SerializeObject(input.Headers),
input.Secret,
CurrentTenant.Id)
input.TenantId ?? CurrentTenant.Id)
{
IsActive = input.IsActive,
};
@ -97,6 +97,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I
subscription.SetWebhookUri(input.WebhookUri);
subscription.SetWebhooks(input.ToSubscribedWebhooksString());
subscription.SetHeaders(input.ToWebhookHeadersString());
subscription.SetTenantId(input.TenantId);
subscription.IsActive = input.IsActive;
await SubscriptionRepository.UpdateAsync(subscription);
@ -142,7 +143,7 @@ public class WebhookSubscriptionAppService : WebhooksManagementAppServiceBase, I
{
foreach (var webhookName in input.Webhooks)
{
if (await SubscriptionRepository.IsSubscribedAsync(CurrentTenant.Id, input.WebhookUri, webhookName))
if (await SubscriptionRepository.IsSubscribedAsync(input.TenantId ?? CurrentTenant.Id, input.WebhookUri, webhookName))
{
throw new BusinessException(WebhooksManagementErrorCodes.WebhookSubscription.DuplicateSubscribed)
.WithData(nameof(WebhookSubscription.WebhookUri), input.WebhookUri)

5
aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs

@ -32,6 +32,11 @@ public class WebhookSubscription : CreationAuditedEntity<Guid>
IsActive = true;
}
public void SetTenantId(Guid? tenantId = null)
{
TenantId = tenantId;
}
public void SetSecret(string secret)
{
Secret = Check.Length(secret, nameof(secret), WebhookSubscriptionConsts.MaxSecretLength);

Loading…
Cancel
Save