feat(webhooks): SUCCESSFUL_IMPORT event, better behaviour when creating entities

This commit is contained in:
spiral
2021-11-25 15:33:02 -05:00
parent a05c3cfeed
commit bc7e0df872
11 changed files with 73 additions and 27 deletions

View File

@@ -69,6 +69,14 @@ namespace PluralKit.API
var newGroup = await _repo.CreateGroup(system.Id, patch.Name.Value, conn);
newGroup = await _repo.UpdateGroup(newGroup.Id, patch, conn);
_ = _dispatch.Dispatch(newGroup.Id, new UpdateDispatchData()
{
Event = DispatchEvent.CREATE_GROUP,
EventData = patch.ToJson(),
});
await tx.CommitAsync();
return Ok(newGroup.ToJson(LookupContext.ByOwner));

View File

@@ -55,6 +55,12 @@ namespace PluralKit.API
var newMember = await _repo.CreateMember(system.Id, patch.Name.Value, conn);
newMember = await _repo.UpdateMember(newMember.Id, patch, conn);
_ = _dispatch.Dispatch(newMember.Id, new()
{
Event = DispatchEvent.CREATE_MEMBER,
EventData = patch.ToJson(),
});
await tx.CommitAsync();
return Ok(newMember.ToJson(LookupContext.ByOwner, v: APIVersion.V2));