summaryrefslogtreecommitdiff
path: root/bucky/app/bucky.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-15 05:36:50 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-15 05:36:50 +0100
commit7ad469291c015b33a2d20587db26b9621ed82d00 (patch)
tree83e2a56822033a638d03ff7ddf4bfee3181631e6 /bucky/app/bucky.js
parentcc585396a85e3107bb7b4298098b84b738919c8f (diff)
sort file list by name or date, updates audio player
Diffstat (limited to 'bucky/app/bucky.js')
-rw-r--r--bucky/app/bucky.js59
1 files changed, 41 insertions, 18 deletions
diff --git a/bucky/app/bucky.js b/bucky/app/bucky.js
index ec0ab8c..25de991 100644
--- a/bucky/app/bucky.js
+++ b/bucky/app/bucky.js
@@ -184,6 +184,8 @@ var bucky = module.exports = {
return res.sendStatus(500)
}
var keyword = util.sanitize(req.body.keyword || "")
+ var privacy = parseInt(req.body.privacy) || 0
+ var allowed = util.sanitize(req.body.allowed || "")
var settings
if (typeof req.body.settings === 'object') {
try {
@@ -194,29 +196,48 @@ var bucky = module.exports = {
if (! settings) {
return res.sendStatus(500)
}
+console.log(privacy)
res.thread.set('title', title)
res.thread.set('keyword', keyword)
res.thread.set('color', util.sanitize(req.body.color || 'blue'))
res.thread.set('revision', res.thread.get('revision')+1)
res.thread.set('settings', settings)
- res.thread.save().then( () => next() )
- },
- ensureInterestedUsers: function(req, res, next){
- // given a thread, find people who might be interested in it
- // - other people who have been in threads with you
- // - other people who have posted on the keyword
- // for now though, just show the last 20 people who have logged in..
- db.getLastlog(21).then( (users) => {
- res.interestedUsers = users
- next()
- }).catch( () => {
- res.interestedUsers = []
+ res.thread.set('privacy', privacy)
+ res.thread.set('allowed', allowed)
+ res.thread.save()
+ .then( () => next() )
+ .catch(err => {
+ console.error(err)
next()
})
},
- ensureThreadUsers: function(req, res, next) {
- db.getThreadUsers(res.thread.get('id')).then(thread_users => {
- res.thread_users = thread_users
+// ensureInterestedUsers: function(req, res, next){
+// // given a thread, find people who might be interested in it
+// // - other people who have been in threads with you
+// // - other people who have posted on the keyword
+// // for now though, just show the last 20 people who have logged in..
+// db.getLastlog(21).then( (users) => {
+// res.interestedUsers = users
+// next()
+// }).catch( () => {
+// res.interestedUsers = []
+// next()
+// })
+// },
+// ensureThreadUsers: function(req, res, next) {
+// db.getThreadUsers(res.thread.get('id')).then(thread_users => {
+// res.thread_users = thread_users
+// next()
+// })
+// },
+ checkUsernames: function(req, res, next) {
+ if (! req.body.usernames) return res.sendStatus(500)
+ db.checkUsernames(req.body.usernames).then( (users) => {
+ res.usernames = users.map(user => user.username)
+ next()
+ }).catch((err) => {
+ console.log(err)
+ res.usernames = []
next()
})
},
@@ -370,6 +391,7 @@ var bucky = module.exports = {
reject(err)
},
success: function(url){
+ console.log("file >", url)
var data = {
thread: res.thread.get('id'),
username: req.user.get('username'),
@@ -436,7 +458,7 @@ var bucky = module.exports = {
res.sendStatus({ error: 'Problem uploading avatar.' })
},
success: function(url){
- console.log(">", url)
+ console.log("avatar >", url)
res.user.set('avatar', url)
next()
}
@@ -461,7 +483,7 @@ var bucky = module.exports = {
next()
},
checkThreadPrivacy: function(req, res, next) {
- if (res.thread.checkPrivacy(req.user)) {
+ if (! res.thread.checkPrivacy(req.user)) {
return res.sendStatus(500)
}
next()
@@ -479,10 +501,11 @@ var bucky = module.exports = {
}
next()
},
- checkThreadsPrivacy: function(req, res, next) {
+ filterPrivateThreads: function(req, res, next) {
res.threads = res.threads.filter(thread => {
return thread.checkPrivacy(req.user)
})
+ next()
},
/* MAIL */