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
[backend/frontend] Improve auditing to split file read and file download (#5005) #5006
Conversation
const publishFileDownload = async (executeContext, auth, file) => { | ||
const { filename, entity_id } = file.metaData; | ||
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined; | ||
const data = buildContextDataForFile(entity, file.id, filename); | ||
await publishUserAction({ | ||
user: auth, | ||
event_type: 'file', | ||
event_access: 'extended', | ||
event_scope: 'download', | ||
context_data: data | ||
}); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just have one function taking the scope download
or read
in parameter to avoid duplicates ? In a same way checkFileAccess
has been made
const publishFileDownload = async (executeContext, auth, file) => { | |
const { filename, entity_id } = file.metaData; | |
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined; | |
const data = buildContextDataForFile(entity, file.id, filename); | |
await publishUserAction({ | |
user: auth, | |
event_type: 'file', | |
event_access: 'extended', | |
event_scope: 'download', | |
context_data: data | |
}); | |
}; | |
const publishFile = async (executeContext, auth, file, event_scope) => { | |
const { filename, entity_id } = file.metaData; | |
const entity = entity_id ? await internalLoadById(executeContext, auth, entity_id) : undefined; | |
const data = buildContextDataForFile(entity, file.id, filename); | |
await publishUserAction({ | |
user: auth, | |
event_type: 'file', | |
event_access: 'extended', | |
event_scope, | |
context_data: data | |
}); | |
}; | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the comment. I will merge as it is and will be part of future refactor.
2b23830
to
9f7ab5b
Compare
See #5005