Merge branch 'master' of framagit.org:/les/gancio into feat/allowgeoloc
This commit is contained in:
@@ -574,8 +574,8 @@ const eventController = {
|
||||
let tags = []
|
||||
if (body.tags) {
|
||||
tags = await tagController._findOrCreate(body.tags)
|
||||
await event.setTags(tags)
|
||||
}
|
||||
await event.setTags(tags)
|
||||
|
||||
let newEvent = await Event.findByPk(event.id, { include: [Tag, Place] })
|
||||
newEvent = newEvent.get()
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const Sequelize = require('sequelize')
|
||||
|
||||
// this is an hack: https://github.com/sequelize/sequelize/pull/14800
|
||||
const livePatchMariaDBDialect = require('sequelize/lib/dialects/mariadb/query')
|
||||
livePatchMariaDBDialect.prototype.handleJsonSelectQuery = () => null
|
||||
|
||||
const Umzug = require('umzug')
|
||||
const path = require('path')
|
||||
const config = require('../../config')
|
||||
@@ -12,29 +8,29 @@ const settingsController = require('../controller/settings')
|
||||
|
||||
const db = {
|
||||
sequelize: null,
|
||||
close () {
|
||||
close() {
|
||||
if (db.sequelize) {
|
||||
return db.sequelize.close()
|
||||
}
|
||||
},
|
||||
connect (dbConf = config.db) {
|
||||
connect(dbConf = config.db) {
|
||||
dbConf.dialectOptions = { autoJsonMap: true }
|
||||
log.debug(`Connecting to DB: ${JSON.stringify(dbConf)}`)
|
||||
if (dbConf.dialect === 'sqlite') {
|
||||
dbConf.retry = {
|
||||
match: [
|
||||
Sequelize.ConnectionError,
|
||||
Sequelize.ConnectionTimedOutError,
|
||||
Sequelize.TimeoutError,
|
||||
/Deadlock/i,
|
||||
/SQLITE_BUSY/],
|
||||
Sequelize.ConnectionError,
|
||||
Sequelize.ConnectionTimedOutError,
|
||||
Sequelize.TimeoutError,
|
||||
/Deadlock/i,
|
||||
/SQLITE_BUSY/],
|
||||
max: 15
|
||||
}
|
||||
}
|
||||
db.sequelize = new Sequelize(dbConf)
|
||||
return db.sequelize.authenticate()
|
||||
},
|
||||
async isEmpty () {
|
||||
async isEmpty() {
|
||||
try {
|
||||
const users = await db.sequelize.query('SELECT * from users')
|
||||
return !(users && users.length)
|
||||
@@ -42,7 +38,7 @@ const db = {
|
||||
return true
|
||||
}
|
||||
},
|
||||
async runMigrations () {
|
||||
async runMigrations() {
|
||||
const logging = config.status !== 'READY' ? false : log.debug.bind(log)
|
||||
const umzug = new Umzug({
|
||||
storage: 'sequelize',
|
||||
@@ -59,9 +55,9 @@ const db = {
|
||||
path: path.resolve(__dirname, '..', '..', 'migrations')
|
||||
}
|
||||
})
|
||||
return umzug.up()
|
||||
return umzug.up()
|
||||
},
|
||||
async initialize () {
|
||||
async initialize() {
|
||||
if (config.status === 'CONFIGURED') {
|
||||
try {
|
||||
await db.connect()
|
||||
|
||||
@@ -91,8 +91,12 @@ module.exports = {
|
||||
const router = express.Router()
|
||||
// serve images/thumb
|
||||
router.use('/media/', express.static(config.upload_path, { immutable: true, maxAge: '1y' }), (_req, res) => res.sendStatus(404))
|
||||
router.use('/download/:filename', (req, res, next) => {
|
||||
return res.download(req.params.filename, undefined, { root: config.upload_path }, err => res.status(404).send('Not found (but nice try 😊)'))
|
||||
router.use('/download/:filename', (req, res) => {
|
||||
return res.download(req.params.filename, undefined, { root: config.upload_path }, err => {
|
||||
if (err) {
|
||||
res.status(404).send('Not found (but nice try 😊)')
|
||||
}
|
||||
})
|
||||
})
|
||||
router.use('/noimg.svg', express.static('./static/noimg.svg'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user