Fix empty receiver signature when sending

This commit is contained in:
Jonathan Jenne 2023-11-28 15:54:35 +01:00
parent 38577f66e0
commit 80246b8964
2 changed files with 13 additions and 12 deletions

View File

@ -33,6 +33,11 @@ Public Class EnvelopeEditorController
Public Function SendEnvelope() As Boolean
For Each receiverItem As EnvelopeReceiver In Envelope.Receivers
If receiverItem.Signature Is Nothing Then
Logger.Warn("Signature for Receiver is empty. Aborting.")
Return False
End If
Dim oEmailData As New EmailData(Envelope, receiverItem) With
{
.SignatureLink = Helpers.GetEnvelopeURL(State.DbConfig.SignatureHost, Envelope.Uuid, receiverItem.Signature)
@ -266,22 +271,16 @@ Public Class EnvelopeEditorController
End Function
Public Function CreateEnvelopeReceivers(pCurrentReceivers As List(Of EnvelopeReceiver)) As Boolean
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pCurrentReceivers)
Dim oExistingReceivers As List(Of EnvelopeReceiver) = ReceiverModel.ListReceivers(pCurrentReceivers).ToList()
Dim oExistingAddresses = oExistingReceivers.Select(Function(r) r.Email)
' Neue Empfänger
Dim oNewReceivers = pCurrentReceivers.
Where(Function(r) Not oExistingAddresses.Contains(r.Email)).ToList()
' Empfänger, die bereits einmal verwendet wurden
For Each oCurrentReceiver In pCurrentReceivers
If oCurrentReceiver.Id = 0 Then
Dim oExistingReceiver As EnvelopeReceiver = oExistingReceivers.Where(Function(r) r.Email.Equals(oCurrentReceiver.Email, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault()
If oExistingReceiver IsNot Nothing Then
oCurrentReceiver.Id = oExistingReceiver.Id
End If
End If
Next
If oNewReceivers.Count = 0 Then
Return True
End If
Dim oConnection = Database.GetConnection()
Dim oTransaction = oConnection.BeginTransaction()
@ -293,6 +292,9 @@ Public Class EnvelopeEditorController
oTransaction.Commit()
' Empfänger neu aus der Datenbank laden
Envelope.Receivers = ReceiverModel.ListReceivers(pCurrentReceivers).ToList()
Return True
Catch ex As Exception
Logger.Error(ex)

View File

@ -184,7 +184,6 @@ Partial Public Class frmEnvelopeEditor
Dim oEnvelope = Controller.Envelope
oEnvelope.Subject = oSubject
oEnvelope.Message = oMessage
oEnvelope.Receivers = Receivers.ToList
oEnvelope.Documents = Documents.ToList
If pWithValidation = True Then
@ -195,7 +194,7 @@ Partial Public Class frmEnvelopeEditor
End If
End If
If Controller.CreateEnvelopeReceivers(oEnvelope.Receivers) = False Then
If Controller.CreateEnvelopeReceivers(Receivers.ToList) = False Then
MsgBox(Resources.Envelope.Error_when_saving_the_recipients, MsgBoxStyle.Critical, Text)
Return False
End If