mirror of
https://github.com/bitwarden/server.git
synced 2025-02-03 23:51:21 +01:00
Fix AccountRevisionDate (#2467)
* Update AccountRevisionDate directly by userId * Have special DateTime handling on postgres
This commit is contained in:
parent
3a201e7520
commit
c39736c583
@ -139,7 +139,7 @@ public class CipherRepository : Repository<Core.Entities.Cipher, Cipher, Guid>,
|
||||
await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, folderEntities);
|
||||
var cipherEntities = Mapper.Map<List<Cipher>>(ciphers);
|
||||
await dbContext.BulkCopyAsync(base.DefaultBulkCopyOptions, cipherEntities);
|
||||
await dbContext.UserBumpAccountRevisionDateByCipherIdAsync(ciphers);
|
||||
await dbContext.UserBumpAccountRevisionDateAsync(ciphers.First().UserId.GetValueOrDefault());
|
||||
await dbContext.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
@ -141,11 +141,11 @@ public class DatabaseContext : DbContext
|
||||
eOrganizationConnection.ToTable(nameof(OrganizationConnection));
|
||||
eAuthRequest.ToTable(nameof(AuthRequest));
|
||||
|
||||
ConfigureDateTimeUTCQueries(builder);
|
||||
ConfigureDateTimeUtcQueries(builder);
|
||||
}
|
||||
|
||||
// Make sure this is called after configuring all the entities as it iterates through all setup entities.
|
||||
private static void ConfigureDateTimeUTCQueries(ModelBuilder builder)
|
||||
private void ConfigureDateTimeUtcQueries(ModelBuilder builder)
|
||||
{
|
||||
foreach (var entityType in builder.Model.GetEntityTypes())
|
||||
{
|
||||
@ -157,10 +157,20 @@ public class DatabaseContext : DbContext
|
||||
{
|
||||
if (property.ClrType == typeof(DateTime) || property.ClrType == typeof(DateTime?))
|
||||
{
|
||||
property.SetValueConverter(
|
||||
new ValueConverter<DateTime, DateTime>(
|
||||
v => v,
|
||||
v => new DateTime(v.Ticks, DateTimeKind.Utc)));
|
||||
if (Database.IsNpgsql())
|
||||
{
|
||||
property.SetValueConverter(
|
||||
new ValueConverter<DateTime, DateTime>(
|
||||
v => v,
|
||||
v => v.ToUniversalTime()));
|
||||
}
|
||||
else
|
||||
{
|
||||
property.SetValueConverter(
|
||||
new ValueConverter<DateTime, DateTime>(
|
||||
v => v,
|
||||
v => new DateTime(v.Ticks, DateTimeKind.Utc)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Bit.Core.Entities;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Enums.Provider;
|
||||
using Bit.Infrastructure.EntityFramework.Repositories.Queries;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
@ -42,14 +41,6 @@ public static class DatabaseContextExtensions
|
||||
UpdateUserRevisionDate(users);
|
||||
}
|
||||
|
||||
public static async Task UserBumpAccountRevisionDateByCipherIdAsync(this DatabaseContext context, IEnumerable<Cipher> ciphers)
|
||||
{
|
||||
foreach (var cipher in ciphers)
|
||||
{
|
||||
await context.UserBumpAccountRevisionDateByCipherIdAsync(cipher.Id, cipher.OrganizationId);
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task UserBumpAccountRevisionDateByCollectionIdAsync(this DatabaseContext context, Guid collectionId, Guid organizationId)
|
||||
{
|
||||
var query = from u in context.Users
|
||||
|
Loading…
Reference in New Issue
Block a user