From 7cd5079e8372dd8ee83dc3f9e1a2a8bbf74d9b7d Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Tue, 12 Apr 2022 16:26:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=BF=E4=B8=BB=E7=AB=AF=E5=BA=94?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=94=B9=E5=8F=98webhook=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E7=A7=9F=E6=88=B7.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WebhookSubscriptionCreateOrUpdateInput.cs | 5 ++++- .../Abp/WebhooksManagement/WebhookSubscriptionAppService.cs | 5 +++-- .../LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs index b3ed79311..a7ed050e3 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application.Contracts/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionCreateOrUpdateInput.cs +++ b/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 Webhooks { get; set; } = new List(); public Dictionary Headers { get; set; } = new Dictionary(); diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs index 0b13dc62e..71bb55b99 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Application/LINGYUN/Abp/WebhooksManagement/WebhookSubscriptionAppService.cs +++ b/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) diff --git a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs index d74b9da93..1a11af2fb 100644 --- a/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs +++ b/aspnet-core/modules/webhooks/LINGYUN.Abp.WebhooksManagement.Domain/LINGYUN/Abp/WebhooksManagement/WebhookSubscription.cs @@ -32,6 +32,11 @@ public class WebhookSubscription : CreationAuditedEntity IsActive = true; } + public void SetTenantId(Guid? tenantId = null) + { + TenantId = tenantId; + } + public void SetSecret(string secret) { Secret = Check.Length(secret, nameof(secret), WebhookSubscriptionConsts.MaxSecretLength);