added 'outpoint' to Files model'

This commit is contained in:
bill bittner 2017-06-15 15:56:40 -07:00
parent 50d65de6a4
commit 99413abdf6
3 changed files with 31 additions and 26 deletions

View file

@ -26,11 +26,10 @@ module.exports = {
"params": { "uri": uri, "timeout": 20} "params": { "uri": uri, "timeout": 20}
}).then(function (getResponse) { }).then(function (getResponse) {
console.log(">> 'get' success", getResponse.data); console.log(">> 'get' success", getResponse.data);
//check to make sure the daemon didn't just time out (or otherwise send an error that appears to be a success response) //check to make sure the daemon didn't just time out
if (getResponse.data.result.error){ if (getResponse.data.result.error){
reject(getResponse.data.result.error); reject(getResponse.data.result.error);
} }
// resolve the promise with the download path for the claim we got
/* /*
note: put in a check to make sure we do not resolve until the download is actually complete (response.data.completed === true) note: put in a check to make sure we do not resolve until the download is actually complete (response.data.completed === true)
*/ */
@ -40,12 +39,13 @@ module.exports = {
path: getResponse.data.result.download_path, path: getResponse.data.result.download_path,
file_type: getResponse.data.result.mime_type, file_type: getResponse.data.result.mime_type,
claim_id: getResponse.data.result.claim_id, claim_id: getResponse.data.result.claim_id,
outpoint: getResponse.data.result.outpoint,
nsfw: getResponse.data.result.metadata.stream.metadata.nsfw, nsfw: getResponse.data.result.metadata.stream.metadata.nsfw,
}).catch(function(error){ }).catch(function(error){
console.log('an error occurred when writing to the MySQL database. Check the logs.'); console.log('an error occurred when writing to the MySQL database. Check the logs.');
}); });
// resolve the promise // resolve the promise
resolve(getResponse.data); //to do: return the result resolve(getResponse.data);
}).catch(function(getUriError){ }).catch(function(getUriError){
console.log(">> 'get' error"); console.log(">> 'get' error");
// reject the promise with an error message // reject the promise with an error message

View file

@ -61,6 +61,7 @@ module.exports = {
path: filePath, path: filePath,
file_type: fileType, file_type: fileType,
claim_id: data.result.claim_id, claim_id: data.result.claim_id,
outpoint: getResponse.data.result.outpoint,
nsfw: nsfw, nsfw: nsfw,
}).catch(function(error){ }).catch(function(error){
console.log('an error occurred when writing to the MySQL database. Check the logs.'); console.log('an error occurred when writing to the MySQL database. Check the logs.');

View file

@ -1,27 +1,31 @@
module.exports = function(sequelize, DataTypes){ module.exports = function(sequelize, DataTypes){
var File = sequelize.define("File", { var File = sequelize.define("File", {
name: { name: {
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: false, allowNull: false
validate: { },
len: [1] path: {
} type: DataTypes.STRING,
}, allowNull: false
path: { },
type: DataTypes.STRING file_type: {
}, type: DataTypes.STRING,
file_type: { },
type: DataTypes.STRING claim_id: {
}, type: DataTypes.STRING,
claim_id: { allowNull: false
type: DataTypes.STRING },
}, outpoint: {
nsfw: { type: DataTypes.STRING,
type: DataTypes.BOOLEAN, allowNull: false
defaultValue: false },
} nsfw: {
}, { type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
}
}, {
freezeTableName: true freezeTableName: true
}); });
return File; return File;
} }