mirror of
https://github.com/PretendoNetwork/miiverse-api.git
synced 2026-08-25 10:04:18 -05:00
Added topics flag to database
This commit is contained in:
@@ -418,6 +418,16 @@ async function getLatestMessage(pid, pid2) {
|
||||
})
|
||||
}
|
||||
|
||||
async function getFriendMessages(pid, search_key, limit) {
|
||||
verifyConnected();
|
||||
return POST.find({
|
||||
message_to_pid: pid,
|
||||
search_key: search_key,
|
||||
parent: null,
|
||||
removed: false
|
||||
}).sort({created_at: 1}).limit(limit);
|
||||
}
|
||||
|
||||
async function getPNIDS() {
|
||||
accountDB.verifyConnected();
|
||||
return PNID.find({});
|
||||
@@ -513,5 +523,6 @@ module.exports = {
|
||||
getNotification,
|
||||
getLastNotification,
|
||||
getAllUserPosts,
|
||||
getRemovedUserPosts
|
||||
getRemovedUserPosts,
|
||||
getFriendMessages
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@ const { Schema, model } = require('mongoose');
|
||||
const endpointSchema = new Schema({
|
||||
status: Number,
|
||||
server_access_level: String,
|
||||
topics: Boolean,
|
||||
guest_access: Boolean,
|
||||
host: String,
|
||||
api_host: String,
|
||||
|
||||
@@ -17,6 +17,8 @@ logger.info('[MIIVERSE] Creating \'discovery\' subdomain');
|
||||
router.use(subdomain('discovery.olv', discovery));
|
||||
logger.info('[MIIVERSE] Creating \'api\' subdomain');
|
||||
router.use(subdomain('api.olv', api));
|
||||
router.use(subdomain('api-test.olv', api));
|
||||
router.use(subdomain('api-dev.olv', api));
|
||||
|
||||
|
||||
logger.info('[MIIVERSE] Importing middleware');
|
||||
|
||||
@@ -7,6 +7,13 @@ memoized = memoize(comPostGen.topics, { async: true, maxAge: 1000 * 60 * 60 });
|
||||
|
||||
/* GET post titles. */
|
||||
router.get('/', async function (req, res) {
|
||||
let user = await database.getPNID(req.pid), discovery;
|
||||
if(user)
|
||||
discovery = await database.getEndPoint(user.server_access_level);
|
||||
else
|
||||
discovery = await database.getEndPoint('prod');
|
||||
if(!discovery.topics)
|
||||
return res.sendStatus(404);
|
||||
let communities = await database.getMostPopularCommunities(10);
|
||||
if(communities === null)
|
||||
return res.sendStatus(404);
|
||||
|
||||
Reference in New Issue
Block a user