updated gallery code

This commit is contained in:
ojack
2023-06-04 17:42:31 +03:00
parent a5d27e1234
commit 7aa31aba26
5 changed files with 212 additions and 10487 deletions

View File

@@ -1,4 +1,7 @@
# Changelog # Changelog
## [1.3.10] - 2023-06-04
- disabled all gallery-related code, hopefully will help editor crashing
## [1.3.9] - 2023-05-30 ## [1.3.9] - 2023-05-30
### Added ### Added
- documentation for self-generating certificates - documentation for self-generating certificates

View File

@@ -43,7 +43,7 @@ io.on('connection', function (socket) {
var thisRoom = null var thisRoom = null
socket.on('join', function (room, _userData) { socket.on('join', function (room, _userData) {
thisRoom = room thisRoom = room
console.log('user', JSON.stringify(_userData)) // console.log('user', JSON.stringify(_userData))
if (_userData.uuid) { if (_userData.uuid) {
userFromSocket[socket.id] = _userData.uuid userFromSocket[socket.id] = _userData.uuid
socketFromUser[_userData.uuid] = socket.id socketFromUser[_userData.uuid] = socket.id

View File

@@ -19,7 +19,7 @@ module.exports = (app) => {
var sketches = [] var sketches = []
db.count({}, function (err, count) { db.count({}, function (err, count) {
console.log("There are " + count + " entries in the database"); // console.log("There are " + count + " entries in the database");
if(err) console.log("There's a problem with the database: ", err); if(err) console.log("There's a problem with the database: ", err);
else if(count<=0){ // empty database so needs populating else if(count<=0){ // empty database so needs populating
// default users inserted in the database // default users inserted in the database
@@ -82,47 +82,51 @@ module.exports = (app) => {
//const storage = multer.memoryStorage(); //const storage = multer.memoryStorage();
var storage = multer.diskStorage({ // var storage = multer.diskStorage({
destination: function (req, file, cb) { // destination: function (req, file, cb) {
cb(null, path.join(__dirname + '/uploads/')) // cb(null, path.join(__dirname + '/uploads/'))
}, // },
filename: function (req, file, cb) { // filename: function (req, file, cb) {
cb(null, file.originalname + '.png') // cb(null, file.originalname + '.png')
} // }
}) // })
// console.log('envv', process.env) // console.log('envv', process.env)
app.post('/image', (req, res) => {
// let data = ÷\ß\req.body;
res.send('gallery is currently disabled, stay tuned for updates');
})
if(process.env.CONSUMER_KEY) { if(process.env.CONSUMER_KEY) {
const upload = multer({ storage: storage }); // const upload = multer({ storage: storage });
app.post("/image", upload.single('previewImage'), (req, res) => { // app.post("/image", upload.single('previewImage'), (req, res) => {
const updatedNameString = req.query.name.replace('@', '{@}') // // const updatedNameString = req.query.name.replace('@', '{@}')
findParentTweet(req.query.sketch_id, function(err, tweet_id){ // // findParentTweet(req.query.sketch_id, function(err, tweet_id){
if(err) console.log(err) // // if(err) console.log(err)
// if(tweet_id !== null) console.log("FOUND PARENT", tweet_id) // // // if(tweet_id !== null) console.log("FOUND PARENT", tweet_id)
/* uncomment below to upload to twitter */ // // /* uncomment below to upload to twitter */
tweet.post_chunked({ // // tweet.post_chunked({
imagePath: req.file.path, // // imagePath: req.file.path,
url: req.query.url, // // url: req.query.url,
name: updatedNameString, // // name: updatedNameString,
parent_tweet: tweet_id // // parent_tweet: tweet_id
}, function(err, data){ // // }, function(err, data){
if(err){ // // if(err){
console.log('ERROR POSTING IMAGE', err) // // console.log('ERROR POSTING IMAGE', err)
} else { // // } else {
// console.log('tweet id is ', data.id_str) // // // console.log('tweet id is ', data.id_str)
res.status(200).send( 'https://twitter.com/hydra_patterns/status/' + data.id_str ); // // res.status(200).send( 'https://twitter.com/hydra_patterns/status/' + data.id_str );
db.update( // // db.update(
{ _id: req.query.sketch_id }, // // { _id: req.query.sketch_id },
{ $set: { tweet_id: data.id_str, bitly_hash: data.bitly_hash } // // { $set: { tweet_id: data.id_str, bitly_hash: data.bitly_hash }
}, function (err, numReplaced) {}); // // }, function (err, numReplaced) {});
} // // }
}) // // })
}) // // })
}); // });
function findParentTweet(sketch_id, callback) { function findParentTweet(sketch_id, callback) {
db.find({_id: sketch_id}, function (err, entries){ db.find({_id: sketch_id}, function (err, entries){
@@ -163,7 +167,7 @@ module.exports = (app) => {
if (err) { if (err) {
console.log(err) console.log(err)
} else { } else {
console.log('Media saved!') // console.log('Media saved!')
const descriptionText = body.title const descriptionText = body.title
// uploadMedia(descriptionText, fileName) // uploadMedia(descriptionText, fileName)
} }

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "hydra", "name": "hydra",
"version": "1.3.9", "version": "1.3.10",
"description": "", "description": "",
"main": "server.js", "main": "server.js",
"scripts": { "scripts": {