upgrade sequelize

This commit is contained in:
les 2020-06-27 02:10:10 +02:00
parent a56839730a
commit 75815fdb03
33 changed files with 546 additions and 369 deletions

View file

@ -1,4 +1,4 @@
const { announcement: Announcement } = require('../models')
const Announcement = require('../models/announcement')
const debug = require('debug')('announcement:controller')
const announceController = {

View file

@ -1,4 +1,4 @@
const { ap_user: APUser } = require('../models')
const APUser = require('../models/ap_user')
const apUserController = {
async toggleBlock (req, res) {

View file

@ -9,14 +9,13 @@ const helpers = require('../../helpers')
const linkifyHtml = require('linkifyjs/html')
const Sequelize = require('sequelize')
const {
event: Event,
resource: Resource,
tag: Tag,
place: Place,
notification: Notification,
ap_user: APUser
} = require('../models')
const Event = require('../models/event')
const Resource = require('../models/resource')
const Tag = require('../models/tag')
const Place = require('../models/place')
const Notification = require('../models/notification')
const APUser = require('../models/ap_user')
const exportController = require('./export')
const debug = require('debug')('controller:event')
@ -301,15 +300,14 @@ const eventController = {
await event.setUser(req.user)
}
// return created event to the client
res.json(event)
// create recurrent instances of event if needed
// without waiting for the task manager
if (event.recurrent) {
eventController._createRecurrent()
}
// return created event to the client
res.json(event)
// send notifications (mastodon / email)
const notifier = require('../../notifier')
notifier.notifyEvent('Create', event.id)

View file

@ -1,4 +1,7 @@
const { event: Event, place: Place, tag: Tag } = require('../models')
const Event = require('../models/event')
const Place = require('../models/place')
const Tag = require('../models/tag')
const { Op } = require('sequelize')
const moment = require('moment-timezone')
const ics = require('ics')

View file

@ -1,9 +1,7 @@
const {
ap_user: APUser,
instance: Instance,
resource: Resource
// event: Event
} = require('../models')
const APUser = require('../models/ap_user')
const Instance = require('../models/instance')
const Resource = require('../models/resource')
// const { Op } = require('sequelize')
const instancesController = {

View file

@ -1,10 +1,12 @@
const crypto = require('crypto')
const { promisify } = require('util')
const randomBytes = promisify(crypto.randomBytes)
const {
oauth_client: OAuthClient, oauth_token: OAuthToken,
oauth_code: OAuthCode, user: User
} = require('../models')
const OAuthClient = require('../models/oauth_client')
const OAuthToken = require('../models/oauth_token')
const OAuthCode = require('../models/oauth_code')
const User = require('../models/user')
const debug = require('debug')('oauth')
const moment = require('moment')

View file

@ -1,4 +1,4 @@
const { resource: Resource } = require('../models')
const Resource = require('../models/resource')
const resourceController = {
async hide (req, res) {

View file

@ -1,4 +1,4 @@
const { setting: Setting } = require('../models')
const Setting = require('../models/setting')
const config = require('config')
const consola = require('consola')
const path = require('path')

View file

@ -2,7 +2,7 @@ const crypto = require('crypto')
const { Op } = require('sequelize')
const config = require('config')
const mail = require('../mail')
const { user: User } = require('../models')
const User = require('../models/user')
const settingsController = require('./settings')
const debug = require('debug')('user:controller')
const linkify = require('linkifyjs')

View file

@ -1,9 +1,12 @@
module.exports = (sequelize, DataTypes) => {
const announcement = sequelize.define('announcement', {
title: DataTypes.STRING,
announcement: DataTypes.STRING,
visible: DataTypes.BOOLEAN
}, {})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
return announcement
}
class Announcement extends Model {}
Announcement.init({
title: DataTypes.STRING,
announcement: DataTypes.STRING,
visible: DataTypes.BOOLEAN
}, { sequelize, modelName: 'announcement' })
module.exports = Announcement

View file

@ -1,18 +1,16 @@
module.exports = (sequelize, DataTypes) => {
const APUser = sequelize.define('ap_user', {
ap_id: {
type: DataTypes.STRING,
primaryKey: true
},
follower: DataTypes.BOOLEAN,
blocked: DataTypes.BOOLEAN,
object: DataTypes.JSON
})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
APUser.associate = function (models) {
APUser.belongsTo(models.instance)
APUser.hasMany(models.resource)
}
class APUser extends Model {}
return APUser
}
APUser.init({
ap_id: {
type: DataTypes.STRING,
primaryKey: true
},
follower: DataTypes.BOOLEAN,
blocked: DataTypes.BOOLEAN,
object: DataTypes.JSON
}, { sequelize, modelName: 'ap_user' })
module.exports = APUser

View file

@ -2,92 +2,105 @@ const config = require('config')
const moment = require('moment-timezone')
const htmlToText = require('html-to-text')
module.exports = (sequelize, DataTypes) => {
const Event = sequelize.define('event', {
id: {
allowNull: false,
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: DataTypes.STRING,
slug: DataTypes.STRING,
description: DataTypes.TEXT,
multidate: DataTypes.BOOLEAN,
start_datetime: {
type: DataTypes.INTEGER,
index: true
},
end_datetime: {
type: DataTypes.INTEGER,
index: true
},
image_path: DataTypes.STRING,
is_visible: DataTypes.BOOLEAN,
recurrent: DataTypes.JSON,
likes: { type: DataTypes.JSON, defaultValue: [] },
boost: { type: DataTypes.JSON, defaultValue: [] }
}, {})
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index')
Event.associate = function (models) {
Event.belongsTo(models.place)
Event.belongsTo(models.user)
Event.belongsToMany(models.tag, { through: 'event_tags' })
Event.belongsToMany(models.notification, { through: 'event_notification' })
Event.hasMany(models.resource)
Event.hasMany(Event, { as: 'child', foreignKey: 'parentId' })
Event.belongsTo(models.event, { as: 'parent' })
const Resource = require('./resource')
const Notification = require('./notification')
const Place = require('./place')
const User = require('./user')
const Tag = require('./tag')
class Event extends Model {}
Event.init({
id: {
allowNull: false,
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
title: DataTypes.STRING,
slug: DataTypes.STRING,
description: DataTypes.TEXT,
multidate: DataTypes.BOOLEAN,
start_datetime: {
type: DataTypes.INTEGER,
index: true
},
end_datetime: {
type: DataTypes.INTEGER,
index: true
},
image_path: DataTypes.STRING,
is_visible: DataTypes.BOOLEAN,
recurrent: DataTypes.JSON,
likes: { type: DataTypes.JSON, defaultValue: [] },
boost: { type: DataTypes.JSON, defaultValue: [] }
}, { sequelize, modelName: 'event' })
Event.belongsTo(Place)
Place.hasMany(Event)
Event.belongsTo(User)
Event.belongsToMany(Tag, { through: 'event_tags' })
Event.belongsToMany(Notification, { through: 'event_notification' })
Notification.belongsToMany(Event, { through: 'event_notification' })
Event.hasMany(Resource)
Resource.belongsTo(Event)
Event.hasMany(Event, { as: 'child', foreignKey: 'parentId' })
Event.belongsTo(Event, { as: 'parent' })
Event.prototype.toAP = function (username, locale, follower = []) {
const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_'))
const plainDescription = htmlToText.fromString(this.description.replace('\n', '').slice(0, 1000))
const summary = `
📍 ${this.place.name}
📅 ${moment.unix(this.start_datetime).locale(locale).format('dddd, D MMMM (HH:mm)')}
${plainDescription}
${tags.map(t => `#${t}`)}
`
const attachment = []
if (this.image_path) {
attachment.push({
type: 'Document',
mediaType: 'image/webp',
url: `${config.baseurl}/media/${this.image_path}`,
name: null,
blurHash: null
})
}
Event.prototype.toAP = function (username, locale, follower = []) {
const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_'))
const plainDescription = htmlToText.fromString(this.description.replace('\n', '').slice(0, 1000))
const summary = `
📍 ${this.place.name}
📅 ${moment.unix(this.start_datetime).locale(locale).format('dddd, D MMMM (HH:mm)')}
${plainDescription}
${tags.map(t => `#${t}`)}
`
const attachment = []
if (this.image_path) {
attachment.push({
type: 'Document',
mediaType: 'image/webp',
url: `${config.baseurl}/media/${this.image_path}`,
name: null,
blurHash: null
})
}
return {
id: `${config.baseurl}/federation/m/${this.id}`,
name: this.title,
url: `${config.baseurl}/event/${this.id}`,
type: 'Event',
startTime: moment.unix(this.start_datetime).locale(locale).format(),
endTime: moment.unix(this.end_datetime).locale(locale).format(),
location: {
name: this.place.name
},
attachment,
tag: tags.map(tag => ({
type: 'Hashtag',
name: '#' + tag,
href: '/tags/' + tag
})),
published: this.createdAt,
attributedTo: `${config.baseurl}/federation/u/${username}`,
to: follower || [],
cc: ['https://www.w3.org/ns/activitystreams#Public', `${config.baseurl}/federation/u/${username}/followers`],
summary,
sensitive: false
}
return {
id: `${config.baseurl}/federation/m/${this.id}`,
name: this.title,
url: `${config.baseurl}/event/${this.id}`,
type: 'Event',
startTime: moment.unix(this.start_datetime).locale(locale).format(),
endTime: moment.unix(this.end_datetime).locale(locale).format(),
location: {
name: this.place.name
},
attachment,
tag: tags.map(tag => ({
type: 'Hashtag',
name: '#' + tag,
href: '/tags/' + tag
})),
published: this.createdAt,
attributedTo: `${config.baseurl}/federation/u/${username}`,
to: follower || [],
cc: ['https://www.w3.org/ns/activitystreams#Public', `${config.baseurl}/federation/u/${username}/followers`],
summary,
sensitive: false
}
return Event
}
module.exports = Event

View file

@ -1,13 +1,15 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const event_notification = sequelize.define('event_notification', {
status: {
type: DataTypes.ENUM,
values: ['new', 'sent', 'error'],
defaultValue: 'new',
index: true
}
}, {})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
return event_notification
}
class EventNotification extends Model {}
EventNotification.init({
status: {
type: DataTypes.ENUM,
values: ['new', 'sent', 'error'],
defaultValue: 'new',
index: true
}
}, { sequelize, modelName: 'event_notification' })
module.exports = EventNotification

View file

@ -1,10 +1,10 @@
const fs = require('fs')
const path = require('path')
// const fs = require('fs')
// const path = require('path')
const Sequelize = require('sequelize')
const basename = path.basename(__filename)
// const basename = path.basename(__filename)
const config = require('config')
const consola = require('consola')
const db = {}
// const db = {}
let sequelize = null
try {
@ -19,23 +19,23 @@ sequelize.authenticate().catch(e => {
process.exit(-1)
})
fs
.readdirSync(__dirname)
.filter(file => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js')
})
.forEach(file => {
const model = sequelize.import(path.join(__dirname, file))
db[model.name] = model
})
// fs
// .readdirSync(__dirname)
// .filter(file => {
// return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js')
// })
// .forEach(file => {
// const model = sequelize.import(path.join(__dirname, file))
// db[model.name] = model
// })
Object.keys(db).forEach(modelName => {
if (db[modelName].associate) {
db[modelName].associate(db)
}
})
// Object.keys(db).forEach(modelName => {
// if (db[modelName].associate) {
// db[modelName].associate(db)
// }
// })
db.sequelize = sequelize
db.Sequelize = Sequelize
// db.sequelize = sequelize
// db.Sequelize = Sequelize
module.exports = db
module.exports = sequelize

View file

@ -1,19 +1,22 @@
'use strict'
module.exports = (sequelize, DataTypes) => {
const Instance = sequelize.define('instance', {
domain: {
primaryKey: true,
allowNull: false,
type: DataTypes.STRING
},
name: DataTypes.STRING,
blocked: DataTypes.BOOLEAN,
data: DataTypes.JSON
}, {})
Instance.associate = function (models) {
Instance.hasMany(models.ap_user)
}
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
const APUser = require('./ap_user')
return Instance
}
class Instance extends Model {}
Instance.init({
domain: {
primaryKey: true,
allowNull: false,
type: DataTypes.STRING
},
name: DataTypes.STRING,
blocked: DataTypes.BOOLEAN,
data: DataTypes.JSON
}, { sequelize, modelName: 'instance' })
Instance.hasMany(APUser)
APUser.belongsTo(Instance)
module.exports = Instance

View file

@ -1,26 +1,32 @@
module.exports = (sequelize, DataTypes) => {
const Notification = sequelize.define('notification', {
filters: DataTypes.JSON,
email: DataTypes.STRING,
remove_code: DataTypes.STRING,
action: {
type: DataTypes.ENUM,
values: ['Create', 'Update', 'Delete']
},
type: {
type: DataTypes.ENUM,
values: ['mail', 'admin_email', 'ap']
}
}, {
indexes: [{
unique: true,
fields: ['action', 'type']
}]
})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
// const Event = require('./event')
Notification.associate = function (models) {
Notification.belongsToMany(models.event, { through: 'event_notification' })
class Notification extends Model {}
Notification.init({
filters: DataTypes.JSON,
email: DataTypes.STRING,
remove_code: DataTypes.STRING,
action: {
type: DataTypes.ENUM,
values: ['Create', 'Update', 'Delete']
},
type: {
type: DataTypes.ENUM,
values: ['mail', 'admin_email', 'ap']
}
return Notification
}
},
{
sequelize,
modelName: 'notification',
indexes: [{
unique: true,
fields: ['action', 'type']
}]
})
// Notification.belongsToMany(Event, { through: 'event_notification' })
module.exports = Notification

View file

@ -1,17 +1,20 @@
module.exports = (sequelize, DataTypes) => {
const OAuthClient = sequelize.define('oauth_client', {
id: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false
},
name: DataTypes.STRING,
client_secret: DataTypes.STRING,
scopes: DataTypes.STRING,
redirectUris: DataTypes.STRING,
website: DataTypes.STRING
}, {})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
return OAuthClient
}
class OAuthClient extends Model {}
OAuthClient.init({
id: {
type: DataTypes.STRING,
primaryKey: true,
allowNull: false
},
name: DataTypes.STRING,
client_secret: DataTypes.STRING,
scopes: DataTypes.STRING,
redirectUris: DataTypes.STRING,
website: DataTypes.STRING
}, { sequelize, modelName: 'oauth_client' })
module.exports = OAuthClient

View file

@ -1,19 +1,23 @@
module.exports = (sequelize, DataTypes) => {
const OAuthCode = sequelize.define('oauth_code', {
authorizationCode: {
type: DataTypes.STRING,
primaryKey: true
},
expiresAt: DataTypes.DATE,
scope: DataTypes.STRING,
redirect_uri: DataTypes.STRING
}, {})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
OAuthCode.associate = function (models) {
OAuthCode.belongsTo(models.user)
OAuthCode.belongsTo(models.oauth_client, { as: 'client' })
}
const User = require('./user')
const OAuthClient = require('./oauth_client')
return OAuthCode
}
class OAuthCode extends Model {}
OAuthCode.init({
authorizationCode: {
type: DataTypes.STRING,
primaryKey: true
},
expiresAt: DataTypes.DATE,
scope: DataTypes.STRING,
redirect_uri: DataTypes.STRING
}, { sequelize, modelName: 'oauth_code' })
OAuthCode.belongsTo(User)
OAuthCode.belongsTo(OAuthClient, { as: 'client' })
module.exports = OAuthCode

View file

@ -1,31 +1,35 @@
module.exports = (sequelize, DataTypes) => {
const OAuthToken = sequelize.define('oauth_token', {
accessToken: {
type: DataTypes.STRING,
allowNull: false,
primaryKey: true
},
accessTokenExpiresAt: {
type: DataTypes.DATE,
get () {
return new Date(this.getDataValue('accesTokenExpiresAt'))
}
},
refreshToken: DataTypes.STRING,
refreshTokenExpiresAt: {
type: DataTypes.DATE,
get () {
return new Date(this.getDataValue('accesTokenExpiresAt'))
}
},
scope: DataTypes.STRING
}, {})
const sequelize = require('./index')
const { Model, DataTypes } = require('sequelize')
OAuthToken.associate = function (models) {
OAuthToken.belongsTo(models.user)
OAuthToken.belongsTo(models.oauth_client, { as: 'client' })
}
const User = require('./user')
const OAuthClient = require('./oauth_client')
return OAuthToken
}
class OAuthToken extends Model {}
OAuthToken.init({
accessToken: {
type: DataTypes.STRING,
allowNull: false,
primaryKey: true
},
accessTokenExpiresAt: {
type: DataTypes.DATE,
get () {
return new Date(this.getDataValue('accesTokenExpiresAt'))
}
},
refreshToken: DataTypes.STRING,
refreshTokenExpiresAt: {
type: DataTypes.DATE,
get () {
return new Date(this.getDataValue('accesTokenExpiresAt'))
}
},
scope: DataTypes.STRING
}, { sequelize, modelName: 'oauth_token' })
OAuthToken.belongsTo(User)
OAuthToken.belongsTo(OAuthClient, { as: 'client' })
module.exports = OAuthToken

View file

@ -1,19 +1,19 @@
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index')
module.exports = (sequelize, DataTypes) => {
// const Event = require('./event')
class Place extends Model {}
const Place = sequelize.define('place', {
name: {
type: DataTypes.STRING,
unique: true,
index: true,
allowNull: false
},
address: DataTypes.STRING
}, {})
Place.init({
name: {
type: DataTypes.STRING,
unique: true,
index: true,
allowNull: false
},
address: DataTypes.STRING
}, { sequelize, modelName: 'place' })
Place.associate = function (models) {
Place.hasMany(models.event)
}
// Place.hasMany(Event)
return Place
}
module.exports = Place

View file

@ -1,19 +1,22 @@
module.exports = (sequelize, DataTypes) => {
const Resource = sequelize.define('resource', {
activitypub_id: {
type: DataTypes.STRING,
index: true,
unique: true
},
hidden: DataTypes.BOOLEAN,
data: DataTypes.JSON
}, {})
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index')
Resource.associate = function (models) {
// Resource.belongsTo(models.instance)
Resource.belongsTo(models.event)
Resource.belongsTo(models.ap_user)
}
// const Event = require('./event')
const APUser = require('./ap_user')
return Resource
}
class Resource extends Model {}
Resource.init({
activitypub_id: {
type: DataTypes.STRING,
index: true,
unique: true
},
hidden: DataTypes.BOOLEAN,
data: DataTypes.JSON
}, { sequelize, modelName: 'resource' })
APUser.hasMany(Resource)
Resource.belongsTo(APUser)
module.exports = Resource

View file

@ -13,3 +13,5 @@ Setting.init({
value: DataTypes.JSON,
is_secret: DataTypes.BOOLEAN
}, { sequelize, modelName: 'setting' })
module.exports = Setting

View file

@ -1,18 +1,19 @@
const { Model, DataTypes } = require('sequelize')
// const Event = require('./event')
const sequelize = require('./index')
module.exports = (sequelize, DataTypes) => {
const Tag = sequelize.define('tag', {
tag: {
type: DataTypes.STRING,
allowNull: false,
index: true,
primaryKey: true
},
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
}, {})
class Tag extends Model {}
Tag.associate = function (models) {
Tag.belongsToMany(models.event, { through: 'event_tags' })
}
Tag.init({
tag: {
type: DataTypes.STRING,
allowNull: false,
index: true,
primaryKey: true
},
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
}, { sequelize, modelName: 'tag' })
return Tag
}
// Tag.belongsToMany(Event, { through: 'event_tags' })
module.exports = Tag

View file

@ -1,50 +1,55 @@
const bcrypt = require('bcryptjs')
const { Model, DataTypes } = require('sequelize')
const sequelize = require('./index')
module.exports = (sequelize, DataTypes) => {
const User = sequelize.define('user', {
settings: {
type: DataTypes.JSON,
defaultValue: []
// const Event = require('./event')
class User extends Model {}
User.init({
settings: {
type: DataTypes.JSON,
defaultValue: []
},
email: {
type: DataTypes.STRING,
unique: { msg: 'error.email_taken' },
validate: {
notEmpty: true
},
email: {
type: DataTypes.STRING,
unique: { msg: 'error.email_taken' },
validate: {
notEmpty: true
},
index: true,
allowNull: false
},
description: DataTypes.TEXT,
password: DataTypes.STRING,
recover_code: DataTypes.STRING,
is_admin: DataTypes.BOOLEAN,
is_active: DataTypes.BOOLEAN
}, {
scopes: {
withoutPassword: {
attributes: { exclude: ['password', 'recover_code'] }
}
index: true,
allowNull: false
},
description: DataTypes.TEXT,
password: DataTypes.STRING,
recover_code: DataTypes.STRING,
is_admin: DataTypes.BOOLEAN,
is_active: DataTypes.BOOLEAN
}, {
sequelize,
modelName: 'user',
scopes: {
withoutPassword: {
attributes: { exclude: ['password', 'recover_code'] }
}
})
User.associate = function (models) {
User.hasMany(models.event)
}
})
User.prototype.comparePassword = async function (pwd) {
if (!this.password) { return false }
const ret = await bcrypt.compare(pwd, this.password)
return ret
}
// User.hasMany(Event)
User.beforeSave(async (user, options) => {
if (user.changed('password')) {
const salt = await bcrypt.genSalt(10)
const hash = await bcrypt.hash(user.password, salt)
user.password = hash
}
})
return User
User.prototype.comparePassword = async function (pwd) {
if (!this.password) { return false }
const ret = await bcrypt.compare(pwd, this.password)
return ret
}
User.beforeSave(async (user, options) => {
if (user.changed('password')) {
const salt = await bcrypt.genSalt(10)
const hash = await bcrypt.hash(user.password, salt)
user.password = hash
}
})
module.exports = User

View file

@ -1,4 +1,4 @@
const { event: Event } = require('../api/models')
const Event = require('../api/models/event')
const config = require('config')
const debug = require('debug')('fediverse:ego')

View file

@ -4,7 +4,8 @@ const crypto = require('crypto')
const config = require('config')
const httpSignature = require('http-signature')
const debug = require('debug')('federation:helpers')
const { ap_user: APUser, instance: Instance } = require('../api/models')
const APUser = require('../api/models/ap_user')
const Instance = require('../api/models/instance')
const url = require('url')
const settingsController = require('../api/controller/settings')

View file

@ -3,7 +3,11 @@ const router = express.Router()
const cors = require('cors')
const Follows = require('./follows')
const Users = require('./users')
const { event: Event, user: User, tag: Tag, place: Place } = require('../api/models')
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 settingsController = require('../api/controller/settings')
const Resources = require('./resources')
const Helpers = require('./helpers')

View file

@ -1,4 +1,7 @@
const { event: Event, resource: Resource, ap_user: APUser } = require('../api/models')
const Event = require('../api/models/event')
const Resource = require('../api/models/resource')
const APUser = require('../api/models/ap_user')
const debug = require('debug')('fediverse:resource')
const helpers = require('../helpers')
const linkifyHtml = require('linkifyjs/html')

View file

@ -1,4 +1,8 @@
const { event: Event, place: Place, tag: Tag, ap_user: APUser } = require('../api/models')
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 config = require('config')
const debug = require('debug')('fediverse:user')

View file

@ -1,6 +1,9 @@
const express = require('express')
const router = express.Router()
const { event: Event, user: User, resource: Resource } = require('../api/models')
const Event = require('../api/models/event')
const Resource = require('../api/models/resource')
const User = require('../api/models/user')
const cors = require('cors')
const settingsController = require('../api/controller/settings')
const version = require('../../package.json').version

View file

@ -32,8 +32,8 @@ async function main () {
function shutdown () {
TaskManager.stop()
nuxt.close(async () => {
const db = require('./api/models')
await db.sequelize.close()
const sequelize = require('./api/models')
await sequelize.close()
process.exit()
})
}

View file

@ -3,10 +3,13 @@ const config = require('config')
const debug = require('debug')('notifier')
const fediverseHelpers = require('./federation/helpers')
const {
event: Event, notification: Notification, event_notification: EventNotification,
user: User, place: Place, tag: Tag
} = require('./api/models')
const Event = require('./api/models/event')
const Notification = require('./api/models/event')
const EventNotification = require('./api/models/event')
const User = require('./api/models/event')
const Place = require('./api/models/event')
const Tag = require('./api/models/event')
const eventController = require('./api/controller/event')
const notifier = {

111
yarn.lock
View file

@ -44,6 +44,7 @@
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.10.3.tgz#32b9a0d963a71d7a54f5f6c15659c3dbc2a523a5"
integrity sha512-drt8MUHbEqRzNR0xnF8nMehbY11b1SDkRw03PSNH/3Rb2Z35oxkddVSi3rcaak0YJQ86PCuE7Qx1jSFhbLNBMA==
<<<<<<< Updated upstream
dependencies:
"@babel/types" "^7.10.3"
jsesc "^2.5.1"
@ -70,6 +71,34 @@
resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.10.2.tgz#a17d9723b6e2c750299d2a14d4637c76936d8285"
integrity sha512-hYgOhF4To2UTB4LTaZepN/4Pl9LD4gfbJx8A34mqoluT8TLbof1mhUlYuNWTEebONa8+UlCC4X0TEXu7AOUyGA==
dependencies:
=======
dependencies:
"@babel/types" "^7.10.3"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.5.0"
"@babel/helper-annotate-as-pure@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.1.tgz#f6d08acc6f70bbd59b436262553fb2e259a1a268"
integrity sha512-ewp3rvJEwLaHgyWGe4wQssC2vjks3E80WiUe2BpMb0KhreTjMROCbxXcEovTrbeGVdQct5VjQfrv9EgC+xMzCw==
dependencies:
"@babel/types" "^7.10.1"
"@babel/helper-builder-binary-assignment-operator-visitor@^7.10.1":
version "7.10.3"
resolved "https://registry.yarnpkg.com/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.10.3.tgz#4e9012d6701bef0030348d7f9c808209bd3e8687"
integrity sha512-lo4XXRnBlU6eRM92FkiZxpo1xFLmv3VsPFk61zJKMm7XYJfwqXHsYJTY6agoc4a3L8QPw1HqWehO18coZgbT6A==
dependencies:
"@babel/helper-explode-assignable-expression" "^7.10.3"
"@babel/types" "^7.10.3"
"@babel/helper-compilation-targets@^7.10.2":
version "7.10.2"
resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.10.2.tgz#a17d9723b6e2c750299d2a14d4637c76936d8285"
integrity sha512-hYgOhF4To2UTB4LTaZepN/4Pl9LD4gfbJx8A34mqoluT8TLbof1mhUlYuNWTEebONa8+UlCC4X0TEXu7AOUyGA==
dependencies:
>>>>>>> Stashed changes
"@babel/compat-data" "^7.10.1"
browserslist "^4.12.0"
invariant "^2.2.4"
@ -367,6 +396,7 @@
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.10.1.tgz#d5bc0645913df5b17ad7eda0fa2308330bde34c5"
integrity sha512-Gf2Yx/iRs1JREDtVZ56OrjjgFHCaldpTnuy9BHla10qyVT3YkIIGEtoDWhyop0ksu1GvNjHIoYRBqm3zoR1jyQ==
<<<<<<< Updated upstream
dependencies:
"@babel/helper-plugin-utils" "^7.10.1"
@ -376,6 +406,17 @@
integrity sha512-a9OAbQhKOwSle1Vr0NJu/ISg1sPfdEkfRKWpgPuzhnWWzForou2gIeUIIwjAMHRekhhpJ7eulZlYs0H14Cbi+g==
dependencies:
"@babel/helper-plugin-utils" "^7.10.1"
=======
dependencies:
"@babel/helper-plugin-utils" "^7.10.1"
"@babel/plugin-syntax-decorators@^7.10.1":
version "7.10.1"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-decorators/-/plugin-syntax-decorators-7.10.1.tgz#16b869c4beafc9a442565147bda7ce0967bd4f13"
integrity sha512-a9OAbQhKOwSle1Vr0NJu/ISg1sPfdEkfRKWpgPuzhnWWzForou2gIeUIIwjAMHRekhhpJ7eulZlYs0H14Cbi+g==
dependencies:
"@babel/helper-plugin-utils" "^7.10.1"
>>>>>>> Stashed changes
"@babel/plugin-syntax-dynamic-import@^7.8.0":
version "7.8.3"
@ -2242,7 +2283,11 @@ bluebird@^2.10.0:
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-2.11.0.tgz#534b9033c022c9579c56ba3b3e5a5caafbb650e1"
integrity sha1-U0uQM8AiyVecVro7Plpcqvu2UOE=
<<<<<<< Updated upstream
bluebird@^3.0.5, bluebird@^3.1.1, bluebird@^3.5.5, bluebird@^3.7.2:
=======
bluebird@^3.0.5, bluebird@^3.1.1, bluebird@^3.5.0, bluebird@^3.5.3, bluebird@^3.5.5, bluebird@^3.7.2:
>>>>>>> Stashed changes
version "3.7.2"
resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f"
integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==
@ -4346,7 +4391,11 @@ eslint-plugin-import@^2.21.2:
resolve "^1.17.0"
tsconfig-paths "^3.9.0"
<<<<<<< Updated upstream
eslint-plugin-jest@^23.10.0, eslint-plugin-jest@^23.17.1:
=======
eslint-plugin-jest@^23.10.0, eslint-plugin-jest@^23.13.2:
>>>>>>> Stashed changes
version "23.17.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-23.17.1.tgz#c0f39ba78e0f33b7ee1ce4ec92b773e39026ea3f"
integrity sha512-/o36fw67qNbJGWbSBIBMfseMsNP/d88WUHAGHCi1xFwsNB3XXZGdvxbOw49j3iQz6MCW/yw8OeOsuQhi6mM5ZA==
@ -4374,7 +4423,11 @@ eslint-plugin-nuxt@^1.0.0:
semver "^7.3.2"
vue-eslint-parser "^7.0.0"
<<<<<<< Updated upstream
eslint-plugin-prettier@^3.1.4:
=======
eslint-plugin-prettier@^3.1.3:
>>>>>>> Stashed changes
version "3.1.4"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.1.4.tgz#168ab43154e2ea57db992a2cd097c828171f75c2"
integrity sha512-jZDa8z76klRqo+TdGDTFJSavwbnWK2ZpqGKNZ+VvweMW516pDUMmQ2koXvxEE4JhzNvTv+radye/bWGBmA6jmg==
@ -4455,7 +4508,11 @@ eslint-visitor-keys@^1.0.0, eslint-visitor-keys@^1.1.0, eslint-visitor-keys@^1.2
resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.3.0.tgz#30ebd1ef7c2fdff01c3a4f151044af25fab0523e"
integrity sha512-6J72N8UNa462wa/KFODt/PJ3IU60SDpC3QXC1Hjc1BXXpfL2C9R5+AU7jhe0F6GREqVMh4Juu+NY7xn+6dipUQ==
<<<<<<< Updated upstream
eslint@^7.3.1:
=======
eslint@^7.2.0:
>>>>>>> Stashed changes
version "7.3.1"
resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.3.1.tgz#76392bd7e44468d046149ba128d1566c59acbe19"
integrity sha512-cQC/xj9bhWUcyi/RuMbRtC3I0eW8MH0jhRELSvpKYkWep3C6YZ2OkvcvJVUeO6gcunABmzptbXBuDoXsjHmfTA==
@ -5909,7 +5966,11 @@ ini@^1.3.4, ini@^1.3.5, ini@~1.3.0:
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"
integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==
<<<<<<< Updated upstream
inquirer@^7.2.0:
=======
inquirer@^7.1.0, inquirer@^7.2.0:
>>>>>>> Stashed changes
version "7.2.0"
resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.2.0.tgz#63ce99d823090de7eb420e4bb05e6f3449aa389a"
integrity sha512-E0c4rPwr9ByePfNlTIB8z51kK1s2n6jrHuJeEHENl/sbq2G/S1auvibgEwNR4uSyiU+PiYHqSwsgGiXjG8p5ZQ==
@ -6655,7 +6716,11 @@ lazy-cache@^1.0.3:
resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e"
integrity sha1-odePw6UEdMuAhF07O24dpJpEbo4=
<<<<<<< Updated upstream
less-loader@^6.1.2:
=======
less-loader@^6.1.1:
>>>>>>> Stashed changes
version "6.1.2"
resolved "https://registry.yarnpkg.com/less-loader/-/less-loader-6.1.2.tgz#793f2ab76dea3c4fca6a27f3effceab16fc3cd9a"
integrity sha512-80g+EURm8H98wirYTNnIJMxVnJU9NYIXRs7rxsghL8C+UyuGzsqDXPgQcLUrNlItMwUviYeBfSOEyULI6iza+g==
@ -7468,14 +7533,22 @@ mkdirp@^1.0.3, mkdirp@^1.0.4, mkdirp@~1.0.3:
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==
<<<<<<< Updated upstream
moment-timezone@^0.5.31:
=======
moment-timezone@^0.5.21, moment-timezone@^0.5.31:
>>>>>>> Stashed changes
version "0.5.31"
resolved "https://registry.yarnpkg.com/moment-timezone/-/moment-timezone-0.5.31.tgz#9c40d8c5026f0c7ab46eda3d63e49c155148de05"
integrity sha512-+GgHNg8xRhMXfEbv81iDtrVeTcWt0kWmTEY1XQK14dICTXnWJnT0dxdlPspwqF3keKMVPXwayEsk1DI0AA/jdA==
dependencies:
moment ">= 2.9.0"
<<<<<<< Updated upstream
"moment@>= 2.9.0", moment@^2.24.0, moment@^2.25.3, moment@^2.26.0:
=======
"moment@>= 2.9.0", moment@^2.24.0, moment@^2.25.3:
>>>>>>> Stashed changes
version "2.27.0"
resolved "https://registry.yarnpkg.com/moment/-/moment-2.27.0.tgz#8bff4e3e26a236220dfe3e36de756b6ebaa0105d"
integrity sha512-al0MUK7cpIcglMv3YF13qSgdAIqxHTO7brRtaz3DlSULbqfazqkc5kEjNrLDOM7fsjshoFIihnU8snrP7zUvhQ==
@ -7914,7 +7987,11 @@ nuxt-express-module@^0.0.11:
dependencies:
express "^4.16.3"
<<<<<<< Updated upstream
nuxt@^2.13.1:
=======
nuxt@^2.12.2:
>>>>>>> Stashed changes
version "2.13.1"
resolved "https://registry.yarnpkg.com/nuxt/-/nuxt-2.13.1.tgz#039472899938de4bd785769c44ce9cec126ec818"
integrity sha512-a8OxhwQAfAQPmpTnRWcOFO9rlkx/QsnP35sByvkQwuaRKij3lR6MI9UbzoGb1SzjF/+BarhrYApiQL/XW2uEqg==
@ -9480,6 +9557,7 @@ prosemirror-keymap@^1.0.0, prosemirror-keymap@^1.1.2:
prosemirror-state "^1.0.0"
w3c-keyname "^2.2.0"
<<<<<<< Updated upstream
prosemirror-model@1.9.1:
version "1.9.1"
resolved "https://registry.yarnpkg.com/prosemirror-model/-/prosemirror-model-1.9.1.tgz#8c08cf556f593c5f015548d2c1a6825661df087f"
@ -9491,6 +9569,12 @@ prosemirror-model@^1.0.0, prosemirror-model@^1.1.0, prosemirror-model@^1.8.1:
version "1.10.0"
resolved "https://registry.yarnpkg.com/prosemirror-model/-/prosemirror-model-1.10.0.tgz#bb1101732bccacf336e23a36a8b045b865025fa2"
integrity sha512-xTMbbO2q4abs5lJdeRvk/SrftNfZlMdvChKziTiK+OKtP8LkQI8uw39u4S5zqyflrmW3Or6+qnyFPf1p4v2u1g==
=======
prosemirror-model@1.8.2, prosemirror-model@1.9.1, prosemirror-model@^1.0.0, prosemirror-model@^1.1.0, prosemirror-model@^1.8.1:
version "1.8.2"
resolved "https://registry.yarnpkg.com/prosemirror-model/-/prosemirror-model-1.8.2.tgz#c74eaacb0bbfea49b59a6d89fef5516181666a56"
integrity sha512-piffokzW7opZVCjf/9YaoXvTC0g7zMRWKJib1hpphPfC+4x6ZXe5CiExgycoWZJe59VxxP7uHX8aFiwg2i9mUQ==
>>>>>>> Stashed changes
dependencies:
orderedmap "^1.1.0"
@ -10426,10 +10510,17 @@ sequelize-pool@^6.0.0:
resolved "https://registry.yarnpkg.com/sequelize-pool/-/sequelize-pool-6.0.0.tgz#2b2f6570fb633ecb38a338c4fc266c0e42ce2af7"
integrity sha512-D/VfOX2Z+6JTWqM73lhcqMXp1X4CeqRNVMlndvbOMtyjFAZ2kYzH7rGFGFrLO1r+RZQdc/h+3zQL4nd3cclNLg==
<<<<<<< Updated upstream
sequelize@^6.1.0:
version "6.1.0"
resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-6.1.0.tgz#576eb95709142dbc96f4a8f2b166932cc2781f8d"
integrity sha512-8x603RQrj14QZ4dGpsYPMr3YGqsihNX9WPclNN83prwrhHAJH9LHfOG/pK2XUdrwYtbRz+2a7xKXK7rVdw3P2A==
=======
sequelize@^5.21.13:
version "5.22.0"
resolved "https://registry.yarnpkg.com/sequelize/-/sequelize-5.22.0.tgz#72344a3aecd6767a8ceb02b8cba739e3ebeadeaf"
integrity sha512-m7Qw2MplbaLw2hA4lu8CwzH6+1cG/W4lu5fVJY8S256Rma8ma0tR9yufC7dZGQ1QsL6KnTaEYwztAbgfQbd3Lw==
>>>>>>> Stashed changes
dependencies:
debug "^4.1.1"
dottie "^2.0.0"
@ -11288,7 +11379,11 @@ tiptap-commands@^1.13.1:
prosemirror-utils "0.9.6"
tiptap-utils "^1.9.1"
<<<<<<< Updated upstream
tiptap-extensions@^1.29.1:
=======
tiptap-extensions@^1.28.6:
>>>>>>> Stashed changes
version "1.29.1"
resolved "https://registry.yarnpkg.com/tiptap-extensions/-/tiptap-extensions-1.29.1.tgz#70679bd57ffcc6a67358f58d03e574b40e0432bb"
integrity sha512-xwBvlGAN0W9+F5DB/s/pH8LcOaUq7WgPffv7KOGU26jmPKq8JAXXwZXn8DOmPYaRo9RscF0Tg9AADOM+0vcLkQ==
@ -11315,7 +11410,11 @@ tiptap-utils@^1.9.1:
prosemirror-tables "1.0.0"
prosemirror-utils "0.9.6"
<<<<<<< Updated upstream
tiptap@^1.27.1:
=======
tiptap@^1.26.6, tiptap@^1.27.1:
>>>>>>> Stashed changes
version "1.27.1"
resolved "https://registry.yarnpkg.com/tiptap/-/tiptap-1.27.1.tgz#b40b6634f23913b4570d6e7a8ed4eb5b206c7589"
integrity sha512-CwPMwKAKjAzsnkxZSISqDh73JmTZP3qpYn91k71WfIUZ7KUDkDt8gOKDrHMhaTJR2qMmuAChkkzd3OvBaBX+/Q==
@ -11598,7 +11697,11 @@ uglify-to-browserify@~1.0.0:
resolved "https://registry.yarnpkg.com/uglify-to-browserify/-/uglify-to-browserify-1.0.2.tgz#6e0924d6bda6b5afe349e39a6d632850a0f882b7"
integrity sha1-bgkk1r2mta/jSeOabWMoUKD4grc=
<<<<<<< Updated upstream
umzug@^2.3.0:
=======
umzug@^2.1.0:
>>>>>>> Stashed changes
version "2.3.0"
resolved "https://registry.yarnpkg.com/umzug/-/umzug-2.3.0.tgz#0ef42b62df54e216b05dcaf627830a6a8b84a184"
integrity sha512-Z274K+e8goZK8QJxmbRPhl89HPO1K+ORFtm6rySPhFKfKc5GHhqdzD0SGhSWHkzoXasqJuItdhorSvY7/Cgflw==
@ -11860,12 +11963,16 @@ uuid@^3.3.2, uuid@^3.3.3:
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
<<<<<<< Updated upstream
uuid@^8.1.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.2.0.tgz#cb10dd6b118e2dada7d0cd9730ba7417c93d920e"
integrity sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==
v-calendar@^1.0.8:
=======
v-calendar@^1.0.6:
>>>>>>> Stashed changes
version "1.0.8"
resolved "https://registry.yarnpkg.com/v-calendar/-/v-calendar-1.0.8.tgz#35c515749b6c5a001c815a232acfa0d85b569f6b"
integrity sha512-2st0wvSM7oGTOQixVMFHAEPjGBWEJmAhBDE6NYR5MB9Owe1d/pR5+A1OB+/HICXbuiKMjG8KzDpeySnPECddsw==
@ -12121,7 +12228,11 @@ webpack-bundle-analyzer@^3.8.0:
opener "^1.5.1"
ws "^6.0.0"
<<<<<<< Updated upstream
webpack-cli@^3.3.12:
=======
webpack-cli@^3.3.11:
>>>>>>> Stashed changes
version "3.3.12"
resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.12.tgz#94e9ada081453cd0aa609c99e500012fd3ad2d4a"
integrity sha512-NVWBaz9k839ZH/sinurM+HcDvJOTXwSjYp1ku+5XKeOC03z8v5QitnK/x+lAxGXFyhdayoIf/GOpv85z3/xPag==