server/app/ws/routes/fs.getattr.js

27 lines
667 B
JavaScript
Raw Permalink Normal View History

2020-11-27 01:57:37 +00:00
const { Errors } = require('../../shared')
module.exports = exports = async (message, di) => {
const Node = di.models.get('fs:Node')
const { path } = message.data()
let data
if ( path === '/' ) {
const root = await Node.get_root()
data = root.to_api()
} else {
const node = await Node.get_path(path, message.socket.session.overlay_name || 'mainline')
if ( !node ) {
return message.send_response(
message.fresh().error(Errors.NodeDoesNotExist)
)
}
data = node.to_api()
}
message.send_response(
message.fresh().data({ node: data })
)
}