send/app/routes/download.js
2018-08-03 16:10:00 -07:00

24 lines
581 B
JavaScript

const preview = require('../pages/preview');
const password = require('../pages/password');
module.exports = function(state, emit) {
if (!state.fileInfo) {
emit('getPasswordExist', { id: state.params.id });
return;
}
state.fileInfo.id = state.params.id;
state.fileInfo.secretKey = state.params.key;
if (!state.transfer && !state.fileInfo.requiresPassword) {
emit('getMetadata');
}
if (state.transfer) {
return preview(state, emit);
}
if (state.fileInfo.requiresPassword && !state.fileInfo.password) {
return password(state, emit);
}
};