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
## [1.3.10] - 2023-06-04
- disabled all gallery-related code, hopefully will help editor crashing
## [1.3.9] - 2023-05-30
### Added
- documentation for self-generating certificates

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

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