mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 09:02:48 -05:00
[AC-1693] Send InvoiceUpcoming Notification to Client Owners (#3319)
* Add Organization_ReadOwnerEmailAddresses SPROC * Add IOrganizationRepository.GetOwnerEmailAddressesById * Add SendInvoiceUpcoming overload for multiple emails * Update InvoiceUpcoming handler to send multiple emails * Cy's feedback * Updates from testing Hardened against missing entity IDs in Stripe events in the StripeEventService. Updated ValidateCloudRegion to not use a refresh/expansion for the customer because the invoice.upcoming event does not have an invoice.Id. Updated the StripeController's handling of invoice.upcoming to not use a refresh/expansion for the subscription because the invoice does not have an ID. * Fix broken test
This commit is contained in:
@ -224,4 +224,24 @@ public class OrganizationRepository : Repository<Core.Entities.Organization, Org
|
||||
return selfHostedOrganization;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<string>> GetOwnerEmailAddressesById(Guid organizationId)
|
||||
{
|
||||
using var scope = ServiceScopeFactory.CreateScope();
|
||||
|
||||
var dbContext = GetDatabaseContext(scope);
|
||||
|
||||
var query =
|
||||
from u in dbContext.Users
|
||||
join ou in dbContext.OrganizationUsers on u.Id equals ou.UserId
|
||||
where
|
||||
ou.OrganizationId == organizationId &&
|
||||
ou.Type == OrganizationUserType.Owner &&
|
||||
ou.Status == OrganizationUserStatusType.Confirmed
|
||||
group u by u.Email
|
||||
into grouped
|
||||
select grouped.Key;
|
||||
|
||||
return await query.ToListAsync();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user