rename as ToEnvelopeKey

This commit is contained in:
tekh 2025-09-01 15:43:13 +02:00
parent 20d312a84e
commit 6a34b65825
5 changed files with 8 additions and 8 deletions

View File

@ -12,7 +12,7 @@ public static class EncodingExtensions
/// </summary> /// </summary>
/// <param name="readOnlyId"></param> /// <param name="readOnlyId"></param>
/// <returns></returns> /// <returns></returns>
public static string EncodeEnvelopeReceiverId(this long readOnlyId) public static string ToEnvelopeKey(this long readOnlyId)
{ {
//The random number is used as a salt to increase security but it is not saved in the database. //The random number is used as a salt to increase security but it is not saved in the database.
string combinedString = $"{Random.Shared.Next()}::{readOnlyId}::{Random.Shared.Next()}"; string combinedString = $"{Random.Shared.Next()}::{readOnlyId}::{Random.Shared.Next()}";
@ -27,7 +27,7 @@ public static class EncodingExtensions
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
public static string EncodeEnvelopeReceiverId(this (string envelopeUuid, string receiverSignature) input) public static string ToEnvelopeKey(this (string envelopeUuid, string receiverSignature) input)
{ {
string combinedString = $"{input.envelopeUuid}::{input.receiverSignature}"; string combinedString = $"{input.envelopeUuid}::{input.receiverSignature}";
byte[] bytes = Encoding.UTF8.GetBytes(combinedString); byte[] bytes = Encoding.UTF8.GetBytes(combinedString);

View File

@ -56,7 +56,7 @@ private async Task<Dictionary<string, string>> CreatePlaceholders(string? access
if(envelopeReceiverDto?.Envelope is not null && envelopeReceiverDto.Receiver is not null) if(envelopeReceiverDto?.Envelope is not null && envelopeReceiverDto.Receiver is not null)
{ {
var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).EncodeEnvelopeReceiverId(); var erId = (envelopeReceiverDto.Envelope.Uuid, envelopeReceiverDto.Receiver.Signature).ToEnvelopeKey();
var sigHost = await _configService.ReadDefaultSignatureHost(); var sigHost = await _configService.ReadDefaultSignatureHost();
var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}"; var linkToDoc = $"{sigHost}/EnvelopeKey/{erId}";
_placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc;
@ -71,7 +71,7 @@ private async Task<Dictionary<string, string>> CreatePlaceholders(string? access
if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null) if (readOnlyDto?.Envelope is not null && readOnlyDto.Receiver is not null)
{ {
_placeholders["[NAME_RECEIVER]"] = await _envRcvService.ReadLastUsedReceiverNameByMailAsync(readOnlyDto.AddedWho).ThenAsync(res => res, (msg, ntc) => string.Empty) ?? string.Empty; _placeholders["[NAME_RECEIVER]"] = await _envRcvService.ReadLastUsedReceiverNameByMailAsync(readOnlyDto.AddedWho).ThenAsync(res => res, (msg, ntc) => string.Empty) ?? string.Empty;
var erReadOnlyId = (readOnlyDto.Id).EncodeEnvelopeReceiverId(); var erReadOnlyId = (readOnlyDto.Id).ToEnvelopeKey();
var sigHost = await _configService.ReadDefaultSignatureHost(); var sigHost = await _configService.ReadDefaultSignatureHost();
var linkToDoc = $"{sigHost}/EnvelopeKey/{erReadOnlyId}"; var linkToDoc = $"{sigHost}/EnvelopeKey/{erReadOnlyId}";
_placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc; _placeholders["[LINK_TO_DOCUMENT]"] = linkToDoc;

View File

@ -32,7 +32,7 @@ public class HistoryTests : TestBase
var createReceiverCmd = this.CreateReceiverCommand(); var createReceiverCmd = this.CreateReceiverCommand();
(var receiver, _) = await Mediator.Send(createReceiverCmd); (var receiver, _) = await Mediator.Send(createReceiverCmd);
var key = (envelope.Uuid, receiver.Signature).EncodeEnvelopeReceiverId(); var key = (envelope.Uuid, receiver.Signature).ToEnvelopeKey();
var createCmd = Fake.Provider.CreateHistoryCommand(key); var createCmd = Fake.Provider.CreateHistoryCommand(key);

View File

@ -458,7 +458,7 @@ public class HomeController : ViewControllerBase
return await _envRcvService.ReadByUuidSignatureAsync(uuid: erro.Envelope!.Uuid, erro.Receiver!.Signature).ThenAsync( return await _envRcvService.ReadByUuidSignatureAsync(uuid: erro.Envelope!.Uuid, erro.Receiver!.Signature).ThenAsync(
SuccessAsync: async er => SuccessAsync: async er =>
{ {
var envelopeKey = (er.Envelope!.Uuid, er.Receiver!.Signature).EncodeEnvelopeReceiverId(); var envelopeKey = (er.Envelope!.Uuid, er.Receiver!.Signature).ToEnvelopeKey();
//TODO: implement multi-threading to history process (Task) //TODO: implement multi-threading to history process (Task)
var hist_res = await _historyService.RecordAsync((int)erro.EnvelopeId, erro.AddedWho, EnvelopeStatus.EnvelopeViewed); var hist_res = await _historyService.RecordAsync((int)erro.EnvelopeId, erro.AddedWho, EnvelopeStatus.EnvelopeViewed);

View File

@ -75,8 +75,8 @@ public class TestEnvelopeReceiverController : ControllerBase
public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null) public IActionResult EncodeEnvelopeReceiverId(string? uuid = null, string? signature = null, long? readOnlyId = null)
{ {
if(readOnlyId is long readOnlyId_long) if(readOnlyId is long readOnlyId_long)
return Ok(readOnlyId_long.EncodeEnvelopeReceiverId()); return Ok(readOnlyId_long.ToEnvelopeKey());
else else
return Ok((uuid ?? string.Empty, signature ?? string.Empty).EncodeEnvelopeReceiverId()); return Ok((uuid ?? string.Empty, signature ?? string.Empty).ToEnvelopeKey());
} }
} }