18 changed files with 441 additions and 1 deletions
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,30 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<None Remove="LINGYUN\Abp\Webhooks\Identity\Localization\Resources\*.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<EmbeddedResource Include="LINGYUN\Abp\Webhooks\Identity\Localization\Resources\*.json" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.EventBus" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Users.Abstractions" Version="$(VoloAbpPackageVersion)" /> |
|||
<PackageReference Include="Volo.Abp.Identity.Domain.Shared" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\LINGYUN.Abp.Webhooks\LINGYUN.Abp.Webhooks.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,32 @@ |
|||
using Volo.Abp.Domain; |
|||
using Volo.Abp.EventBus; |
|||
using Volo.Abp.Identity; |
|||
using Volo.Abp.Identity.Localization; |
|||
using Volo.Abp.Localization; |
|||
using Volo.Abp.Modularity; |
|||
using Volo.Abp.Users; |
|||
using Volo.Abp.VirtualFileSystem; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
[DependsOn(typeof(AbpDddDomainModule))] |
|||
[DependsOn(typeof(AbpEventBusModule))] |
|||
[DependsOn(typeof(AbpUsersAbstractionModule))] |
|||
[DependsOn(typeof(AbpIdentityDomainSharedModule))] |
|||
public class AbpWebhooksIdentityModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
Configure<AbpVirtualFileSystemOptions>(options => |
|||
{ |
|||
options.FileSets.AddEmbedded<AbpWebhooksIdentityModule>(); |
|||
}); |
|||
|
|||
Configure<AbpLocalizationOptions>(options => |
|||
{ |
|||
options.Resources |
|||
.Get<IdentityResource>() |
|||
.AddVirtualJson("/LINGYUN/Abp/Webhooks/Identity/Localization/Resources"); |
|||
}); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityRoleNameChangedWto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string OldName { get; set; } |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityRoleWebHooker : |
|||
IDistributedEventHandler<EntityCreatedEto<IdentityRoleEto>>, |
|||
IDistributedEventHandler<EntityUpdatedEto<IdentityRoleEto>>, |
|||
IDistributedEventHandler<IdentityRoleNameChangedEto>, |
|||
ITransientDependency |
|||
{ |
|||
private readonly IWebhookPublisher _webhookPublisher; |
|||
|
|||
public IdentityRoleWebHooker( |
|||
IWebhookPublisher webhookPublisher) |
|||
{ |
|||
_webhookPublisher = webhookPublisher; |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityCreatedEto<IdentityRoleEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Create, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityUpdatedEto<IdentityRoleEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Update, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityDeletedEto<IdentityRoleEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Delete, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(IdentityRoleNameChangedEto eventData) |
|||
{ |
|||
await _webhookPublisher.PublishAsync( |
|||
IdentityWebhookNames.IdentityRole.ChangeName, |
|||
new IdentityRoleNameChangedWto |
|||
{ |
|||
Id = eventData.Id, |
|||
Name = eventData.Name, |
|||
OldName = eventData.OldName, |
|||
}, |
|||
eventData.TenantId); |
|||
} |
|||
|
|||
protected async virtual Task PublishAsync(string webhookName, IdentityRoleEto eto) |
|||
{ |
|||
await _webhookPublisher.PublishAsync( |
|||
webhookName, |
|||
new IdentityRoleWto |
|||
{ |
|||
Id = eto.Id, |
|||
Name = eto.Name |
|||
}, |
|||
eto.TenantId); |
|||
} |
|||
} |
|||
@ -0,0 +1,10 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityRoleWto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Users; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityUserWebHooker : |
|||
IDistributedEventHandler<EntityCreatedEto<UserEto>>, |
|||
IDistributedEventHandler<EntityUpdatedEto<UserEto>>, |
|||
IDistributedEventHandler<EntityDeletedEto<UserEto>>, |
|||
ITransientDependency |
|||
{ |
|||
private readonly IWebhookPublisher _webhookPublisher; |
|||
|
|||
public IdentityUserWebHooker( |
|||
IWebhookPublisher webhookPublisher) |
|||
{ |
|||
_webhookPublisher = webhookPublisher; |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityCreatedEto<UserEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityUser.Create, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityUpdatedEto<UserEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityUser.Update, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityDeletedEto<UserEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityUser.Delete, eventData.Entity); |
|||
} |
|||
|
|||
protected async virtual Task PublishAsync(string webhookName, UserEto eto) |
|||
{ |
|||
await _webhookPublisher.PublishAsync( |
|||
webhookName, |
|||
new IdentityUserWto |
|||
{ |
|||
Id = eto.Id, |
|||
Name = eto.Name, |
|||
Email = eto.Email, |
|||
EmailConfirmed = eto.EmailConfirmed, |
|||
UserName = eto.UserName, |
|||
PhoneNumber = eto.PhoneNumber, |
|||
PhoneNumberConfirmed = eto.PhoneNumberConfirmed, |
|||
Surname = eto.Surname, |
|||
}, |
|||
eto.TenantId); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityUserWto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string UserName { get; set; } |
|||
|
|||
public string Name { get; set; } |
|||
|
|||
public string Surname { get; set; } |
|||
|
|||
public string Email { get; set; } |
|||
|
|||
public bool EmailConfirmed { get; set; } |
|||
|
|||
public string PhoneNumber { get; set; } |
|||
|
|||
public bool PhoneNumberConfirmed { get; set; } |
|||
} |
|||
@ -0,0 +1,60 @@ |
|||
using Volo.Abp.Identity.Localization; |
|||
using Volo.Abp.Localization; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class IdentityWebhookDefinitionProvider : WebhookDefinitionProvider |
|||
{ |
|||
public override void Define(IWebhookDefinitionContext context) |
|||
{ |
|||
context.Add(CreateIdentityRoleWebhooks()); |
|||
context.Add(CreateIdentityUserWebhooks()); |
|||
} |
|||
|
|||
protected virtual WebhookDefinition[] CreateIdentityRoleWebhooks() |
|||
{ |
|||
return new[] |
|||
{ |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityRole.Create, |
|||
L("Webhooks:CreateRole"), |
|||
L("Webhooks:CreateRoleDesc")), |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityRole.Update, |
|||
L("Webhooks:UpdateRole"), |
|||
L("Webhooks:UpdateRoleDesc")), |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityRole.Delete, |
|||
L("Webhooks:DeleteRole"), |
|||
L("Webhooks:DeleteRoleDesc")), |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityRole.ChangeName, |
|||
L("Webhooks:ChangeRoleName"), |
|||
L("Webhooks:ChangeRoleNameDesc")), |
|||
}; |
|||
} |
|||
|
|||
protected virtual WebhookDefinition[] CreateIdentityUserWebhooks() |
|||
{ |
|||
return new[] |
|||
{ |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityUser.Create, |
|||
L("Webhooks:CreateUser"), |
|||
L("Webhooks:CreateUserDesc")), |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityUser.Update, |
|||
L("Webhooks:UpdateUser"), |
|||
L("Webhooks:UpdateUserDesc")), |
|||
new WebhookDefinition( |
|||
IdentityWebhookNames.IdentityUser.Delete, |
|||
L("Webhooks:DeleteUser"), |
|||
L("Webhooks:DeleteUserDesc")), |
|||
}; |
|||
} |
|||
|
|||
private static ILocalizableString L(string name) |
|||
{ |
|||
return LocalizableString.Create<IdentityResource>(name); |
|||
} |
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public static class IdentityWebhookNames |
|||
{ |
|||
public const string GroupName = "abp.identity"; |
|||
public static class IdentityRole |
|||
{ |
|||
public const string Prefix = GroupName + ".roles"; |
|||
public const string Create = Prefix + ".create"; |
|||
public const string Update = Prefix + ".update"; |
|||
public const string Delete = Prefix + ".delete"; |
|||
public const string ChangeName = Prefix + ".change_name"; |
|||
} |
|||
|
|||
public static class IdentityUser |
|||
{ |
|||
public const string Prefix = GroupName + ".users"; |
|||
public const string Create = Prefix + ".create"; |
|||
public const string Update = Prefix + ".update"; |
|||
public const string Delete = Prefix + ".delete"; |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
{ |
|||
"culture": "en", |
|||
"texts": { |
|||
"Webhooks:CreateRole": "Create Role", |
|||
"Webhooks:CreateRoleDesc": "A new role has been created", |
|||
"Webhooks:UpdateRole": "Update Role", |
|||
"Webhooks:UpdateRoleDesc": "A role has changed", |
|||
"Webhooks:DeleteRole": "Delete Role", |
|||
"Webhooks:DeleteRoleDesc": "Deleted Role", |
|||
"Webhooks:ChangeRoleName": "Change Role Name", |
|||
"Webhooks:ChangeRoleNameDesc": "The name of a role was changed", |
|||
"Webhooks:CreateUser": "Create User", |
|||
"Webhooks:CreateUserDesc": "A new user has been created", |
|||
"Webhooks:UpdateUser": "Update User", |
|||
"Webhooks:UpdateUserDesc": "A user has been changed", |
|||
"Webhooks:DeleteUser": "Delete User", |
|||
"Webhooks:DeleteUserDesc": "Deleted User" |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
{ |
|||
"culture": "zh-Hans", |
|||
"texts": { |
|||
"Webhooks:CreateRole": "创建角色", |
|||
"Webhooks:CreateRoleDesc": "一个新角色已创建", |
|||
"Webhooks:UpdateRole": "编辑角色", |
|||
"Webhooks:UpdateRoleDesc": "一个角色属性已变更", |
|||
"Webhooks:DeleteRole": "删除角色", |
|||
"Webhooks:DeleteRoleDesc": "已删除角色", |
|||
"Webhooks:ChangeRoleName": "改变角色名称", |
|||
"Webhooks:ChangeRoleNameDesc": "一个角色的名称被更改", |
|||
"Webhooks:CreateUser": "创建用户", |
|||
"Webhooks:CreateUserDesc": "一个新用户已创建", |
|||
"Webhooks:UpdateUser": "编辑用户", |
|||
"Webhooks:UpdateUserDesc": "一个用户属性已变更", |
|||
"Webhooks:DeleteUser": "删除用户", |
|||
"Webhooks:DeleteUserDesc": "已删除用户" |
|||
} |
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|||
using Volo.Abp.EventBus.Distributed; |
|||
using Volo.Abp.Identity; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class OrganizationUnitWebHooker : |
|||
IDistributedEventHandler<EntityCreatedEto<OrganizationUnitEto>>, |
|||
IDistributedEventHandler<EntityUpdatedEto<OrganizationUnitEto>>, |
|||
IDistributedEventHandler<EntityDeletedEto<OrganizationUnitEto>>, |
|||
ITransientDependency |
|||
{ |
|||
private readonly IWebhookPublisher _webhookPublisher; |
|||
|
|||
public OrganizationUnitWebHooker( |
|||
IWebhookPublisher webhookPublisher) |
|||
{ |
|||
_webhookPublisher = webhookPublisher; |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityCreatedEto<OrganizationUnitEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Create, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityUpdatedEto<OrganizationUnitEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Update, eventData.Entity); |
|||
} |
|||
|
|||
public async virtual Task HandleEventAsync(EntityDeletedEto<OrganizationUnitEto> eventData) |
|||
{ |
|||
await PublishAsync(IdentityWebhookNames.IdentityRole.Delete, eventData.Entity); |
|||
} |
|||
|
|||
protected async virtual Task PublishAsync(string webhookName, OrganizationUnitEto eto) |
|||
{ |
|||
await _webhookPublisher.PublishAsync( |
|||
webhookName, |
|||
new OrganizationUnitWto |
|||
{ |
|||
Id = eto.Id, |
|||
DisplayName = eto.DisplayName |
|||
}, |
|||
eto.TenantId); |
|||
} |
|||
} |
|||
@ -0,0 +1,12 @@ |
|||
using System; |
|||
|
|||
namespace LINGYUN.Abp.Webhooks.Identity; |
|||
|
|||
public class OrganizationUnitWto |
|||
{ |
|||
public Guid Id { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
|
|||
public string DisplayName { get; set; } |
|||
} |
|||
Loading…
Reference in new issue