diff --git a/src/server/models/catgrp.js b/src/server/models/catgrp.js new file mode 100755 index 0000000..ea1dc75 --- /dev/null +++ b/src/server/models/catgrp.js @@ -0,0 +1,83 @@ +const mongoose = require('mongoose').set('debug', false) +const Schema = mongoose.Schema; + +mongoose.Promise = global.Promise; +mongoose.level = "F"; + +const tools = require('../tools/general'); + +const { ObjectID } = require('mongodb'); + +// Resolving error Unknown modifier: $pushAll +mongoose.plugin(schema => { + schema.options.usePushEach = true +}); + +const CatGrpSchema = new Schema({ + _id: { + type: Number, + }, + descr: { + type: String, + }, + idCatGrp: { + type: Number + }, + icon: { + type: String, + }, + img: { + type: String, + }, + color: { + type: String, + }, + theme: { + type: String, + }, +}); + +CatGrpSchema.pre('save', async function (next) { + if (this.isNew) { + const myrec = await CatGrp.findOne().limit(1).sort({_id:-1}); + if (!!myrec) { + if (myrec._doc._id === 0) + this._id = 1; + else + this._id = myrec._doc._id + 1; + } else { + this._id = 1; + } + } + + next(); +}); + +CatGrpSchema.statics.findAllIdApp = async function (idapp) { + const CatGrp = this; + + const query = [ + { $sort: { descr: 1 } } + ]; + + return CatGrp + .aggregate(query) + .then((arrrec) => { + return arrrec + }) + +}; + +CatGrpSchema.statics.getFieldsForSearch = function () { + return [{ field: 'descr', type: tools.FieldType.string }] +}; + +CatGrpSchema.statics.executeQueryTable = function (idapp, params) { + params.fieldsearch = this.getFieldsForSearch(); + return tools.executeQueryTable(this, 0, params); +}; + + +const CatGrp = mongoose.model('CatGrp', CatGrpSchema); + +module.exports = { CatGrp }; diff --git a/src/server/models/mygroup.js b/src/server/models/mygroup.js index ed49260..6197ae2 100755 --- a/src/server/models/mygroup.js +++ b/src/server/models/mygroup.js @@ -3,6 +3,8 @@ const Schema = mongoose.Schema; const tools = require('../tools/general'); +const shared_consts = require('../tools/shared_nodejs'); + mongoose.Promise = global.Promise; mongoose.level = 'F'; @@ -24,7 +26,7 @@ const MyGroupSchema = new Schema({ descr: { type: String, }, - idSector: { + idCatGrp: { type: Number, }, userId: { @@ -52,12 +54,20 @@ const MyGroupSchema = new Schema({ link_telegram: { type: String, }, - visibility: { - type: Number, + note: { + type: String, + default: '', + }, + visibility: [ + { + type: Number, + }, + ], + pwd_cryp: { + type: String, }, admins: [ { - _id: false, username: {type: String}, date: {type: Date}, }, @@ -93,6 +103,14 @@ MyGroupSchema.statics.getFieldsForSearch = function() { MyGroupSchema.statics.executeQueryTable = function(idapp, params) { params.fieldsearch = this.getFieldsForSearch(); + + if (params.options) { + if (tools.isBitActive(params.options, + shared_consts.OPTIONS_SEARCH_USER_ONLY_FULL_WORDS)) { + params.fieldsearch = User.getFieldsForSearchUserFriend(); + } + } + return tools.executeQueryTable(this, idapp, params); }; @@ -103,42 +121,43 @@ MyGroupSchema.statics.findAllIdApp = async function(idapp) { }; // Rimuovo la Richiesta del Gruppo -MyGroupSchema.statics.removeReqGroup = async function( - idapp, username, groupnameDest) { - const {User} = require('../models/user'); +MyGroupSchema.statics.removeReqGroup = async function(idapp, username, groupnameDest) { - return User.updateOne({idapp, username: username}, - {$pull: {'profile.req_groups': {groupname: {$in: [groupnameDest]}}}}); + return MyGroup.updateOne({idapp, groupname: groupnameDest}, + {$pull: {req_users: {username: {$in: [username]}}}}); }; -function getWhatToShow(idapp, username) { - // ++Todo: MyGroup what to show +MyGroupSchema.statics.getWhatToShow = function (idapp, username) { + // FOR ME, PERMIT ALL return { groupname: 1, title: 1, descr: 1, visibility: 1, - idSector: 1, + idCatGrp: 1, userId: 1, photos: 1, idCity: 1, website: 1, link_telegram: 1, + note: 1, admins: 1, blocked: 1, + req_users: 1, }; } -function getWhatToShow_Unknown(idapp, username) { +MyGroupSchema.statics.getWhatToShow_Unknown = function (idapp, username) { return { groupname: 1, title: 1, descr: 1, photos: 1, visibility: 1, - idSector: 1, + idCatGrp: 1, idCity: 1, + note: 1, }; } @@ -170,10 +189,9 @@ MyGroupSchema.statics.getUsernameReqGroupsByGroupname = async function( }; -MyGroupSchema.statics.getInfoGroupByGroupname = async function( - idapp, groupname) { +MyGroupSchema.statics.getInfoGroupByGroupname = async function(idapp, groupname) { - const whatToShow = getWhatToShow(idapp, groupname); + const whatToShow = this.getWhatToShow(idapp, groupname); return MyGroup.findOne({ idapp, @@ -187,8 +205,8 @@ MyGroupSchema.statics.getGroupsByUsername = async function(idapp, username) { try { const {User} = require('../models/user'); - const whatToShow = getWhatToShow(idapp, username); - const whatToShow_Unknown = getWhatToShow_Unknown(idapp, username); + const whatToShow = this.getWhatToShow(idapp, username); + const whatToShow_Unknown = this.getWhatToShow_Unknown(idapp, username); const arrUsernameGroups = await User.getUsernameGroupsByUsername(idapp, username); // const arrUsernameReqGroups = await MyGroup.getUsernameReqGroupsByGroupname(idapp, username); diff --git a/src/server/models/myskill.js b/src/server/models/myskill.js index d44326f..64f2495 100755 --- a/src/server/models/myskill.js +++ b/src/server/models/myskill.js @@ -64,6 +64,7 @@ const MySkillSchema = new Schema({ }], note: { type: String, + default: '', }, subTitle: { type: String, diff --git a/src/server/models/user.js b/src/server/models/user.js index 63183b7..e0ccc7a 100755 --- a/src/server/models/user.js +++ b/src/server/models/user.js @@ -342,7 +342,7 @@ const UserSchema = new mongoose.Schema({ username: {type: String}, date: {type: Date}, }], // username - groups: [ + mygroups: [ { _id: false, groupname: {type: String}, @@ -1314,7 +1314,7 @@ UserSchema.statics.removeFriend = async function(idapp, username, usernameDest) // Rimuovo il Gruppo UserSchema.statics.removeFromMyGroups = async function(idapp, username, groupnameDest) { return User.updateOne({idapp, username}, - {$pull: {'profile.groups': {groupname: {$in: [groupnameDest]}}}}); + {$pull: {'profile.mygroups': {groupname: {$in: [groupnameDest]}}}}); }; // Rimuovo la Richiesta di Amicizia @@ -1463,11 +1463,11 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD let update = {}; try { if (cmd === shared_consts.GROUPSCMD.SETGROUP) { - // Aggiungo l'Amicizia a me + // Controllo se è stato già inserito const foundIfAlreadyGroup = await User.findOne({ idapp, username: usernameOrig, - 'profile.groups': { + 'profile.mygroups': { $elemMatch: {groupname: {$eq: groupnameDest}}, }, }); @@ -1475,7 +1475,7 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD if (!foundIfAlreadyGroup) { update = { $push: { - 'profile.groups': { + 'profile.mygroups': { groupname: groupnameDest, date: new Date(), }, @@ -1483,8 +1483,11 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD }; ris = await User.updateOne({idapp, username: usernameOrig}, update); - update = {$pull: {'profile.req_groups': {groupname: {$in: [groupnameDest]}}}}; - ris = await User.updateOne({idapp, username: usernameOrig}, update); + // Elimina la richiesta: + update = {$pull: {req_users: {username: {$in: [usernameOrig]}}}}; + ris = await MyGroup.updateOne({idapp, groupname: groupnameDest}, update); + } else { + ris = false; } if (ris) { @@ -1495,7 +1498,7 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD const foundIfAlreadyAskGroup = await MyGroup.findOne({ idapp, groupname: groupnameDest, - 'req_groups': { + 'req_users': { $elemMatch: { username: {$eq: usernameOrig}}, }, }); @@ -1504,31 +1507,33 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD if (!foundIfAlreadyAskGroup) { update = { $push: { - 'profile.req_groups': { + 'req_users': { username: usernameOrig, date: new Date(), }, }, }; - ris = await User.updateOne({idapp, username: groupnameDest}, update); + ris = await MyGroup.updateOne({idapp, groupname: groupnameDest}, update); } if (ris) { // Invia una notifica alla persona - tools.sendNotificationByGroupName(idapp, groupnameDest, cmd, true); + tools.sendNotificationByGroupname(idapp, groupnameDest, cmd, true); } } else { if (foundIfAlreadyAskGroup) { - ris = await this.removeFromMyGroups(idapp, groupnameDest, usernameOrig); // Rimuovo l'Amicizia da me + ris = await this.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo il Gruppo da me } } + if (ris) { - ris = await User.getInfoAskGroupByUsername(idapp, groupnameDest); + ris = await MyGroup.getInfoGroupByGroupname(idapp, groupnameDest); } - } else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUPS) { + } else if (cmd === shared_consts.GROUPSCMD.REMOVE_FROM_MYGROUP) { - ris = await this.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me + ris = await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me + console.log('ris', ris); } else if (cmd === shared_consts.GROUPSCMD.CANCEL_REQ_GROUP) { @@ -1536,10 +1541,10 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD } else if (cmd === shared_consts.GROUPSCMD.BLOCK_GROUP) { - await this.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me + await User.removeFromMyGroups(idapp, usernameOrig, groupnameDest); // Rimuovo l'Amicizia da me // Blocco il Gruppo - ris = await MyGroup.updateOne({idapp, username: groupnameDest}, { + ris = await MyGroup.updateOne({idapp, groupname: groupnameDest}, { $set: { blocked: true, username_who_block: usernameOrig, @@ -1547,6 +1552,7 @@ UserSchema.statics.setGroupsCmd = async function(idapp, usernameOrig, groupnameD }, }); //++Todo: Send Notification to Admin and Group's manager + tools.sendNotificationByGroupname(idapp, groupnameDest, cmd, true); } } catch (e) { @@ -1601,6 +1607,26 @@ function getWhatToShow_Unknown(idapp, username) { } +UserSchema.statics.getWhatToShow_IfFriends = async function(idapp, username) { + return { + username: 1, + aportador_solidario: 1, + name: 1, + // deleted: 1, + // sospeso: 1, + verified_email: 1, + verified_by_aportador: 1, + 'profile.img': 1, + 'profile.sex': 1, + 'profile.born_province': 1, + 'profile.born_country': 1, + date_reg: 1, + groups: 1, + friends: 1, + }; + +}; + UserSchema.statics.getInfoFriendByUsername = async function(idapp, username) { const whatToShow = getWhatToShow(idapp, username); @@ -2935,17 +2961,32 @@ UserSchema.statics.addExtraInfo = async function(idapp, recUser) { recUser._doc.profile.asked_friends = listSentMyRequestFriends ? listSentMyRequestFriends : []; - const listSentMyRequestGroups = await User.find({ + const listSentMyRequestGroups = await MyGroup.find({ idapp, - 'profile.req_groups': { + 'req_users': { $elemMatch: {username: {$eq: recUser.username}}, }, $or: [ {deleted: {$exists: false}}, {deleted: {$exists: true, $eq: false}}], - }, {username: 1}); + }, MyGroup.getWhatToShow_Unknown()); recUser._doc.profile.asked_groups = listSentMyRequestGroups ? listSentMyRequestGroups : []; + + const listManageGroups = await MyGroup.find({ + idapp, + 'admins': { + $elemMatch: {username: {$eq: recUser.username}}, + }, + $or: [ + {deleted: {$exists: false}}, + {deleted: {$exists: true, $eq: false}}], + }); + + recUser._doc.profile.manage_mygroups = listManageGroups ? listManageGroups : []; + + + }catch (e){ console.error('Err', e); } diff --git a/src/server/populate/catgrps.js b/src/server/populate/catgrps.js new file mode 100644 index 0000000..97a84c8 --- /dev/null +++ b/src/server/populate/catgrps.js @@ -0,0 +1,72 @@ +module.exports = { + list: [ + { + _id: 1, + descr: "Abitare", + }, + { + _id: 2, + descr: "Arte", + }, + { + _id: 3, + descr: "Alimentazione", + }, + { + _id: 4, + descr: "Artigianato", + }, + { + _id: 5, + descr: "Assistenza Legale", + }, + { + _id: 6, + descr: "Benessere e Salute", + }, + { + _id: 7, + descr: "Gruppi Locali", + }, + { + _id: 8, + descr: "Istruzione", + }, + { + _id: 2, + descr: "Arte", + }, + { + _id: 9, + descr: "Mobilità", + }, + { + _id: 10, + descr: "Sport", + }, + { + _id: 11, + descr: "Servizi", + }, + { + _id: 12, + descr: "Tecnologia", + }, + { + _id: 13, + descr: "Turismo", + }, + { + _id: 14, + descr: "Ecovillaggi", + }, + { + _id: 15, + descr: "Feste", + }, + { + _id: 16, + descr: "Altro", + }, + ] +} diff --git a/src/server/populate/populate.js b/src/server/populate/populate.js index 5d76f7c..f7947ef 100644 --- a/src/server/populate/populate.js +++ b/src/server/populate/populate.js @@ -34,6 +34,10 @@ module.exports = { const { Sector } = require('../models/sector'); this.insertIntoDb('sectors', Sector) + // CatGrps + const { CatGrp } = require('../models/catgrp'); + this.insertIntoDb('catgrps', CatGrp) + // Skills (Competenze) const { Skill } = require('../models/skill'); this.insertIntoDb('skills', Skill) diff --git a/src/server/router/index_router.js b/src/server/router/index_router.js index 9248ce2..084e6e6 100755 --- a/src/server/router/index_router.js +++ b/src/server/router/index_router.js @@ -50,6 +50,7 @@ const {StatusSkill} = require('../models/statusSkill'); const {City} = require('../models/city'); const {Province} = require('../models/province'); const {Sector} = require('../models/sector'); +const {CatGrp} = require('../models/catgrp'); const {Level} = require('../models/level'); const Pickup = require('../models/pickup'); const {Newstosent} = require('../models/newstosent'); @@ -315,6 +316,8 @@ function getTableByTableName(tablename) { mytable = Province; else if (tablename === 'sectors') mytable = Sector; + else if (tablename === 'catgrps') + mytable = CatGrp; else if (tablename === 'levels') mytable = Level; else if (shared_consts.TablePickup.includes(tablename)) @@ -351,7 +354,8 @@ router.post('/settable', authenticate, (req, res) => { } if (shared_consts.TABLES_USER_ID.includes(params.table)) { - mydata.userId = req.user._id; + if (!mydata.userId) + mydata.userId = req.user._id; } if (shared_consts.TABLES_PERM_NEWREC.includes(params.table)) { @@ -360,20 +364,31 @@ router.post('/settable', authenticate, (req, res) => { } } + if (params.table === shared_consts.TAB_MYGROUPS) { + if (shared_consts.MYGROUPS_KEY_TO_CRYPTED in mydata) { + if (mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]) { + mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED + shared_consts.SUFFIX_CRYPTED] = tools.cryptdata(mydata[shared_consts.MYGROUPS_KEY_TO_CRYPTED]); + } + } + + } + if (shared_consts.TABLES_USER_INCLUDE_MY.includes(params.table)) { if (!mydata.admins) { mydata.admins = []; } else { - const arrnew = []; + /*const arrnew = []; for (const username of mydata.admins) { arrnew.push({username}); } mydata.admins = arrnew; + + */ } const indfind = mydata.admins.findIndex((rec) => (rec.username === req.user.username)); if (indfind < 0) { - mydata.admins.push({_id: new ObjectID(), username: req.user.username}); + mydata.admins.push({username: req.user.username}); } } @@ -634,7 +649,6 @@ router.patch('/chval', authenticate, async (req, res) => { fieldsvalue.crypted = true; fieldsvalue.value_str = tools.cryptdata(fieldsvalue.value_str); } - } if (mydata.table === shared_consts.TAB_SITES) { @@ -1089,6 +1103,7 @@ function load(req, res, version) { let subSkills = SubSkill.findAllIdApp(idapp); let statusSkills = StatusSkill.findAllIdApp(idapp); let sectors = Sector.findAllIdApp(idapp); + let catgrps = CatGrp.findAllIdApp(idapp); let cities = City.findAllIdApp(idapp); let cart = null; let orderscart = null; @@ -1145,7 +1160,9 @@ function load(req, res, version) { sectors, statusSkills, cities, - myuserextra]).then((arrdata) => { + myuserextra, + catgrps, + ]).then((arrdata) => { // console.table(arrdata); let myuser = req.user; if (myuser) { @@ -1216,6 +1233,8 @@ function load(req, res, version) { sectors: arrdata[27], statusSkills: arrdata[28], cities: arrdata[29], + // myuser arrdata[30] + catgrps: arrdata[31], }); } @@ -1425,11 +1444,14 @@ function uploadFile(req, res, version) { const ris = await resizer(newname, setup_image_compress); if (ris) { - tools.delete(newname, false, () => {}); + if (tools.isFileExists(resized_img)) { + tools.delete(newname, false, () => {}); - tools.move(resized_img, newname, (err) => { - - }); + tools.move(resized_img, newname, (err) => { + if (err) + console.error('err', err); + }); + } } } catch (e) { console.error('newname', e); diff --git a/src/server/router/mygroups_router.js b/src/server/router/mygroups_router.js index 3dd0a4b..a08250f 100755 --- a/src/server/router/mygroups_router.js +++ b/src/server/router/mygroups_router.js @@ -5,34 +5,45 @@ 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 mongoose = require('mongoose').set('debug', false); -const { User } = require('../models/user'); -const { MyGroup } = require('../models/mygroup'); +const {User} = require('../models/user'); +const {MyGroup} = require('../models/mygroup'); const _ = require('lodash'); -const { ObjectID } = require('mongodb'); - +const {ObjectID} = require('mongodb'); router.post('/load', authenticate, async (req, res) => { const idapp = req.body.idapp; const groupname = req.body.groupname; - try{ - data = await MyGroup.findOne({idapp, groupname}).lean(); + try { + const whatshow = MyGroup.getWhatToShow(idapp, req.user.username); + const data = await MyGroup.findOne({idapp, groupname}, whatshow).lean(); - res.send(data); + const whatshowUsers = await User.getWhatToShow_IfFriends(idapp, req.user.username); - }catch (e) { - console.error('Error in MyGroups'); + const users_in_group = await User.find( + { + idapp, + 'profile.mygroups': { + $elemMatch: {groupname: {$eq: groupname}}, + } + }, + whatshowUsers + ); + + res.send({mygroup: data, users_in_group}); + + } catch (e) { + console.error('Error in MyGroups', e); return res.status(400).send(e); } - const ris = null - + const ris = null; }); diff --git a/src/server/router/myskills_router.js b/src/server/router/myskills_router.js index baeb1a7..8315607 100755 --- a/src/server/router/myskills_router.js +++ b/src/server/router/myskills_router.js @@ -13,8 +13,8 @@ var mongoose = require('mongoose').set('debug', false); const Subscription = mongoose.model('subscribers'); const _ = require('lodash'); -const { MySkill } = require('../models/myskill'); -var { User } = require('../models/user'); +const {MySkill} = require('../models/myskill'); +var {User} = require('../models/user'); const {ObjectID} = require('mongodb'); @@ -23,22 +23,27 @@ router.post('/page', authenticate, function(req, res, next) { let idSkill = req.body.idSkill; let idapp = req.body.idapp; - return MySkill.getMySkillByIdkill(idapp, idSkill).then((ris) => { + return MySkill.getMySkillByIdkill(idapp, idSkill). + then((ris) => { - if (ris) { - res.send(ris); - /* - const userId = ris.userId; - return User.getUsernameById(idapp, userId).then((username) => - { - res.send({...ris, username}); - }); - */ + if (ris) { + res.send(ris); + /* + const userId = ris.userId; + return User.getUsernameById(idapp, userId).then((username) => + { + res.send({...ris, username}); + }); + */ + + } else { + res.status(400).send(); + } + }).catch((e) => { + console.error('Err', e); + res.status(400).send(e); + }) - } else { - res.status(400).send(e); - } - }); }); diff --git a/src/server/router/users_router.js b/src/server/router/users_router.js index 70cea18..c4a530f 100755 --- a/src/server/router/users_router.js +++ b/src/server/router/users_router.js @@ -549,7 +549,7 @@ router.post('/groups/cmd', authenticate, (req, res) => { } } - return MyGroup.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).then((ris) => { + return User.setGroupsCmd(idapp, usernameOrig, groupnameDest, cmd, value).then((ris) => { res.send(ris); }).catch((e) => { tools.mylog('ERRORE IN groups/cmd: ' + e.message); diff --git a/src/server/tools/general.js b/src/server/tools/general.js index 0009c54..bfe3ada 100755 --- a/src/server/tools/general.js +++ b/src/server/tools/general.js @@ -120,6 +120,8 @@ const textlang = { 'MSG_SEND_FROM': 'Msg Inviato da', 'ZOOM_CONFERMATO': 'Sei stato confermato ad aver visto la Video Conferenza di Benvenuto!', 'RICHIESTA_AMICIZIA': 'Richiesta d\'Amicizia da parte di %s', + 'RICHIESTA_GRUPPO': 'Richiesta di entrare nel Gruppo %s da parte di %s', + 'RICHIESTA_BLOCCO_GRUPPO': 'Richiesta di bloccare il Gruppo %s da parte di %s', }, si: {}, es: { @@ -851,35 +853,52 @@ module.exports = { const arrusernameAdmins = group.admins; - for (const username of arrusernameAdmins) { - const user = await User.get - let userId = user._id; - let lang = user.lang; + for (const arradmins of arrusernameAdmins) { + try { + if (arradmins.username) { + const user = await User.findOne({idapp, username: arradmins.username}, + {_id: 1, lang: 1}); + if (user) { - let title = this.getNomeAppByIdApp(idapp); - let descr = ''; - let openUrl = '/'; - let tag = ''; - let actions = []; - if (cmd) { - if (cmd === shared_consts.FRIENDSCMD.REQFRIEND) { - descr = printf(this.get__('RICHIESTA_AMICIZIA', lang), username); - openUrl = '/my/' + username; - tag = 'reqfriends'; + let userId = user._id; + let lang = user.lang; + + let title = this.getNomeAppByIdApp(idapp); + let descr = ''; + let openUrl = '/'; + let tag = ''; + let actions = []; + if (cmd) { + if (cmd === shared_consts.GROUPSCMD.REQGROUP) { + descr = printf(this.get__('RICHIESTA_GRUPPO', lang), groupname, + arradmins.username); + openUrl = '/grp/' + groupname; + tag = 'reqgroups'; + } else if (cmd === shared_consts.GROUPSCMD.BLOCK_USER) { + descr = printf(this.get__('RICHIESTA_BLOCCO_GRUPPO', lang), + groupname, arradmins.username); + openUrl = '/grp/' + groupname; + tag = 'blockgroups'; + } + } + + if (userId) { + this.sendNotificationToUser(userId, title, descr, openUrl, '', + tag, + actions); + } + + if (telegram) { + const telegrambot = require('../telegram/telegrambot'); + + const idtelegram = await User.TelegIdByUsername(idapp, arradmins.username); + + await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr); + } + } } - } - - if (userId) { - this.sendNotificationToUser(userId, title, descr, openUrl, '', tag, - actions); - } - - if (telegram) { - const telegrambot = require('../telegram/telegrambot'); - - const idtelegram = await User.TelegIdByUsername(idapp, username); - - await telegrambot.sendMsgTelegramByIdTelegram(idapp, idtelegram, descr); + }catch (e){ + console.error('sendNotificationByGroupname', e); } } diff --git a/src/server/tools/shared_nodejs.js b/src/server/tools/shared_nodejs.js index 9f9efe9..d0d338a 100755 --- a/src/server/tools/shared_nodejs.js +++ b/src/server/tools/shared_nodejs.js @@ -63,10 +63,14 @@ module.exports = { TAB_PHONES: 'phones', TAB_SETTINGS: 'settings', TAB_SITES: 'sites', + TAB_MYGROUPS: 'mygroups', TAB_MYBOTS: 'mybots', KEY_TO_CRYPTED: ['PWD_FROM'], SITES_KEY_TO_CRYPTED: ['email_pwd'], + MYGROUPS_KEY_TO_CRYPTED: 'pwd', + + SUFFIX_CRYPTED: ['_cryp'], TablePickup: ['countries', 'phones'], @@ -84,8 +88,8 @@ module.exports = { TABLES_USER_INCLUDE_MY: ['mygroups'], TABLES_UPDATE_LASTMODIFIED: ['myskills', 'mybots', 'mygroups'], - TABLES_PERM_CHANGE_FOR_USERS: ['myskills'], - TABLES_PERM_NEWREC: ['skills', 'subskills'], + TABLES_PERM_CHANGE_FOR_USERS: ['myskills', 'mygroups'], + TABLES_PERM_NEWREC: ['skills', 'subskills', 'mygroups'], VISIB_ALL: 0, VISIB_ONLYIF_VERIFIED: 1,