fixed publish issues
This commit is contained in:
parent
6d9523ff39
commit
d7a35bed78
12 changed files with 27 additions and 24 deletions
|
@ -7,6 +7,6 @@
|
|||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none",
|
||||
"DownloadAddress": "C:\\lbry\\speech\\hosted_content"
|
||||
"PublishUploadPath": "none"
|
||||
}
|
||||
}
|
|
@ -6,6 +6,7 @@
|
|||
"googleId": "UA-100747990-1"
|
||||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none"
|
||||
"MySqlConnectionUri": "none",
|
||||
"PublishUploadPath": "C:\\lbry\\speech\\hosted_content"
|
||||
}
|
||||
}
|
|
@ -7,6 +7,6 @@
|
|||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none",
|
||||
"DownloadAddress": "~/Downloads/"
|
||||
"PublishUploadPath": "~/Downloads/"
|
||||
}
|
||||
}
|
|
@ -7,6 +7,6 @@
|
|||
},
|
||||
"Database": {
|
||||
"MySqlConnectionUri": "none",
|
||||
"DownloadAddress": "~/Downloads/"
|
||||
"PublishUploadPath": "~/Downloads/"
|
||||
}
|
||||
}
|
|
@ -5,21 +5,22 @@ var errorHandlers = require("../helpers/libraries/errorHandlers.js");
|
|||
|
||||
var walledAddress = config.get('WalletConfig.lbryAddress');
|
||||
|
||||
function createPublishParams(name, filePath, license, nsfw) {
|
||||
function createPublishParams(claim, filePath, license, nsfw) {
|
||||
console.log("nsfw:", nsfw, typeof nsfw);
|
||||
var publishParams = {
|
||||
"name": name,
|
||||
"name": claim,
|
||||
"file_path": filePath,
|
||||
"bid": 0.01,
|
||||
"metadata": {
|
||||
"description": name + " published via spee.ch",
|
||||
"title": name,
|
||||
"description": claim + " published via spee.ch",
|
||||
"title": claim,
|
||||
"author": "spee.ch",
|
||||
"language": "en",
|
||||
"license": license,
|
||||
"nsfw": (nsfw.toLowerCase() === "true")
|
||||
"nsfw": (nsfw.toLowerCase() === "on")
|
||||
},
|
||||
"claim_address": walledAddress,
|
||||
"change_address": walledAddress //requires daemon 0.12.2rc1 or above
|
||||
"change_address": walledAddress
|
||||
};
|
||||
return publishParams;
|
||||
}
|
||||
|
@ -32,19 +33,19 @@ function deleteTemporaryFile(filePath) {
|
|||
}
|
||||
|
||||
module.exports = {
|
||||
publish: function(name, filePath, fileType, license, nsfw, socket, visitor) {
|
||||
publish: function(claim, fileName, filePath, fileType, license, nsfw, socket, visitor) {
|
||||
// update the client
|
||||
socket.emit("publish-status", "Your image is being published (this might take a second)...");
|
||||
// send to analytics
|
||||
visitor.event("Publish Route", "Publish Request", filePath).send();
|
||||
// create the publish object
|
||||
var publishParams = createPublishParams(name, filePath, license, nsfw);
|
||||
var publishParams = createPublishParams(claim, filePath, license, nsfw);
|
||||
// get a promise to publish
|
||||
lbryApi.publishClaim(publishParams, fileType)
|
||||
lbryApi.publishClaim(publishParams, fileName, fileType)
|
||||
.then(function(result){
|
||||
visitor.event("Publish Route", "Publish Success", filePath).send();
|
||||
console.log("publish promise success. Tx info:", result)
|
||||
socket.emit("publish-complete", {name: name, result: result});
|
||||
socket.emit("publish-complete", {name: claim, result: result});
|
||||
})
|
||||
.catch(function(error){
|
||||
visitor.event("Publish Route", "Publish Failure", filePath).send();
|
||||
|
|
|
@ -2,6 +2,6 @@ var getAllFreePublicClaims = require("../helpers/functions/getAllFreePublicClaim
|
|||
|
||||
module.exports = {
|
||||
getAllClaims: function(claimName){
|
||||
return getAllFreePublicClaims(claimName); // to-do: does this need to be returned?
|
||||
return getAllFreePublicClaims(claimName);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
module.exports = function(claim){
|
||||
console.log(">> isFreePublicClaim? claim:", claim);
|
||||
console.log(">> check: isFreePublicClaim?");
|
||||
if (((claim.value.stream.metadata.license.indexOf("Public Domain") != -1 ) || (claim.value.stream.metadata.license.indexOf("Creative Commons") != -1 ))
|
||||
&&
|
||||
(!claim.value.stream.metadata.fee || claim.value.stream.metadata.fee.amount === 0)) {
|
||||
|
|
|
@ -2,20 +2,20 @@ var axios = require('axios');
|
|||
var db = require("../../models");
|
||||
|
||||
module.exports = {
|
||||
publishClaim: function(publishParams, fileType){
|
||||
publishClaim: function(publishParams, fileName, fileType){
|
||||
var deferred = new Promise(function(resolve, reject){
|
||||
console.log(">> lbryApi >> publishClaim:", publishParams);
|
||||
axios.post('http://localhost:5279/lbryapi', {
|
||||
"method": "publish",
|
||||
"params": publishParams
|
||||
}).then(function (response) {
|
||||
console.log(">> 'publish' success");
|
||||
console.log(">> 'publish' success", response);
|
||||
var result = response.data.result;
|
||||
db.File.create({
|
||||
name: publishParams.name,
|
||||
claim_id: result.claim_id,
|
||||
outpoint: result.txid + ":" + result.nout,
|
||||
file_name: "test",
|
||||
file_name: fileName,
|
||||
file_path: publishParams.file_path,
|
||||
file_type: fileType,
|
||||
nsfw: publishParams.metadata.nsfw,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
var errorHandlers = require("../helpers/libraries/errorHandlers.js");
|
||||
var showController = require("../controllers/serveController.js");
|
||||
var showController = require("../controllers/showController.js");
|
||||
|
||||
module.exports = function(app, ua, googleAnalyticsId){
|
||||
// route to fetch all free public claims
|
||||
|
|
|
@ -23,12 +23,13 @@ module.exports = function(app, siofu, hostedContentPath, ua, googleAnalyticsId)
|
|||
socket.emit("publish-status", event.error)
|
||||
});
|
||||
uploader.on("saved", function(event){
|
||||
console.log("saved ", event.file.name, "deets:", event.file);
|
||||
console.log("uploaded ", event.file.name);
|
||||
if (event.file.success){
|
||||
socket.emit("publish-status", "file upload successfully completed");
|
||||
publishController.publish(event.file.meta.name, event.file.pathName, event.file.meta.type, event.file.meta.license, event.file.meta.nsfw, socket, visitor)
|
||||
publishController.publish(event.file.meta.name, event.file.name, event.file.pathName, event.file.meta.type, event.file.meta.license, event.file.meta.nsfw, socket, visitor)
|
||||
} else {
|
||||
socket.emit("publish-failure", "file uploaded, but with errors")
|
||||
// to-do: remove the file
|
||||
};
|
||||
});
|
||||
// handle disconnect
|
||||
|
|
|
@ -10,7 +10,7 @@ var config = require('config');
|
|||
var ua = require('universal-analytics');
|
||||
|
||||
var googleAnalyticsId = config.get('AnalyticsConfig.googleId');
|
||||
var hostedContentPath = config.get('Database.DownloadAddress');
|
||||
var hostedContentPath = config.get('Database.PublishUploadPath');
|
||||
|
||||
// set port
|
||||
var PORT = 3000;
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<img class="all-claims-img" src="https://spee.ch/{{this.name}}/{{this.claim_id}}" />
|
||||
<div class="card card-block">
|
||||
<p>claim_id: {{this.claim_id}}</p>
|
||||
<p>direct link <a href="https://spee.ch/{{this.name}}/{{this.claim_id}}">here</a></p>
|
||||
<p>direct link <a href="/{{this.name}}/{{this.claim_id}}">here</a></p>
|
||||
<p>author: {{this.value.stream.metadata.author}}</p>
|
||||
<p>description: {{this.value.stream.metadata.description}}</p>
|
||||
<p>license: {{this.value.stream.metadata.license}}</p>
|
||||
|
|
Loading…
Add table
Reference in a new issue