diff --git a/server/cli/accounts.js b/server/cli/accounts.js index c1c9bca6..c248eee6 100644 --- a/server/cli/accounts.js +++ b/server/cli/accounts.js @@ -33,7 +33,7 @@ async function modify (args) { async function create (args) { await _initializeDB() - const User = require('../api/models/user') + const { User } = require('../api/models/models') const user = await User.create({ email: args.email, is_active: true, @@ -46,7 +46,7 @@ async function create (args) { async function remove (args) { await _initializeDB() - const User = require('../api/models/user') + const { User } = require('../api/models/models') const user = await User.findOne({ where: { email: args.email } }) @@ -58,7 +58,7 @@ async function remove (args) { async function list () { await _initializeDB() - const User = require('../api/models/user') + const { User } = require('../api/models/models') const users = await User.findAll() console.log() users.forEach(u => console.log(`${u.id}\tadmin: ${u.is_admin}\tenabled: ${u.is_active}\temail: ${u.email}`)) diff --git a/server/federation/ego.js b/server/federation/ego.js index 7c31182f..44ab0684 100644 --- a/server/federation/ego.js +++ b/server/federation/ego.js @@ -1,4 +1,4 @@ -const Event = require('../api/models/event') +const { Event } = require('../api/models/models') const config = require('../config') const log = require('../log') diff --git a/server/federation/index.js b/server/federation/index.js index 0c00ece4..7a27a062 100644 --- a/server/federation/index.js +++ b/server/federation/index.js @@ -2,10 +2,8 @@ const express = require('express') const router = express.Router() const cors = require('cors') const Users = require('./users') -const Event = require('../api/models/event') -const User = require('../api/models/user') -const Tag = require('../api/models/tag') -const Place = require('../api/models/place') +const { Event, User, Tag, Place } = require('../api/models/models') + const settingsController = require('../api/controller/settings') const Helpers = require('./helpers') diff --git a/server/federation/resources.js b/server/federation/resources.js index 195716c7..4c497635 100644 --- a/server/federation/resources.js +++ b/server/federation/resources.js @@ -1,6 +1,4 @@ -const Event = require('../api/models/event') -const Resource = require('../api/models/resource') -const APUser = require('../api/models/ap_user') +const { Event, Resource, APUser } = require('../api/models/models') const log = require('../log') const helpers = require('../helpers') diff --git a/server/federation/users.js b/server/federation/users.js index 074ea0b3..b8ac73f4 100644 --- a/server/federation/users.js +++ b/server/federation/users.js @@ -1,7 +1,5 @@ -const Event = require('../api/models/event') -const Place = require('../api/models/place') -const APUser = require('../api/models/ap_user') -const Tag = require('../api/models/tag') +const { Event, Place, APUser, Tag } = require('../api/models/models') + const escape = require('lodash/escape') const config = require('../config') const log = require('../log') diff --git a/server/federation/webfinger.js b/server/federation/webfinger.js index e6e4a091..a2869da9 100644 --- a/server/federation/webfinger.js +++ b/server/federation/webfinger.js @@ -1,8 +1,6 @@ const express = require('express') const router = express.Router() -const Event = require('../api/models/event') -const Resource = require('../api/models/resource') -const User = require('../api/models/user') +const { Event, Resource, User } = require('../api/models/models') const cors = require('cors') const settingsController = require('../api/controller/settings') diff --git a/server/helpers/place.js b/server/helpers/place.js index ff87797a..d4260924 100644 --- a/server/helpers/place.js +++ b/server/helpers/place.js @@ -1,5 +1,4 @@ -const Place = require('../api/models/place') -const Event = require('../api/models/event') +const { Event, Place } = require('../api/models/models') const Sequelize = require('sequelize') const log = require('../log') diff --git a/server/helpers/tag.js b/server/helpers/tag.js index 63f31627..35d44746 100644 --- a/server/helpers/tag.js +++ b/server/helpers/tag.js @@ -1,5 +1,5 @@ -const Tag = require('../api/models/tag') -const Event = require('../api/models/event') +const { Event, Tag } = require('../api/models/models') + const Sequelize = require('sequelize') const log = require('../log') @@ -13,7 +13,7 @@ module.exports = { }) if (!tags.length) { return } - log.info(`Remove ${tags.length} unrelated tags`) + log.info(`Remove ${tags.length} orphan tags (${tags.join(', ')})`) await Tag.destroy({ where: { tag: { [Sequelize.Op.in]: tags.map(p => p.tag) } }