mirror of
https://github.com/bitwarden/server
synced 2026-01-16 07:23:15 +00:00
PM-18939 refactoring send service to 'cqrs' (#5652)
* PM-18939 refactoring send service to 'cqrs' * PM-18939 fixing import issue with sendValidationService * PM-18939 fixing code based on PR comments * PM-18339 reverting to previous code in test * PM-18939 adding XMLdocs to services * PM-18939 reverting send validation methods * PM-18939 updating code to match main * PM-18939 reverting validateUserCanSaveAsync to match main * PM-18939 fill our param and return sections of XMLdocs * PM-18939 updating XMLdocs based on PR comments * Update src/Core/Tools/SendFeatures/Commands/Interfaces/IAnonymousSendCommand.cs Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com> * Update src/Core/Tools/SendFeatures/Commands/Interfaces/INonAnonymousSendCommand.cs Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com> * Update src/Core/Tools/SendFeatures/Commands/Interfaces/INonAnonymousSendCommand.cs Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com> * Update src/Core/Tools/SendFeatures/Services/Interfaces/ISendStorageService.cs Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com> * PM-18939 adding commits to change tuple to enum type * PM-18939 resetting stream position to 0 when uploading file * PM-18939 updating XMLdocs based on PR comments * PM-18939 updating XMLdocs * PM-18939 removing circular dependency * PM-18939 fixing based on comments * PM-18939 updating method name and documentation --------- Co-authored-by: ✨ Audrey ✨ <ajensen@bitwarden.com>
This commit is contained in:
@@ -36,31 +36,31 @@ public class SendRequestModel
|
||||
public bool? Disabled { get; set; }
|
||||
public bool? HideEmail { get; set; }
|
||||
|
||||
public Send ToSend(Guid userId, ISendService sendService)
|
||||
public Send ToSend(Guid userId, ISendAuthorizationService sendAuthorizationService)
|
||||
{
|
||||
var send = new Send
|
||||
{
|
||||
Type = Type,
|
||||
UserId = (Guid?)userId
|
||||
};
|
||||
ToSend(send, sendService);
|
||||
ToSend(send, sendAuthorizationService);
|
||||
return send;
|
||||
}
|
||||
|
||||
public (Send, SendFileData) ToSend(Guid userId, string fileName, ISendService sendService)
|
||||
public (Send, SendFileData) ToSend(Guid userId, string fileName, ISendAuthorizationService sendAuthorizationService)
|
||||
{
|
||||
var send = ToSendBase(new Send
|
||||
{
|
||||
Type = Type,
|
||||
UserId = (Guid?)userId
|
||||
}, sendService);
|
||||
}, sendAuthorizationService);
|
||||
var data = new SendFileData(Name, Notes, fileName);
|
||||
return (send, data);
|
||||
}
|
||||
|
||||
public Send ToSend(Send existingSend, ISendService sendService)
|
||||
public Send ToSend(Send existingSend, ISendAuthorizationService sendAuthorizationService)
|
||||
{
|
||||
existingSend = ToSendBase(existingSend, sendService);
|
||||
existingSend = ToSendBase(existingSend, sendAuthorizationService);
|
||||
switch (existingSend.Type)
|
||||
{
|
||||
case SendType.File:
|
||||
@@ -125,7 +125,7 @@ public class SendRequestModel
|
||||
}
|
||||
}
|
||||
|
||||
private Send ToSendBase(Send existingSend, ISendService sendService)
|
||||
private Send ToSendBase(Send existingSend, ISendAuthorizationService authorizationService)
|
||||
{
|
||||
existingSend.Key = Key;
|
||||
existingSend.ExpirationDate = ExpirationDate;
|
||||
@@ -133,7 +133,7 @@ public class SendRequestModel
|
||||
existingSend.MaxAccessCount = MaxAccessCount;
|
||||
if (!string.IsNullOrWhiteSpace(Password))
|
||||
{
|
||||
existingSend.Password = sendService.HashPassword(Password);
|
||||
existingSend.Password = authorizationService.HashPassword(Password);
|
||||
}
|
||||
existingSend.Disabled = Disabled.GetValueOrDefault();
|
||||
existingSend.HideEmail = HideEmail.GetValueOrDefault();
|
||||
|
||||
Reference in New Issue
Block a user