35 lines
917 B
JavaScript
35 lines
917 B
JavaScript
|
const { NodeDescriptorType } = require('../../enum')
|
||
|
const { Errors } = require('../../shared')
|
||
|
|
||
|
module.exports = exports = async (message, di) => {
|
||
|
const Node = di.models.get('fs:Node')
|
||
|
const { descriptor } = message.data()
|
||
|
|
||
|
if ( !descriptor || !message.socket.session.file_descriptors[descriptor] ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NoSuchDescriptor)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
const node = await Node.findOne({
|
||
|
deleted: false,
|
||
|
descriptor_type: NodeDescriptorType.File,
|
||
|
uuid: message.socket.session.file_descriptors[descriptor],
|
||
|
})
|
||
|
|
||
|
if ( !node ) {
|
||
|
return message.send_response(
|
||
|
message.fresh().error(Errors.NodeDoesNotExist)
|
||
|
)
|
||
|
}
|
||
|
|
||
|
const data = {
|
||
|
node_uuid: node.uuid,
|
||
|
socket_uuid: message.socket.uuid,
|
||
|
}
|
||
|
|
||
|
message.send_response(
|
||
|
message.fresh().data(data)
|
||
|
)
|
||
|
}
|