fix bug 62268

This commit is contained in:
NikitaVashchuk 2023-04-26 17:08:35 +05:00
parent 2369fa9a54
commit aaf7885f50
2 changed files with 23 additions and 51 deletions

View File

@ -2559,11 +2559,11 @@ public class FileStorageService<T> //: IFileStorageService
EventType eventType;
if(usersRecords.Any() && ace.Access != FileShare.None && recordEntrys.Contains(entry.Id.ToString()))
if (usersRecords.Any() && ace.Access != FileShare.None && recordEntrys.Contains(entry.Id.ToString()))
{
eventType = EventType.Update;
}
else if(!usersRecords.Any() || !recordEntrys.Contains(entry.Id.ToString()))
else if (!usersRecords.Any() || !recordEntrys.Contains(entry.Id.ToString()))
{
eventType = EventType.Create;
}
@ -2582,10 +2582,10 @@ public class FileStorageService<T> //: IFileStorageService
{
foreach (var e in eventTypes)
{
var user = e.User;
var user = e.User;
var name = user.DisplayUserName(false, _displayUserSettingsHelper);
var access = e.Access;
var access = e.Access;
if (entry.FileEntryType == FileEntryType.Folder && DocSpaceHelper.IsRoom(((Folder<T>)entry).FolderType))
{
@ -2680,7 +2680,7 @@ public class FileStorageService<T> //: IFileStorageService
{
var linkExist = (await _fileSecurity.GetSharesAsync(room))
.Any(r => r.Subject == linkId && r.SubjectType == SubjectType.InvitationLink);
if (linkExist)
{
messageAction = MessageAction.RoomLinkUpdated;
@ -2921,46 +2921,7 @@ public class FileStorageService<T> //: IFileStorageService
continue;
}
if (!await _fileSecurity.CanReadAsync(file, recipient.Id))
{
if (!canShare.Value)
{
continue;
}
try
{
var aces = new List<AceWrapper>
{
new AceWrapper
{
Access = FileShare.Read,
Id = recipient.Id,
SubjectGroup = false,
}
};
var (changed, _) = await _fileSharingAceHelper.SetAceObjectAsync(aces, file, false, null, null);
showSharingSettings |= changed;
if (showSharingSettings)
{
foreach (var ace in aces)
{
_ = _filesMessageService.Send(file, GetHttpHeaders(), MessageAction.FileUpdatedAccessFor, file.Title, _userManager.GetUsers(ace.Id).DisplayUserName(false, _displayUserSettingsHelper), GetAccessString(ace.Access));
}
}
recipients.Add(recipient.Id);
}
catch (Exception e)
{
throw GenerateException(e);
}
}
else
{
recipients.Add(recipient.Id);
}
recipients.Add(recipient.Id);
}
var fileLink = _filesLinkUtility.GetFileWebEditorUrl(file.Id);
@ -2980,7 +2941,7 @@ public class FileStorageService<T> //: IFileStorageService
{
await _notifyClient.SendEditorMentions(file, fileLink, recipients, message);
}
catch(Exception ex)
catch (Exception ex)
{
_logger.ErrorWithException(ex);
}

View File

@ -25,8 +25,8 @@
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
using Actions = ASC.Web.Studio.Core.Notify.Actions;
using Context = ASC.Notify.Context;
using ConfigurationConstants = ASC.Core.Configuration.Constants;
using Context = ASC.Notify.Context;
namespace ASC.Files.Core.Services.NotifyService;
@ -46,6 +46,7 @@ public class NotifyClient
private readonly Context _notifyContext;
private readonly NotifyEngineQueue _notifyEngineQueue;
private readonly RoomsNotificationSettingsHelper _roomsNotificationSettingsHelper;
private readonly FileSecurity _fileSecurity;
public NotifyClient(
Context notifyContext,
@ -60,7 +61,8 @@ public class NotifyClient
UserManager userManager,
TenantManager tenantManager,
StudioNotifyHelper studioNotifyHelper,
RoomsNotificationSettingsHelper roomsNotificationSettingsHelper)
RoomsNotificationSettingsHelper roomsNotificationSettingsHelper,
FileSecurity fileSecurity)
{
_notifyContext = notifyContext;
_notifyEngineQueue = notifyEngineQueue;
@ -75,6 +77,7 @@ public class NotifyClient
_tenantManager = tenantManager;
_studioNotifyHelper = studioNotifyHelper;
_roomsNotificationSettingsHelper = roomsNotificationSettingsHelper;
_fileSecurity = fileSecurity;
}
public void SendDocuSignComplete<T>(File<T> file, string sourceTitle)
@ -208,12 +211,20 @@ public class NotifyClient
var recipientsProvider = _notifySource.GetRecipientsProvider();
var folderDao = _daoFactory.GetFolderDao<T>();
var folderDao = _daoFactory.GetFolderDao<int>();
var (roomId, roomTitle) = await folderDao.GetParentRoomInfoFromFileEntryAsync(file);
var roomUrl = _pathProvider.GetRoomsUrl(roomId);
var roomUrl = _pathProvider.GetRoomsUrl(roomId);
var room = await folderDao.GetFolderAsync(roomId);
foreach (var recipientId in recipientIds)
{
if (!await _fileSecurity.CanReadAsync(room, recipientId))
{
continue;
};
var u = _userManager.GetUsers(recipientId);
if (!_studioNotifyHelper.IsSubscribedToNotify(u, Actions.RoomsActivity))
@ -221,7 +232,7 @@ public class NotifyClient
continue;
}
var recipient = recipientsProvider.GetRecipient(u.Id.ToString());
var recipient = recipientsProvider.GetRecipient(recipientId.ToString());
var disabledRooms = _roomsNotificationSettingsHelper.GetDisabledRoomsForUser(recipientId);