Skip to content
This repository was archived by the owner on Jun 18, 2022. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions app/controllers/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,22 @@ module.exports = function(app) {

query += " ORDER BY rating DESC NULLS LAST";

db.tx(t => {
return t.batch([
t.any(query)
]);
})
db.any(query)
.then(data => {
for (var i = 0; i < data[0].length; i++) {
data[0][i].img = `data:image/png;base64,${
new Buffer(data[0][i].img, 'hex').toString('base64')
for (var i = 0; i < data.length; i++) {
data[i].img = `data:image/png;base64,${
new Buffer(data[i].img, 'hex').toString('base64')
}`;
}

res.render('media-listing', {
medias: data[0],
medias: data,
title: 'Browse'
});
});
})
.post(isAdmin, upload.single('image'), (req, res) => {
db.tx(t => {

var query;

switch (req.body.type) {
Expand Down Expand Up @@ -103,8 +99,8 @@ module.exports = function(app) {
]);
break;
}
return t.batch([query]);
}).then(() => {
db.none(query)
.then(() => {
res.redirect('/m');
}).catch(err => {
console.error(err);
Expand Down