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

BC-5461 - fix personal file page error #4453

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions src/services/fileStorage/proxy-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,10 +422,10 @@ const signedUrlService = {
throw new NotFound('File seems not to be there.');
}

// deprecated: author check via file.permissions[0].refId is deprecated and will be removed in the next release
// deprecated: author check via file.permissions[0]?.refId is deprecated and will be removed in the next release
const creatorId =
fileObject.creator ||
(fileObject.permissions[0].refPermModel !== 'user' ? userId : fileObject.permissions[0].refId);
(fileObject.permissions[0]?.refPermModel !== 'user' ? userId : fileObject.permissions[0]?.refId);

if (download && fileObject.securityCheck && fileObject.securityCheck.status === SecurityCheckStatusTypes.BLOCKED) {
throw new Forbidden('File access blocked by security check.');
Expand Down Expand Up @@ -456,11 +456,11 @@ const signedUrlService = {
throw new NotFound('File seems not to be there.');
}

// deprecated: author check via file.permissions[0].refId is deprecated and will be removed in the next release
// deprecated: author check via file.permissions[0]?.refId is deprecated and will be removed in the next release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vor 3 Jahren hat jemand rein geschrieben das es im nächsten Release deprecated ist. Müssen wir uns sorgen machen das es immer noch verwendet wird bzw. wird es verwendet?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣

const creatorId =
fileObject.creator || fileObject.permissions[0].refPermModel !== 'user'
fileObject.creator || fileObject.permissions[0]?.refPermModel !== 'user'
? userId
: fileObject.permissions[0].refId;
: fileObject.permissions[0]?.refId;

return canRead(userId, id)
.then(() =>
Expand Down Expand Up @@ -899,8 +899,8 @@ const filePermissionService = {
const { refOwnerModel, owner } = fileObj;
const rolePermissions = fileObj.permissions.filter(({ refPermModel }) => refPermModel === 'role');
const rolePromises = rolePermissions.map(({ refId }) => RoleModel.findOne({ _id: refId }).lean().exec());
// deprecated: author check via file.permissions[0].refId is deprecated and will be removed in the next release
const isFileCreator = equalIds(fileObj.creator || fileObj.permissions[0].refId, userId);
// deprecated: author check via file.permissions[0]?.refId is deprecated and will be removed in the next release
const isFileCreator = equalIds(fileObj.creator || fileObj.permissions[0]?.refId, userId);

const actionMap = {
user: () => {
Expand Down
4 changes: 2 additions & 2 deletions src/services/fileStorage/utils/filePermissionHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const checkTeamPermission = async ({ user, file, permission }) => {
rolesToTest = rolesToTest.concat(roleIndex[roleId].roles || []);
}

// deprecated: author check via file.permissions[0].refId is deprecated and will be removed in the next release
// deprecated: author check via file.permissions[0]?.refId is deprecated and will be removed in the next release
const { role: creatorRole } = file.owner.userIds.find((_) =>
equalIds(_.userId, file.creator || file.permissions[0].refId)
equalIds(_.userId, file.creator || file.permissions[0]?.refId)
);

const findRole = (roleId) => (roles) => roles.findIndex((r) => equalIds(r._id, roleId)) > -1;
Expand Down