Skip to content

Commit

Permalink
Merge branch 'main' into chore/improve-slack-table-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
elsand authored Oct 7, 2024
2 parents 7685989 + c7bfb07 commit ae9b384
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 6 deletions.
18 changes: 16 additions & 2 deletions docs/schema/V1/swagger.verified.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
"type": "string"
},
"process": {
"description": "Optional process identifier used to indicate a business process this dialog belongs to ",
"description": "Optional process identifier used to indicate a business process this dialog belongs to",
"nullable": true,
"type": "string"
},
Expand Down Expand Up @@ -262,7 +262,7 @@
]
},
"systemLabel": {
"description": "Set the system label of the dialog Migration purposes ",
"description": "Set the system label of the dialog Migration purposes",
"nullable": true,
"oneOf": [
{
Expand Down Expand Up @@ -751,6 +751,13 @@
},
"type": "array"
},
"id": {
"description": "A self-defined UUIDv7 may be provided to support idempotent creation of transmission attachments. If not provided, a new UUIDv7 will be generated.",
"example": "01913cd5-784f-7d3b-abef-4c77b1f0972d",
"format": "guid",
"nullable": true,
"type": "string"
},
"urls": {
"description": "The URLs associated with the attachment, each referring to a different representation of the attachment.",
"items": {
Expand Down Expand Up @@ -4089,6 +4096,13 @@
},
"type": "array"
},
"id": {
"description": "A self-defined UUIDv7 may be provided to support idempotent creation of transmission attachments. If not provided, a new UUIDv7 will be generated.",
"example": "01913cd5-784f-7d3b-abef-4c77b1f0972d",
"format": "guid",
"nullable": true,
"type": "string"
},
"urls": {
"description": "The URLs associated with the attachment, each referring to a different representation of the attachment.",
"items": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,11 @@ private async Task EnsureNoExistingUserDefinedIds(DialogEntity dialog, Cancellat
{
_domainContext.AddError(DomainFailure.EntityExists<DialogTransmission>(existingTransmissionIds));
}

var existingTransmissionAttachmentIds = await _db.GetExistingIds(dialog.Transmissions.SelectMany(t => t.Attachments), cancellationToken);
if (existingTransmissionAttachmentIds.Count != 0)
{
_domainContext.AddError(DomainFailure.EntityExists<DialogTransmissionAttachment>(existingTransmissionAttachmentIds));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ public CreateDialogTransmissionAttachmentDtoValidator(
IValidator<IEnumerable<LocalizationDto>> localizationsValidator,
IValidator<CreateDialogTransmissionAttachmentUrlDto> urlValidator)
{
RuleFor(x => x.Id)
.IsValidUuidV7()
.UuidV7TimestampIsInPast();

RuleFor(x => x.DisplayName)
.SetValidator(localizationsValidator);
RuleFor(x => x.Urls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class CreateDialogDto
public DateTimeOffset? DueAt { get; set; }

/// <summary>
/// Optional process identifier used to indicate a business process this dialog belongs to
/// Optional process identifier used to indicate a business process this dialog belongs to
/// </summary>
public string? Process { get; set; }
/// <summary>
Expand Down Expand Up @@ -104,7 +104,7 @@ public class CreateDialogDto
public DialogStatus.Values Status { get; set; }

/// <summary>
/// Set the system label of the dialog Migration purposes
/// Set the system label of the dialog Migration purposes
/// </summary>
public SystemLabel.Values? SystemLabel { get; set; }
/// <summary>
Expand Down Expand Up @@ -527,6 +527,12 @@ public sealed class CreateDialogDialogAttachmentUrlDto

public sealed class CreateDialogTransmissionAttachmentDto
{
/// <summary>
/// A self-defined UUIDv7 may be provided to support idempotent creation of transmission attachments. If not provided, a new UUIDv7 will be generated.
/// </summary>
/// <example>01913cd5-784f-7d3b-abef-4c77b1f0972d</example>
public Guid? Id { get; set; }

/// <summary>
/// The display name of the attachment that should be used in GUIs.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ public MappingProfile()
.ForMember(dest => dest.ActorType, opt => opt.Ignore())
.ForMember(dest => dest.ActorTypeId, opt => opt.MapFrom(src => src.ActorType));

CreateMap<UpdateDialogTransmissionAttachmentDto, DialogTransmissionAttachment>()
.ForMember(x => x.Id, opt => opt.Ignore());
CreateMap<UpdateDialogTransmissionAttachmentDto, DialogTransmissionAttachment>();

CreateMap<UpdateDialogTransmissionAttachmentUrlDto, AttachmentUrl>()
.ForMember(x => x.Id, opt => opt.Ignore())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,17 @@ private async Task AppendTransmission(DialogEntity dialog, UpdateDialogDto dto,
return;
}

var newTransmissionAttachments = newDialogTransmissions
.SelectMany(x => x.Attachments)
.ToList();

var existingTransmissionAttachmentIds = await _db.GetExistingIds(newTransmissionAttachments, cancellationToken);
if (existingTransmissionAttachmentIds.Count != 0)
{
_domainContext.AddError(DomainFailure.EntityExists<DialogTransmissionAttachment>(existingTransmissionAttachmentIds));
return;
}

dialog.Transmissions.AddRange(newDialogTransmissions);
// Tell ef explicitly to add transmissions as new to the database.
_db.DialogTransmissions.AddRange(newDialogTransmissions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ public UpdateDialogTransmissionAttachmentDtoValidator(
IValidator<IEnumerable<LocalizationDto>> localizationsValidator,
IValidator<UpdateDialogTransmissionAttachmentUrlDto> urlValidator)
{
RuleFor(x => x.Id)
.IsValidUuidV7()
.UuidV7TimestampIsInPast();

RuleFor(x => x.DisplayName)
.SetValidator(localizationsValidator);
RuleFor(x => x.Urls)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,12 @@ public sealed class UpdateDialogDialogAttachmentUrlDto

public sealed class UpdateDialogTransmissionAttachmentDto
{
/// <summary>
/// A self-defined UUIDv7 may be provided to support idempotent creation of transmission attachments. If not provided, a new UUIDv7 will be generated.
/// </summary>
/// <example>01913cd5-784f-7d3b-abef-4c77b1f0972d</example>
public Guid? Id { get; set; }

/// <summary>
/// The display name of the attachment that should be used in GUIs.
/// </summary>
Expand Down

0 comments on commit ae9b384

Please sign in to comment.