cleaning
This commit is contained in:
@@ -5,6 +5,7 @@ const lodash = require('lodash')
|
||||
const { event: Event, comment: Comment, tag: Tag, place: Place, user: User, notification: Notification } = require('../models')
|
||||
const Sequelize = require('sequelize')
|
||||
const notifier = require('../../notifier')
|
||||
const federation = require('../../federation/helpers')
|
||||
|
||||
const eventController = {
|
||||
|
||||
@@ -120,7 +121,8 @@ const eventController = {
|
||||
res.sendStatus(200)
|
||||
|
||||
// send notification
|
||||
notifier.notifyEvent(event.id)
|
||||
//notifier.notifyEvent(event.id)
|
||||
//federation.sendEvent(event, req.user)
|
||||
} catch (e) {
|
||||
res.sendStatus(404)
|
||||
}
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
// const fs = require('fs')
|
||||
// const path = require('path')
|
||||
// const moment = require('moment')
|
||||
// const { event: Event, comment: Comment } = require('../models')
|
||||
// const config = require('config')
|
||||
// const settingsController = require('./settings')
|
||||
// const get = require('lodash/get')
|
||||
|
||||
// const botController = {
|
||||
// bots: null,
|
||||
// async initialize() {
|
||||
// const access_token = get(settingsController.secretSettings, 'mastodon_auth.access_token')
|
||||
// const instance = get(settingsController.settings, 'mastodon_instance')
|
||||
// if (!access_token || !instance) return
|
||||
// botController.bot = new Mastodon({
|
||||
// access_token,
|
||||
// api_url: `https://${instance}/api/v1`
|
||||
// })
|
||||
// const listener = botController.bot.stream('/streaming/user')
|
||||
// listener.on('message', botController.message)
|
||||
// listener.on('error', botController.error)
|
||||
// },
|
||||
// async post(event) {
|
||||
// const status = `${event.title} @${event.place.name} ${moment(event.start_datetime).format('ddd, D MMMM HH:mm')} -
|
||||
// ${event.description.length > 200 ? event.description.substr(0, 200) + '...' : event.description} - ${event.tags.map(t => '#' + t.tag).join(' ')} ${config.baseurl}/event/${event.id}`
|
||||
|
||||
// let media
|
||||
// if (event.image_path) {
|
||||
// const file = path.resolve(config.upload_path, event.image_path)
|
||||
// if (fs.statSync(file)) {
|
||||
// media = await botController.bot.post('/media', { file: fs.createReadStream(file) })
|
||||
// }
|
||||
// }
|
||||
// return botController.bot.post('/statuses', { status, media_ids: media ? [media.data.id] : [] })
|
||||
// },
|
||||
|
||||
// async message(msg) {
|
||||
// const type = msg.event
|
||||
|
||||
// if (type === 'delete') {
|
||||
// const activitypub_id = String(msg.data)
|
||||
// const event = await Comment.findOne({ where: { activitypub_id } })
|
||||
// if (event) await event.destroy()
|
||||
// return
|
||||
// }
|
||||
|
||||
// const activitypub_id = String(msg.data.status.in_reply_to_id)
|
||||
// if (!activitypub_id) return
|
||||
// let event = await Event.findOne({ where: { activitypub_id } })
|
||||
// if (!event) {
|
||||
// // check for comment..
|
||||
// const comment = await Comment.findOne( { include: [Event], where: { activitypub_id }})
|
||||
// if (!comment) return
|
||||
// event = comment.event
|
||||
// }
|
||||
// await Comment.create({
|
||||
// activitypub_id: String(msg.data.status.id),
|
||||
// data: msg.data.status,
|
||||
// eventId: event.id
|
||||
// })
|
||||
// },
|
||||
// error(err) {
|
||||
// console.log('error ', err)
|
||||
// }
|
||||
// }
|
||||
|
||||
// setTimeout(botController.initialize, 5000)
|
||||
// module.exports = botController
|
||||
@@ -14,7 +14,7 @@ const settingsController = require('./controller/settings')
|
||||
const storage = require('./storage')
|
||||
const upload = multer({ storage })
|
||||
|
||||
const api = express()
|
||||
const api = express.Router()
|
||||
api.use(cookieParser())
|
||||
api.use(bodyParser.urlencoded({ extended: false }))
|
||||
api.use(bodyParser.json())
|
||||
@@ -100,15 +100,5 @@ api.get('/export/:type', exportController.export)
|
||||
// get events in this range
|
||||
api.get('/event/:month/:year', eventController.getAll)
|
||||
|
||||
// Handle 404
|
||||
api.use(function(req, res) {
|
||||
res.status(404).send('404: Page not Found')
|
||||
})
|
||||
|
||||
// Handle 500
|
||||
api.use(function(error, req, res, next) {
|
||||
res.status(500).send('500: Internal Server Error')
|
||||
})
|
||||
|
||||
|
||||
module.exports = api
|
||||
|
||||
Reference in New Issue
Block a user