summaryrefslogtreecommitdiff
path: root/bucky/db/index.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-12-15 02:52:15 +0100
committerJules Laplace <julescarbon@gmail.com>2017-12-15 02:52:15 +0100
commitcc585396a85e3107bb7b4298098b84b738919c8f (patch)
treebd74ed6e090231d472e022f487748c5f7eb46aa4 /bucky/db/index.js
parent1466563673ffe6c41ec9a18bf98565b8562ee4f3 (diff)
more middleware
Diffstat (limited to 'bucky/db/index.js')
-rw-r--r--bucky/db/index.js7
1 files changed, 7 insertions, 0 deletions
diff --git a/bucky/db/index.js b/bucky/db/index.js
index 36e5c93..652f723 100644
--- a/bucky/db/index.js
+++ b/bucky/db/index.js
@@ -14,6 +14,13 @@ var User = db.User = bookshelf.Model.extend({
var Thread = db.Thread = bookshelf.Model.extend({
tableName: 'threads',
hasTimestamps: false,
+ checkPrivacy: function(user){
+ if (this.get('privacy') === 0) return true
+ let username = user.get('username')
+ if (this.get('username') === username) return true
+ let allowed = this.get('allowed').split(',')
+ if (allowed.findIndex(username) !== -1) return true
+ }
})
var ThreadUser = db.ThreadUser = bookshelf.Model.extend({
tableName: 'thread_users',