go on Conto Comunitario
This commit is contained in:
@@ -5,23 +5,24 @@ const tools = require('../tools/general');
|
||||
|
||||
const server_constants = require('../tools/server_constants');
|
||||
|
||||
const {authenticate} = require('../middleware/authenticate');
|
||||
const { authenticate } = require('../middleware/authenticate');
|
||||
|
||||
const mongoose = require('mongoose').set('debug', false);
|
||||
|
||||
const {User} = require('../models/user');
|
||||
const {Circuit} = require('../models/circuit');
|
||||
const { User } = require('../models/user');
|
||||
const { Circuit } = require('../models/circuit');
|
||||
const { Account } = require('../models/account');
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const {ObjectID} = require('mongodb');
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
async function getCircuitRecAdminsInfo(idapp, data) {
|
||||
|
||||
if (data && data.admins) {
|
||||
for (const admin of data.admins) {
|
||||
const myuser = await User.findOne({idapp, username: admin.username}, {'profile.img': 1}).lean();
|
||||
admin.profile = {img: myuser.profile.img};
|
||||
const myuser = await User.findOne({ idapp, username: admin.username }, { 'profile.img': 1 }).lean();
|
||||
admin.profile = { img: myuser.profile.img };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,15 +36,15 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
|
||||
try {
|
||||
|
||||
const {SendNotif} = require('../models/sendnotif');
|
||||
const {Movement} = require('../models/movement');
|
||||
const { SendNotif } = require('../models/sendnotif');
|
||||
const { Movement } = require('../models/movement');
|
||||
|
||||
// Check if ìs a Notif to read
|
||||
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
|
||||
SendNotif.setNotifAsRead(idapp, usernameOrig, idnotif);
|
||||
|
||||
const whatshow = Circuit.getWhatToShow(idapp, req.user.username);
|
||||
let data = await Circuit.findOne({idapp, path}, whatshow).lean();
|
||||
let data = await Circuit.findOne({ idapp, path }, whatshow).lean();
|
||||
|
||||
const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username);
|
||||
|
||||
@@ -70,7 +71,11 @@ router.post('/load', authenticate, async (req, res) => {
|
||||
data.movements = await Movement.getMovsByCircuitId(idapp, usernameOrig, data._id);
|
||||
}
|
||||
|
||||
res.send({circuit: data, users_in_circuit});
|
||||
if (data) {
|
||||
data.account = await Account.getAccountByUsernameAndCircuitId(idapp, '', data._id, false, data.path);
|
||||
}
|
||||
|
||||
res.send({ circuit: data, users_in_circuit });
|
||||
|
||||
} catch (e) {
|
||||
console.error('Error in Circuits', e);
|
||||
|
||||
Reference in New Issue
Block a user