mirror of
https://github.com/wassname/talk.git
synced 2026-07-26 13:37:38 +08:00
@@ -36,7 +36,6 @@
|
||||
"yoda": [1],
|
||||
"no-path-concat": [2],
|
||||
"no-process-exit": [2],
|
||||
"camelcase": [1],
|
||||
"eol-last": [1],
|
||||
"no-continue": [1],
|
||||
"no-nested-ternary": [1],
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
### Steps to reproduce behavior
|
||||
@@ -0,0 +1,9 @@
|
||||
## What does this PR do?
|
||||
|
||||
## How do I test this PR?
|
||||
|
||||
- click a button
|
||||
- view the cat
|
||||
- see the cat meow
|
||||
|
||||
@coralproject/tech
|
||||
@@ -3,3 +3,4 @@ npm-debug.log
|
||||
dist
|
||||
.DS_Store
|
||||
*.iml
|
||||
.env
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
const Setting = require('../models/setting');
|
||||
const defaults = {id: '1', moderation: 'pre'};
|
||||
|
||||
Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}).then(() => {
|
||||
console.log('created settings object.');
|
||||
process.exit();
|
||||
}).catch(console.error);
|
||||
@@ -0,0 +1,30 @@
|
||||
These are some settings we're planning on implementing in the future.
|
||||
I'm keeping them in this file for reference
|
||||
|
||||
```javascript
|
||||
anonymous_users: {type: Boolean, default: false},
|
||||
block_mute_enabled: {type: Boolean, default: false},
|
||||
comment_count: {type: Boolean, default: false},
|
||||
comment_editing_enabled: {type: Boolean, default: false},
|
||||
comments_hidden: {type: Boolean, default: false},
|
||||
community_guidelines: {type: Boolean, default: false},
|
||||
detailed_flags: {type: Boolean, default: false},
|
||||
emojis_enabled: {type: Boolean, default: false},
|
||||
following: {type: Boolean, default: false},
|
||||
likes_enabled: {type: Boolean, default: false},
|
||||
mentions: {type: Boolean, default: false},
|
||||
nested_replies: {type: Boolean, default: false},
|
||||
notification_timeout: {type: Number, default: 4500},
|
||||
permalinks: {type: Boolean, default: false},
|
||||
post_button_text: {type: String, default: 'Post'},
|
||||
pseudonyms: {type: Boolean, default: false},
|
||||
public_profile: {type: Boolean, default: false},
|
||||
reactions_enabled: {type: Boolean, default: false},
|
||||
reply_button_text: {type: String, default: 'Reply'},
|
||||
rich_content: {type: Boolean, default: false},
|
||||
show_staff_picks: {type: Boolean, default: false},
|
||||
up_down_voting: {type: Boolean, default: false},
|
||||
user_badges: {type: Boolean, default: false},
|
||||
user_mods_enabled: {type: Boolean, default: false},
|
||||
user_stats_enabled: {type: Boolean, default: false}
|
||||
```
|
||||
@@ -0,0 +1,26 @@
|
||||
const mongoose = require('../mongoose');
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
const SettingSchema = new Schema({
|
||||
id: {type: String, default: '1'},
|
||||
moderation: {type: String, enum: ['pre', 'post'], default: 'pre'}
|
||||
}, {
|
||||
_id: false,
|
||||
timestamps: {
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at'
|
||||
}
|
||||
});
|
||||
|
||||
SettingSchema.statics.getSettings = function () {
|
||||
return this.findOne();
|
||||
};
|
||||
|
||||
SettingSchema.statics.updateSettings = function (setting) {
|
||||
// there should only ever be one record unless something has gone wrong.
|
||||
return this.findOneAndUpdate({id: '1'}, {$set: setting}, {new: true});
|
||||
};
|
||||
|
||||
const Setting = mongoose.model('Setting', SettingSchema);
|
||||
|
||||
module.exports = Setting;
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
const mongoose = require('mongoose');
|
||||
const enabled = require('debug').enabled;
|
||||
const url = process.env.TALK_MONGO_URL || 'mongodb://localhost';
|
||||
|
||||
// Use native promises
|
||||
mongoose.Promise = global.Promise;
|
||||
@@ -9,7 +10,7 @@ if (enabled('talk:db')) {
|
||||
}
|
||||
|
||||
try {
|
||||
mongoose.connect(process.env.TALK_MONGO_URL, (err) => {
|
||||
mongoose.connect(url, (err) => {
|
||||
if (err) throw err;
|
||||
console.log('Connected to MongoDB!');
|
||||
});
|
||||
|
||||
@@ -3,6 +3,7 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
router.use('/comments', require('./comments'));
|
||||
router.use('/settings', require('./settings'));
|
||||
router.use('/queue', require('./queue'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const Setting = require('../../../models/setting');
|
||||
|
||||
router.get('/', (req, res, next) => {
|
||||
Setting.getSettings().then(res.json).catch(next);
|
||||
});
|
||||
|
||||
router.put('/', (req, res, next) => {
|
||||
Setting.updateSettings(req.body).then(res.json).catch(next);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user