Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-336] Enable Nullable In Unowned Services #4748

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/Core/Context/ICurrentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public interface ICurrentContext
{
HttpContext HttpContext { get; set; }
Guid? UserId { get; set; }
User User { get; set; }
User? User { get; set; }
string DeviceIdentifier { get; set; }
DeviceType? DeviceType { get; set; }
string IpAddress { get; set; }
Expand Down
8 changes: 5 additions & 3 deletions src/Core/Models/PushNotification.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Bit.Core.Enums;

#nullable enable

namespace Bit.Core.Models;

public class PushNotificationData<T>
{
public PushNotificationData(PushType type, T payload, string contextId)
public PushNotificationData(PushType type, T payload, string? contextId)

Check warning on line 9 in src/Core/Models/PushNotification.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Models/PushNotification.cs#L9

Added line #L9 was not covered by tests
{
Type = type;
Payload = payload;
Expand All @@ -13,15 +15,15 @@

public PushType Type { get; set; }
public T Payload { get; set; }
public string ContextId { get; set; }
public string? ContextId { get; set; }

Check warning on line 18 in src/Core/Models/PushNotification.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Models/PushNotification.cs#L18

Added line #L18 was not covered by tests
}

public class SyncCipherPushNotification
{
public Guid Id { get; set; }
public Guid? UserId { get; set; }
public Guid? OrganizationId { get; set; }
public IEnumerable<Guid> CollectionIds { get; set; }
public IEnumerable<Guid>? CollectionIds { get; set; }

Check warning on line 26 in src/Core/Models/PushNotification.cs

View check run for this annotation

Codecov / codecov/patch

src/Core/Models/PushNotification.cs#L26

Added line #L26 was not covered by tests
public DateTime RevisionDate { get; set; }
}

Expand Down
2 changes: 1 addition & 1 deletion src/Core/Repositories/ICollectionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public interface ICollectionRepository : IRepository<Collection, Guid>
Task<CollectionAdminDetails?> GetByIdWithPermissionsAsync(Guid collectionId, Guid? userId, bool includeAccessRelationships);

Task CreateAsync(Collection obj, IEnumerable<CollectionAccessSelection>? groups, IEnumerable<CollectionAccessSelection>? users);
Task ReplaceAsync(Collection obj, IEnumerable<CollectionAccessSelection> groups, IEnumerable<CollectionAccessSelection> users);
Task ReplaceAsync(Collection obj, IEnumerable<CollectionAccessSelection>? groups, IEnumerable<CollectionAccessSelection>? users);
Task DeleteUserAsync(Guid collectionId, Guid organizationUserId);
Task UpdateUsersAsync(Guid id, IEnumerable<CollectionAccessSelection> users);
Task<ICollection<CollectionAccessSelection>> GetManyUsersByIdAsync(Guid id);
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Services/IApplicationCacheService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Bit.Core.AdminConsole.Models.Data.Provider;
using Bit.Core.Models.Data.Organizations;

#nullable enable

namespace Bit.Core.Services;

public interface IApplicationCacheService
Expand Down
1 change: 1 addition & 0 deletions src/Core/Services/IAttachmentStorageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Bit.Core.Vault.Entities;
using Bit.Core.Vault.Models.Data;

#nullable enable

namespace Bit.Core.Services;

Expand Down
4 changes: 3 additions & 1 deletion src/Core/Services/ICollectionService.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
using Bit.Core.Entities;
using Bit.Core.Models.Data;

#nullable enable

namespace Bit.Core.Services;

public interface ICollectionService
{
Task SaveAsync(Collection collection, IEnumerable<CollectionAccessSelection> groups = null, IEnumerable<CollectionAccessSelection> users = null);
Task SaveAsync(Collection collection, IEnumerable<CollectionAccessSelection>? groups = null, IEnumerable<CollectionAccessSelection>? users = null);
Task DeleteUserAsync(Collection collection, Guid organizationUserId);
[Obsolete("Pre-Flexible Collections logic.")]
Task<IEnumerable<Collection>> GetOrganizationCollectionsAsync(Guid organizationId);
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Services/IDeviceService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Bit.Core.Auth.Models.Api.Request;
using Bit.Core.Entities;

#nullable enable

namespace Bit.Core.Services;

public interface IDeviceService
Expand Down
4 changes: 3 additions & 1 deletion src/Core/Services/IDnsResolverService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Bit.Core.Services;
#nullable enable

namespace Bit.Core.Services;

public interface IDnsResolverService
{
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Services/IFeatureService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Bit.Core.Services;
#nullable enable

namespace Bit.Core.Services;

public interface IFeatureService
{
Expand Down Expand Up @@ -30,7 +32,7 @@ public interface IFeatureService
/// <param name="key">The key of the feature to check.</param>
/// <param name="defaultValue">The default value for the feature.</param>
/// <returns>The feature variation value.</returns>
string GetStringVariation(string key, string defaultValue = null);
string GetStringVariation(string key, string? defaultValue = null);

/// <summary>
/// Gets all feature values.
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Services/II18nService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.Extensions.Localization;

#nullable enable

namespace Bit.Core.Services;

public interface II18nService
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Services/ILicensingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using Bit.Core.Entities;
using Bit.Core.Models.Business;

#nullable enable

namespace Bit.Core.Services;

public interface ILicensingService
Expand All @@ -11,7 +13,7 @@ public interface ILicensingService
Task<bool> ValidateUserPremiumAsync(User user);
bool VerifyLicense(ILicense license);
byte[] SignLicense(ILicense license);
Task<OrganizationLicense> ReadOrganizationLicenseAsync(Organization organization);
Task<OrganizationLicense> ReadOrganizationLicenseAsync(Guid organizationId);
Task<OrganizationLicense?> ReadOrganizationLicenseAsync(Organization organization);
Task<OrganizationLicense?> ReadOrganizationLicenseAsync(Guid organizationId);

}
2 changes: 2 additions & 0 deletions src/Core/Services/IMailDeliveryService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Bit.Core.Models.Mail;

#nullable enable

namespace Bit.Core.Services;

public interface IMailDeliveryService
Expand Down
2 changes: 2 additions & 0 deletions src/Core/Services/IMailEnqueuingService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Bit.Core.Models.Mail;

#nullable enable

namespace Bit.Core.Services;

public interface IMailEnqueuingService
Expand Down
5 changes: 3 additions & 2 deletions src/Core/Services/IMailService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Bit.Core.Entities;
using Bit.Core.Models.Mail;

#nullable enable

namespace Bit.Core.Services;

public interface IMailService
Expand Down Expand Up @@ -49,7 +51,7 @@ Task SendInvoiceUpcoming(
bool mentionInvoices);
Task SendPaymentFailedAsync(string email, decimal amount, bool mentionInvoices);
Task SendAddedCreditAsync(string email, decimal amount);
Task SendLicenseExpiredAsync(IEnumerable<string> emails, string organizationName = null);
Task SendLicenseExpiredAsync(IEnumerable<string> emails, string? organizationName = null);
Task SendNewDeviceLoggedInEmail(string email, string deviceType, DateTime timestamp, string ip);
Task SendRecoverTwoFactorEmail(string email, DateTime timestamp, string ip);
Task SendOrganizationUserRemovedForPolicySingleOrgEmailAsync(string organizationName, string email);
Expand Down Expand Up @@ -89,4 +91,3 @@ Task SendProviderUpdatePaymentMethod(
Task SendInitiateDeleteOrganzationEmailAsync(string email, Organization organization, string token);
Task SendRequestSMAccessToAdminEmailAsync(IEnumerable<string> adminEmails, string organizationName, string userRequestingAccess, string emailContent);
}

4 changes: 3 additions & 1 deletion src/Core/Services/IOrganizationDomainService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Bit.Core.Services;
#nullable enable

namespace Bit.Core.Services;

public interface IOrganizationDomainService
{
Expand Down
26 changes: 14 additions & 12 deletions src/Core/Services/IPaymentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,54 @@
using Bit.Core.Models.Business;
using Bit.Core.Models.StaticStore;

#nullable enable

namespace Bit.Core.Services;

public interface IPaymentService
{
Task CancelAndRecoverChargesAsync(ISubscriber subscriber);
Task<string> PurchaseOrganizationAsync(Organization org, PaymentMethodType paymentMethodType,
Task<string?> PurchaseOrganizationAsync(Organization org, PaymentMethodType paymentMethodType,
string paymentToken, Plan plan, short additionalStorageGb, int additionalSeats,
bool premiumAccessAddon, TaxInfo taxInfo, bool provider = false, int additionalSmSeats = 0,
int additionalServiceAccount = 0, bool signupIsFromSecretsManagerTrial = false);
Task SponsorOrganizationAsync(Organization org, OrganizationSponsorship sponsorship);
Task RemoveOrganizationSponsorshipAsync(Organization org, OrganizationSponsorship sponsorship);
Task<string> UpgradeFreeOrganizationAsync(Organization org, Plan plan, OrganizationUpgrade upgrade);
Task<string> PurchasePremiumAsync(User user, PaymentMethodType paymentMethodType, string paymentToken,
Task<string?> UpgradeFreeOrganizationAsync(Organization org, Plan plan, OrganizationUpgrade upgrade);
Task<string?> PurchasePremiumAsync(User user, PaymentMethodType paymentMethodType, string paymentToken,
short additionalStorageGb, TaxInfo taxInfo);
Task<string> AdjustSubscription(
Task<string?> AdjustSubscription(
Organization organization,
Plan updatedPlan,
int newlyPurchasedPasswordManagerSeats,
bool subscribedToSecretsManager,
int? newlyPurchasedSecretsManagerSeats,
int? newlyPurchasedAdditionalSecretsManagerServiceAccounts,
int newlyPurchasedAdditionalStorage);
Task<string> AdjustSeatsAsync(Organization organization, Plan plan, int additionalSeats);
Task<string> AdjustSeats(
Task<string?> AdjustSeatsAsync(Organization organization, Plan plan, int additionalSeats);
Task<string?> AdjustSeats(
Provider provider,
Plan plan,
int currentlySubscribedSeats,
int newlySubscribedSeats);
Task<string> AdjustSmSeatsAsync(Organization organization, Plan plan, int additionalSeats);
Task<string> AdjustStorageAsync(IStorableSubscriber storableSubscriber, int additionalStorage, string storagePlanId);
Task<string?> AdjustSmSeatsAsync(Organization organization, Plan plan, int additionalSeats);
Task<string?> AdjustStorageAsync(IStorableSubscriber storableSubscriber, int additionalStorage, string storagePlanId);

Task<string> AdjustServiceAccountsAsync(Organization organization, Plan plan, int additionalServiceAccounts);
Task<string?> AdjustServiceAccountsAsync(Organization organization, Plan plan, int additionalServiceAccounts);
Task CancelSubscriptionAsync(ISubscriber subscriber, bool endOfPeriod = false);
Task ReinstateSubscriptionAsync(ISubscriber subscriber);
Task<bool> UpdatePaymentMethodAsync(ISubscriber subscriber, PaymentMethodType paymentMethodType,
string paymentToken, TaxInfo taxInfo = null);
string paymentToken, TaxInfo? taxInfo = null);
Task<bool> CreditAccountAsync(ISubscriber subscriber, decimal creditAmount);
Task<BillingInfo> GetBillingAsync(ISubscriber subscriber);
Task<BillingHistoryInfo> GetBillingHistoryAsync(ISubscriber subscriber);
Task<SubscriptionInfo> GetSubscriptionAsync(ISubscriber subscriber);
Task<TaxInfo> GetTaxInfoAsync(ISubscriber subscriber);
Task<TaxInfo?> GetTaxInfoAsync(ISubscriber subscriber);
Task SaveTaxInfoAsync(ISubscriber subscriber, TaxInfo taxInfo);
Task<TaxRate> CreateTaxRateAsync(TaxRate taxRate);
Task UpdateTaxRateAsync(TaxRate taxRate);
Task ArchiveTaxRateAsync(TaxRate taxRate);
Task<string> AddSecretsManagerToSubscription(Organization org, Plan plan, int additionalSmSeats,
Task<string?> AddSecretsManagerToSubscription(Organization org, Plan plan, int additionalSmSeats,
int additionalServiceAccount);
Task<bool> RisksSubscriptionFailure(Organization organization);
Task<bool> HasSecretsManagerStandalone(Organization organization);
Expand Down
6 changes: 4 additions & 2 deletions src/Core/Services/IPushNotificationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Bit.Core.Tools.Entities;
using Bit.Core.Vault.Entities;

#nullable enable

namespace Bit.Core.Services;

public interface IPushNotificationService
Expand All @@ -24,7 +26,7 @@ public interface IPushNotificationService
Task PushSyncSendDeleteAsync(Send send);
Task PushAuthRequestAsync(AuthRequest authRequest);
Task PushAuthRequestResponseAsync(AuthRequest authRequest);
Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier, string deviceId = null);
Task SendPayloadToUserAsync(string userId, PushType type, object payload, string identifier, string? deviceId = null);
Task SendPayloadToOrganizationAsync(string orgId, PushType type, object payload, string identifier,
string deviceId = null);
string? deviceId = null);
}
4 changes: 3 additions & 1 deletion src/Core/Services/IPushRegistrationService.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Bit.Core.Enums;

#nullable enable

namespace Bit.Core.Services;

public interface IPushRegistrationService
{
Task CreateOrUpdateRegistrationAsync(string pushToken, string deviceId, string userId,
Task CreateOrUpdateRegistrationAsync(string? pushToken, string deviceId, string userId,
string identifier, DeviceType type);
Task DeleteRegistrationAsync(string deviceId, DeviceType type);
Task AddUserRegistrationOrganizationAsync(IEnumerable<KeyValuePair<string, DeviceType>> devices, string organizationId);
Expand Down
38 changes: 20 additions & 18 deletions src/Core/Services/IStripeAdapter.cs
Original file line number Diff line number Diff line change
@@ -1,48 +1,50 @@
using Bit.Core.Models.BitStripe;
using Stripe;

#nullable enable

namespace Bit.Core.Services;

public interface IStripeAdapter
{
Task<Stripe.Customer> CustomerCreateAsync(Stripe.CustomerCreateOptions customerCreateOptions);
Task<Stripe.Customer> CustomerGetAsync(string id, Stripe.CustomerGetOptions options = null);
Task<Stripe.Customer> CustomerUpdateAsync(string id, Stripe.CustomerUpdateOptions options = null);
Task<Stripe.Customer> CustomerGetAsync(string id, Stripe.CustomerGetOptions? options = null);
Task<Stripe.Customer> CustomerUpdateAsync(string id, Stripe.CustomerUpdateOptions? options = null);
Task<Stripe.Customer> CustomerDeleteAsync(string id);
Task<List<PaymentMethod>> CustomerListPaymentMethods(string id, CustomerListPaymentMethodsOptions options = null);
Task<List<PaymentMethod>> CustomerListPaymentMethods(string id, CustomerListPaymentMethodsOptions? options = null);
Task<Stripe.Subscription> SubscriptionCreateAsync(Stripe.SubscriptionCreateOptions subscriptionCreateOptions);
Task<Stripe.Subscription> SubscriptionGetAsync(string id, Stripe.SubscriptionGetOptions options = null);
Task<Stripe.Subscription> SubscriptionGetAsync(string id, Stripe.SubscriptionGetOptions? options = null);
Task<List<Stripe.Subscription>> SubscriptionListAsync(StripeSubscriptionListOptions subscriptionSearchOptions);
Task<Stripe.Subscription> SubscriptionUpdateAsync(string id, Stripe.SubscriptionUpdateOptions options = null);
Task<Stripe.Subscription> SubscriptionCancelAsync(string Id, Stripe.SubscriptionCancelOptions options = null);
Task<Stripe.Subscription> SubscriptionUpdateAsync(string id, Stripe.SubscriptionUpdateOptions? options = null);
Task<Stripe.Subscription> SubscriptionCancelAsync(string Id, Stripe.SubscriptionCancelOptions? options = null);
Task<Stripe.Invoice> InvoiceUpcomingAsync(Stripe.UpcomingInvoiceOptions options);
Task<Stripe.Invoice> InvoiceGetAsync(string id, Stripe.InvoiceGetOptions options);
Task<List<Stripe.Invoice>> InvoiceListAsync(StripeInvoiceListOptions options);
Task<List<Stripe.Invoice>> InvoiceSearchAsync(InvoiceSearchOptions options);
Task<Stripe.Invoice> InvoiceUpdateAsync(string id, Stripe.InvoiceUpdateOptions options);
Task<Stripe.Invoice> InvoiceFinalizeInvoiceAsync(string id, Stripe.InvoiceFinalizeOptions options);
Task<Stripe.Invoice> InvoiceSendInvoiceAsync(string id, Stripe.InvoiceSendOptions options);
Task<Stripe.Invoice> InvoicePayAsync(string id, Stripe.InvoicePayOptions options = null);
Task<Stripe.Invoice> InvoiceDeleteAsync(string id, Stripe.InvoiceDeleteOptions options = null);
Task<Stripe.Invoice> InvoiceVoidInvoiceAsync(string id, Stripe.InvoiceVoidOptions options = null);
Task<Stripe.Invoice> InvoicePayAsync(string id, Stripe.InvoicePayOptions? options = null);
Task<Stripe.Invoice> InvoiceDeleteAsync(string id, Stripe.InvoiceDeleteOptions? options = null);
Task<Stripe.Invoice> InvoiceVoidInvoiceAsync(string id, Stripe.InvoiceVoidOptions? options = null);
IEnumerable<Stripe.PaymentMethod> PaymentMethodListAutoPaging(Stripe.PaymentMethodListOptions options);
IAsyncEnumerable<Stripe.PaymentMethod> PaymentMethodListAutoPagingAsync(Stripe.PaymentMethodListOptions options);
Task<Stripe.PaymentMethod> PaymentMethodAttachAsync(string id, Stripe.PaymentMethodAttachOptions options = null);
Task<Stripe.PaymentMethod> PaymentMethodDetachAsync(string id, Stripe.PaymentMethodDetachOptions options = null);
Task<Stripe.PaymentMethod> PaymentMethodAttachAsync(string id, Stripe.PaymentMethodAttachOptions? options = null);
Task<Stripe.PaymentMethod> PaymentMethodDetachAsync(string id, Stripe.PaymentMethodDetachOptions? options = null);
Task<Stripe.TaxRate> TaxRateCreateAsync(Stripe.TaxRateCreateOptions options);
Task<Stripe.TaxRate> TaxRateUpdateAsync(string id, Stripe.TaxRateUpdateOptions options);
Task<Stripe.TaxId> TaxIdCreateAsync(string id, Stripe.TaxIdCreateOptions options);
Task<Stripe.TaxId> TaxIdDeleteAsync(string customerId, string taxIdId, Stripe.TaxIdDeleteOptions options = null);
Task<Stripe.TaxId> TaxIdDeleteAsync(string customerId, string taxIdId, Stripe.TaxIdDeleteOptions? options = null);
Task<Stripe.StripeList<Stripe.Charge>> ChargeListAsync(Stripe.ChargeListOptions options);
Task<Stripe.Refund> RefundCreateAsync(Stripe.RefundCreateOptions options);
Task<Stripe.Card> CardDeleteAsync(string customerId, string cardId, Stripe.CardDeleteOptions options = null);
Task<Stripe.BankAccount> BankAccountCreateAsync(string customerId, Stripe.BankAccountCreateOptions options = null);
Task<Stripe.BankAccount> BankAccountDeleteAsync(string customerId, string bankAccount, Stripe.BankAccountDeleteOptions options = null);
Task<Stripe.StripeList<Stripe.Price>> PriceListAsync(Stripe.PriceListOptions options = null);
Task<Stripe.Card> CardDeleteAsync(string customerId, string cardId, Stripe.CardDeleteOptions? options = null);
Task<Stripe.BankAccount> BankAccountCreateAsync(string customerId, Stripe.BankAccountCreateOptions? options = null);
Task<Stripe.BankAccount> BankAccountDeleteAsync(string customerId, string bankAccount, Stripe.BankAccountDeleteOptions? options = null);
Task<Stripe.StripeList<Stripe.Price>> PriceListAsync(Stripe.PriceListOptions? options = null);
Task<SetupIntent> SetupIntentCreate(SetupIntentCreateOptions options);
Task<List<SetupIntent>> SetupIntentList(SetupIntentListOptions options);
Task SetupIntentCancel(string id, SetupIntentCancelOptions options = null);
Task<SetupIntent> SetupIntentGet(string id, SetupIntentGetOptions options = null);
Task SetupIntentCancel(string id, SetupIntentCancelOptions? options = null);
Task<SetupIntent> SetupIntentGet(string id, SetupIntentGetOptions? options = null);
Task SetupIntentVerifyMicroDeposit(string id, SetupIntentVerifyMicrodepositsOptions options);
Task<List<Stripe.TestHelpers.TestClock>> TestClockListAsync();
}
4 changes: 3 additions & 1 deletion src/Core/Services/IStripeSyncService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Bit.Core.Services;
#nullable enable

namespace Bit.Core.Services;

public interface IStripeSyncService
{
Expand Down
Loading
Loading