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);