Merge branch 'release/v1.0.0' of https://github.com/ONLYOFFICE/DocSpace into release/v1.0.0

This commit is contained in:
Maria Sukhova 2023-04-13 15:33:30 +03:00
commit 7828abcec9
4 changed files with 38 additions and 44 deletions

View File

@ -26,6 +26,8 @@
using ASC.Core.Common.EF;
using Microsoft.EntityFrameworkCore;
namespace ASC.Core.Data;
[Scope]
@ -550,53 +552,45 @@ public class EFUserService : IUserService
public void SetUserPhoto(int tenant, Guid id, byte[] photo)
{
using var userDbContext = _dbContextFactory.CreateDbContext();
var strategy = userDbContext.Database.CreateExecutionStrategy();
strategy.Execute(async () =>
var userPhoto = userDbContext.Photos.FirstOrDefault(r => r.UserId == id && r.Tenant == tenant);
if (photo != null && photo.Length != 0)
{
using var userDbContext = _dbContextFactory.CreateDbContext();
using var tr = await userDbContext.Database.BeginTransactionAsync();
var userPhoto = await userDbContext.Photos.FirstOrDefaultAsync(r => r.UserId == id && r.Tenant == tenant);
if (photo != null && photo.Length != 0)
if (userPhoto == null)
{
if (userPhoto == null)
userPhoto = new UserPhoto
{
userPhoto = new UserPhoto
{
Tenant = tenant,
UserId = id,
Photo = photo
};
}
else
{
userPhoto.Photo = photo;
}
await userDbContext.AddOrUpdateAsync(r => userDbContext.Photos, userPhoto);
var userEntity = new User
{
Id = id,
LastModified = DateTime.UtcNow,
Tenant = tenant
Tenant = tenant,
UserId = id,
Photo = photo
};
userDbContext.Entry(userEntity).Property(x => x.LastModified).IsModified = true;
}
else if (userPhoto != null)
else
{
userDbContext.Photos.Remove(userPhoto);
userPhoto.Photo = photo;
}
await userDbContext.SaveChangesAsync();
await tr.CommitAsync();
}).GetAwaiter()
.GetResult();
userDbContext.AddOrUpdate(userDbContext.Photos, userPhoto);
var userEntity = new User
{
Id = id,
LastModified = DateTime.UtcNow,
Tenant = tenant
};
userDbContext.Users.Attach(userEntity);
userDbContext.Entry(userEntity).Property(x => x.LastModified).IsModified = true;
}
else if (userPhoto != null)
{
userDbContext.Photos.Remove(userPhoto);
}
userDbContext.SaveChanges();
}
private IQueryable<User> GetUserQuery(UserDbContext userDbContext, int tenant)

View File

@ -154,7 +154,8 @@ const StyledComboButton = styled.div`
? props.theme.comboBox.label.selectedColor
: props.theme.comboBox.label.color};
max-width: ${(props) => props.theme.comboBox.label.maxWidth};
max-width: ${(props) =>
props.scaled ? "100%" : props.theme.comboBox.label.maxWidth};
${(props) =>
props.noBorder &&

View File

@ -207,14 +207,14 @@ public class PhotoController : PeopleControllerBase
throw new ImageSizeLimitException();
}
var mainPhoto = _userPhotoManager.SaveOrUpdatePhoto(userId, data);
var mainPhoto = await _userPhotoManager.SaveOrUpdatePhoto(userId, data);
var userInfo = _userManager.GetUsers(userId);
var cacheKey = Math.Abs(userInfo.LastModified.GetHashCode());
result.Data =
new
{
main = (await mainPhoto).Item1 + $"?hash={cacheKey}",
main = mainPhoto.Item1 + $"?hash={cacheKey}",
retina = await _userPhotoManager.GetRetinaPhotoURL(userId) + $"?hash={cacheKey}",
max = await _userPhotoManager.GetMaxPhotoURL(userId) + $"?hash={cacheKey}",
big = await _userPhotoManager.GetBigPhotoURL(userId) + $"?hash={cacheKey}",

View File

@ -546,7 +546,7 @@ public class UserPhotoManager
data = TryParseImage(data, -1, OriginalFotoSize, out _, out var width, out var height);
_userManager.SaveUserPhoto(userID, data);
SetUserPhotoThumbnailSettings(userID, width, height);
_userPhotoManagerCache.ClearCache(userID, _tenantManager.GetCurrentTenant().Id);
// _userPhotoManagerCache.ClearCache(userID, _tenantManager.GetCurrentTenant().Id);
}
@ -561,8 +561,7 @@ public class UserPhotoManager
{
_userManager.SaveUserPhoto(userID, data);
SetUserPhotoThumbnailSettings(userID, width, height);
_userPhotoManagerCache.ClearCache(userID, _tenantManager.GetCurrentTenant().Id);
// _userPhotoManagerCache.ClearCache(userID, _tenantManager.GetCurrentTenant().Id);
}
var store = GetDataStore();