Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions src/Api/Tools/Controllers/SendsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using Bit.Core;
using Bit.Core.Exceptions;
using Bit.Core.Services;
using Bit.Core.Settings;
using Bit.Core.Tools.Enums;
using Bit.Core.Tools.Models.Data;
using Bit.Core.Tools.Repositories;
Expand All @@ -31,7 +30,6 @@
private readonly IAnonymousSendCommand _anonymousSendCommand;
private readonly INonAnonymousSendCommand _nonAnonymousSendCommand;
private readonly ILogger<SendsController> _logger;
private readonly GlobalSettings _globalSettings;

public SendsController(
ISendRepository sendRepository,
Expand All @@ -40,8 +38,7 @@
IAnonymousSendCommand anonymousSendCommand,
INonAnonymousSendCommand nonAnonymousSendCommand,
ISendFileStorageService sendFileStorageService,
ILogger<SendsController> logger,
GlobalSettings globalSettings)
ILogger<SendsController> logger)
{
_sendRepository = sendRepository;
_userService = userService;
Expand All @@ -50,7 +47,6 @@
_nonAnonymousSendCommand = nonAnonymousSendCommand;
_sendFileStorageService = sendFileStorageService;
_logger = logger;
_globalSettings = globalSettings;
}

#region Anonymous endpoints
Expand Down Expand Up @@ -83,7 +79,7 @@
throw new NotFoundException();
}

var sendResponse = new SendAccessResponseModel(send, _globalSettings);
var sendResponse = new SendAccessResponseModel(send);
if (send.UserId.HasValue && !send.HideEmail.GetValueOrDefault())
{
var creator = await _userService.GetUserByIdAsync(send.UserId.Value);
Expand Down Expand Up @@ -185,15 +181,15 @@
throw new NotFoundException();
}

return new SendResponseModel(send, _globalSettings);
return new SendResponseModel(send);

Check warning on line 184 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L184

Added line #L184 was not covered by tests
}

[HttpGet("")]
public async Task<ListResponseModel<SendResponseModel>> Get()
{
var userId = _userService.GetProperUserId(User).Value;
var sends = await _sendRepository.GetManyByUserIdAsync(userId);
var responses = sends.Select(s => new SendResponseModel(s, _globalSettings));
var responses = sends.Select(s => new SendResponseModel(s));

Check warning on line 192 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L192

Added line #L192 was not covered by tests
return new ListResponseModel<SendResponseModel>(responses);
}

Expand All @@ -204,7 +200,7 @@
var userId = _userService.GetProperUserId(User).Value;
var send = model.ToSend(userId, _sendAuthorizationService);
await _nonAnonymousSendCommand.SaveSendAsync(send);
return new SendResponseModel(send, _globalSettings);
return new SendResponseModel(send);

Check warning on line 203 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L203

Added line #L203 was not covered by tests
}

[HttpPost("file/v2")]
Expand Down Expand Up @@ -233,7 +229,7 @@
{
Url = uploadUrl,
FileUploadType = _sendFileStorageService.FileUploadType,
SendResponse = new SendResponseModel(send, _globalSettings)
SendResponse = new SendResponseModel(send)

Check warning on line 232 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L232

Added line #L232 was not covered by tests
};
}

Expand All @@ -257,7 +253,7 @@
{
Url = await _sendFileStorageService.GetSendFileUploadUrlAsync(send, fileId),
FileUploadType = _sendFileStorageService.FileUploadType,
SendResponse = new SendResponseModel(send, _globalSettings),
SendResponse = new SendResponseModel(send),

Check warning on line 256 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L256

Added line #L256 was not covered by tests
};
}

Expand Down Expand Up @@ -291,7 +287,7 @@
}

await _nonAnonymousSendCommand.SaveSendAsync(model.ToSend(send, _sendAuthorizationService));
return new SendResponseModel(send, _globalSettings);
return new SendResponseModel(send);

Check warning on line 290 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L290

Added line #L290 was not covered by tests
}

[HttpPut("{id}/remove-password")]
Expand All @@ -306,7 +302,7 @@

send.Password = null;
await _nonAnonymousSendCommand.SaveSendAsync(send);
return new SendResponseModel(send, _globalSettings);
return new SendResponseModel(send);

Check warning on line 305 in src/Api/Tools/Controllers/SendsController.cs

View check run for this annotation

Codecov / codecov/patch

src/Api/Tools/Controllers/SendsController.cs#L305

Added line #L305 was not covered by tests
}

[HttpDelete("{id}")]
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tools/Models/Response/SendAccessResponseModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
๏ปฟusing System.Text.Json;
using Bit.Core.Models.Api;
using Bit.Core.Settings;
using Bit.Core.Tools.Entities;
using Bit.Core.Tools.Enums;
using Bit.Core.Tools.Models.Data;
Expand All @@ -10,7 +9,7 @@ namespace Bit.Api.Tools.Models.Response;

public class SendAccessResponseModel : ResponseModel
{
public SendAccessResponseModel(Send send, GlobalSettings globalSettings)
public SendAccessResponseModel(Send send)
: base("send-access")
{
if (send == null)
Expand Down
3 changes: 1 addition & 2 deletions src/Api/Tools/Models/Response/SendResponseModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
๏ปฟusing System.Text.Json;
using Bit.Core.Models.Api;
using Bit.Core.Settings;
using Bit.Core.Tools.Entities;
using Bit.Core.Tools.Enums;
using Bit.Core.Tools.Models.Data;
Expand All @@ -10,7 +9,7 @@ namespace Bit.Api.Tools.Models.Response;

public class SendResponseModel : ResponseModel
{
public SendResponseModel(Send send, GlobalSettings globalSettings)
public SendResponseModel(Send send)
: base("send")
{
if (send == null)
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Vault/Models/Response/SyncResponseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public SyncResponseModel(
c => new CollectionDetailsResponseModel(c)) ?? new List<CollectionDetailsResponseModel>();
Domains = excludeDomains ? null : new DomainsResponseModel(user, false);
Policies = policies?.Select(p => new PolicyResponseModel(p)) ?? new List<PolicyResponseModel>();
Sends = sends.Select(s => new SendResponseModel(s, globalSettings));
Sends = sends.Select(s => new SendResponseModel(s));
}

public ProfileResponseModel Profile { get; set; }
Expand Down
3 changes: 1 addition & 2 deletions test/Api.Test/Tools/Controllers/SendsControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ public SendsControllerTests()
_anonymousSendCommand,
_nonAnonymousSendCommand,
_sendFileStorageService,
_logger,
_globalSettings
_logger
);
}

Expand Down
Loading