[lint] linting
This commit is contained in:
@@ -34,7 +34,7 @@ export default {
|
||||
return {
|
||||
password: '',
|
||||
email: '',
|
||||
loading: false,
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -61,7 +61,7 @@ export default {
|
||||
Message({ message: this.$t('login.check_email'), type: 'success' })
|
||||
},
|
||||
async submit (e) {
|
||||
if (this.disabled) return false
|
||||
if (this.disabled) { return false }
|
||||
e.preventDefault()
|
||||
try {
|
||||
this.loading = true
|
||||
|
||||
@@ -27,7 +27,7 @@ export default {
|
||||
disable_gamification: {
|
||||
get () { return this.settings.disable_gamification },
|
||||
set (value) { this.setSetting({ key: 'disable_gamification', value }) }
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -57,7 +57,7 @@ export default {
|
||||
recurrent_event_visible: {
|
||||
get () { return this.settings.recurrent_event_visible },
|
||||
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: mapActions(['setSetting'])
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default [
|
||||
'Europe/Rome',
|
||||
'Europe/Paris',
|
||||
'Europe/Paris'
|
||||
]
|
||||
@@ -137,7 +137,7 @@ export default {
|
||||
due: 'alle',
|
||||
from: 'Dalle',
|
||||
image_too_big: 'Immagine troppo grande! Massimo 4M',
|
||||
interact_with_me_at: 'Seguimi nel fediverso su',
|
||||
interact_with_me_at: 'Seguimi nel fediverso su'
|
||||
},
|
||||
|
||||
admin: {
|
||||
|
||||
@@ -118,7 +118,6 @@ import List from '@/components/List'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
name: 'Add',
|
||||
name: 'newEvent',
|
||||
components: { List },
|
||||
validate ({ store }) {
|
||||
@@ -241,6 +240,7 @@ export default {
|
||||
} else if (freq === '1d') {
|
||||
return this.$t('event.recurrent_each_day')
|
||||
}
|
||||
return
|
||||
},
|
||||
todayEvents () {
|
||||
if (this.event.type === 'multidate') {
|
||||
@@ -250,11 +250,11 @@ export default {
|
||||
return this.events.filter(e =>
|
||||
!e.multidate
|
||||
? date_start.isSame(moment.unix(e.start_datetime), 'day') ||
|
||||
date_start.isBefore(moment.unix(e.start_dateime)) && date_end.isAfter(moment.unix(e.start_datetime))
|
||||
(date_start.isBefore(moment.unix(e.start_dateime)) && date_end.isAfter(moment.unix(e.start_datetime)))
|
||||
: date_start.isSame(moment.unix(e.start_datetime), 'day') || date_start.isSame(moment.unix(e.end_datetime)) ||
|
||||
date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime)))
|
||||
(date_start.isAfter(moment.unix(e.start_datetime)) && date_start.isBefore(moment.unix(e.end_datetime))))
|
||||
} else if (this.event.type === 'recurrent') {
|
||||
|
||||
return []
|
||||
} else {
|
||||
const date = moment(this.date)
|
||||
return this.events.filter(e =>
|
||||
@@ -292,13 +292,17 @@ export default {
|
||||
switch (Number(this.activeTab)) {
|
||||
case 0 + t:
|
||||
return true
|
||||
break
|
||||
case 1 + t:
|
||||
return this.event.title.length > 0
|
||||
break
|
||||
case 2 + t:
|
||||
return this.event.place.name.length > 0 &&
|
||||
this.event.place.address.length > 0
|
||||
break
|
||||
case 3 + t:
|
||||
if (this.date && this.time.start) { return true }
|
||||
break
|
||||
case 4 + t:
|
||||
return this.event.place.name.length > 0 &&
|
||||
this.event.place.address.length > 0 &&
|
||||
@@ -312,7 +316,7 @@ export default {
|
||||
recurrentDays () {
|
||||
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }
|
||||
const type = this.event.recurrent.type
|
||||
if (type === 'ordinal') { return map(this.date, d => moment(d).date()) } else if (type === 'weekday') { return map(this.date, moment(d).day() + 1) }
|
||||
if (type === 'ordinal') { return map(this.date, d => moment(d).date()) } else if (type === 'weekday') { return map(this.date, d => moment(d).day() + 1) }
|
||||
},
|
||||
next () {
|
||||
this.activeTab = String(Number(this.activeTab) + 1)
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { Message, MessageBox } from 'element-ui'
|
||||
import { mapState } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import Users from '../components/admin/Users'
|
||||
import Places from '../components/admin/Places'
|
||||
import Settings from '../components/admin/Settings'
|
||||
@@ -91,7 +91,7 @@ export default {
|
||||
paginatedEvents () {
|
||||
return this.events.slice((this.eventPage - 1) * this.perPage,
|
||||
this.eventPage * this.perPage)
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
preview (id) {
|
||||
|
||||
@@ -16,21 +16,20 @@
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Event from '../../components/Event'
|
||||
import moment from 'dayjs'
|
||||
import get from 'lodash/get'
|
||||
|
||||
export default {
|
||||
layout: 'event_iframe',
|
||||
components: { Event },
|
||||
data: {
|
||||
data () {
|
||||
return {
|
||||
loading: true
|
||||
}
|
||||
},
|
||||
async asyncData ({ $axios, params, error, store }) {
|
||||
try {
|
||||
const [ id, start_datetime ] = params.event_id.split('_')
|
||||
const event = await $axios.$get(`/event/${id}`)
|
||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||
event.end_datetime = event.end_datetime
|
||||
return { event, id: Number(id) }
|
||||
} catch (e) {
|
||||
error({ statusCode: 404, message: 'Event not found' })
|
||||
|
||||
@@ -2,10 +2,7 @@
|
||||
List(:events="events" :title='title')
|
||||
</template>
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import List from '../../components/List'
|
||||
import moment from 'dayjs'
|
||||
import get from 'lodash/get'
|
||||
|
||||
export default {
|
||||
layout: 'iframe',
|
||||
@@ -19,7 +16,6 @@ export default {
|
||||
const title = query.title
|
||||
const tags = query.tags
|
||||
const places = query.places
|
||||
const now = new Date()
|
||||
|
||||
let params = []
|
||||
if (places) { params.push(`places=${places}`) }
|
||||
|
||||
@@ -61,26 +61,29 @@
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { mapState, mapActions, mapGetters } from 'vuex'
|
||||
import { MessageBox } from 'element-ui'
|
||||
import { mapState, mapGetters } from 'vuex'
|
||||
import EventAdmin from './eventAdmin'
|
||||
import moment from 'dayjs'
|
||||
|
||||
export default {
|
||||
name: 'Event',
|
||||
transition: null,
|
||||
components: { EventAdmin },
|
||||
data () {
|
||||
return {
|
||||
copied: false
|
||||
}
|
||||
},
|
||||
components: { EventAdmin },
|
||||
head () {
|
||||
if (!this.event) { return {} }
|
||||
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate', type: 'application/rss+xml',
|
||||
title: `${this.settings.title} events tagged ${tag}`, href: this.settings.baseurl + `/feed/rss?tags=${tag}` }))
|
||||
const place_feed = { rel: 'alternate', type: 'application/rss+xml',
|
||||
title: `${this.settings.title} events @${this.event.place.name}`, href: this.settings.baseurl + `/feed/rss?places=${this.event.placeId}` }
|
||||
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate',
|
||||
type: 'application/rss+xml',
|
||||
title: `${this.settings.title} events tagged ${tag}`,
|
||||
href: this.settings.baseurl + `/feed/rss?tags=${tag}` }))
|
||||
const place_feed = { rel: 'alternate',
|
||||
type: 'application/rss+xml',
|
||||
title: `${this.settings.title} events @${this.event.place.name}`,
|
||||
href: this.settings.baseurl + `/feed/rss?places=${this.event.placeId}` }
|
||||
|
||||
return {
|
||||
title: `${this.settings.title} - ${this.event.title}`,
|
||||
@@ -88,10 +91,10 @@ export default {
|
||||
// hid is used as unique identifier. Do not use `vmid` for it as it will not work
|
||||
{ hid: 'description',
|
||||
name: 'description',
|
||||
content: this.event.description.replace("\n",'').slice(0, 1000) },
|
||||
content: this.event.description.replace('\n', '').slice(0, 1000) },
|
||||
{ hid: 'og-description',
|
||||
name: 'og:description',
|
||||
content: this.event.description.replace("\n",'').slice(0, 100) },
|
||||
content: this.event.description.replace('\n', '').slice(0, 100) },
|
||||
{ hid: 'og-title', property: 'og:title', content: this.event.title },
|
||||
{ hid: 'og-url', property: 'og:url', content: `${this.settings.baseurl}/event/${this.event.id}` },
|
||||
{ property: 'og:type', content: 'event' },
|
||||
@@ -103,7 +106,7 @@ export default {
|
||||
{ property: 'twitter:card', content: 'summary' },
|
||||
{ property: 'twitter:title', content: this.event.title },
|
||||
{ property: 'twitter:image', content: `${this.settings.baseurl}${this.imgPath}` },
|
||||
{ property: 'twitter:description', content: this.event.description.replace("\n",'').slice(0, 100) }
|
||||
{ property: 'twitter:description', content: this.event.description.replace('\n', '').slice(0, 100) }
|
||||
],
|
||||
link: [
|
||||
{ rel: 'image_src', href: `${this.settings.baseurl}${this.imgPath}` },
|
||||
@@ -118,7 +121,6 @@ export default {
|
||||
const [ id, start_datetime ] = params.id.split('_')
|
||||
const event = await $axios.$get(`/event/${id}`)
|
||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||
event.end_datetime = event.end_datetime
|
||||
const now = new Date()
|
||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||
store.commit('setEvents', events)
|
||||
@@ -169,10 +171,10 @@ export default {
|
||||
methods: {
|
||||
copyLink () {
|
||||
this.copied = true
|
||||
setTimeout(() => this.copied=false, 3000)
|
||||
setTimeout(() => { this.copied = false }, 3000)
|
||||
},
|
||||
comment_filter (value) {
|
||||
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
|
||||
return value.replace(/<a.*href="([^">]+).*>(?:.(?!<\/a>))*.<\/a>/, (orig, url) => {
|
||||
// get extension
|
||||
const ext = url.slice(-4)
|
||||
if (['.mp3', '.ogg'].includes(ext)) {
|
||||
@@ -181,7 +183,7 @@ export default {
|
||||
return orig
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -247,7 +249,6 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 768px) {
|
||||
#eventDetail {
|
||||
.menu {
|
||||
|
||||
@@ -53,11 +53,8 @@
|
||||
</template>
|
||||
<script>
|
||||
import { mapState, mapGetters } from 'vuex'
|
||||
import Calendar from '@/components/Calendar'
|
||||
import List from '@/components/List'
|
||||
import Search from '@/components/Search'
|
||||
|
||||
import { intersection } from 'lodash'
|
||||
import { Message } from 'element-ui'
|
||||
|
||||
export default {
|
||||
@@ -68,12 +65,6 @@ export default {
|
||||
title: `${this.settings.title} - ${this.$t('common.export')}`
|
||||
}
|
||||
},
|
||||
async asyncData ({ $axios, params, store }) {
|
||||
// get metadata just in case we are not coming from home
|
||||
if (store.state.tags.length) return
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
type: 'rss',
|
||||
@@ -81,6 +72,12 @@ export default {
|
||||
list: { title: 'Gancio' }
|
||||
}
|
||||
},
|
||||
async asyncData ({ $axios, params, store }) {
|
||||
// get metadata just in case we are not coming from home
|
||||
if (store.state.tags.length) { return }
|
||||
const { tags, places } = await $axios.$get('/event/meta')
|
||||
store.commit('update', { tags, places })
|
||||
},
|
||||
methods: {
|
||||
copy (msg) {
|
||||
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ', e))
|
||||
|
||||
@@ -13,9 +13,6 @@ import { mapState } from 'vuex'
|
||||
export default {
|
||||
name: 'Index',
|
||||
computed: mapState(['settings']),
|
||||
mounted (ctx) {
|
||||
moment.tz.setDefault(this.settings.instance_timezone)
|
||||
},
|
||||
async fetch ({ store, $axios }) {
|
||||
try {
|
||||
moment.tz.setDefault(store.state.settings.instance_timezone)
|
||||
@@ -28,6 +25,9 @@ export default {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
mounted (ctx) {
|
||||
moment.tz.setDefault(this.settings.instance_timezone)
|
||||
},
|
||||
components: { Nav, Home }
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -29,7 +29,7 @@ export default {
|
||||
methods: {
|
||||
async change_password () {
|
||||
try {
|
||||
const res = await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
|
||||
await this.$axios.$post('/user/recover_password', { recover_code: this.code, password: this.new_password })
|
||||
Message({
|
||||
showClose: true,
|
||||
type: 'success',
|
||||
|
||||
@@ -2,7 +2,6 @@ import Vue from 'vue'
|
||||
import moment from 'moment-timezone'
|
||||
|
||||
export default ({ app, store }) => {
|
||||
|
||||
// set timezone to instance_timezone!!
|
||||
// to show local time relative to event's place
|
||||
// not where in the worlds I'm looking at the page from
|
||||
|
||||
@@ -7,10 +7,9 @@ import messages from '../locales'
|
||||
Vue.use(VueI18n)
|
||||
|
||||
export default async ({ app, store, req }) => {
|
||||
|
||||
if (process.server) {
|
||||
store.commit('setLocale', req.settings.locale)
|
||||
if (req.settings.user_locale) store.commit('setUserLocale', req.settings.user_locale)
|
||||
if (req.settings.user_locale) { store.commit('setUserLocale', req.settings.user_locale) }
|
||||
}
|
||||
|
||||
if (store.state.user_locale) {
|
||||
|
||||
@@ -3,7 +3,7 @@ const moment = require('moment-timezone')
|
||||
const { Op } = require('sequelize')
|
||||
const lodash = require('lodash')
|
||||
const { event: Event, comment: Comment, tag: Tag, place: Place,
|
||||
user: User, notification: Notification, event_notification: EventNotification } = require('../models')
|
||||
user: User, notification: Notification } = require('../models')
|
||||
const Sequelize = require('sequelize')
|
||||
const exportController = require('./export')
|
||||
const debug = require('debug')('controller:event')
|
||||
@@ -142,7 +142,7 @@ const eventController = {
|
||||
async unconfirm (req, res) {
|
||||
const id = Number(req.params.event_id)
|
||||
const event = await Event.findByPk(id)
|
||||
if (!event) { return sendStatus(404) }
|
||||
if (!event) { return req.sendStatus(404) }
|
||||
|
||||
try {
|
||||
event.is_visible = false
|
||||
|
||||
@@ -200,7 +200,7 @@ const userController = {
|
||||
},
|
||||
|
||||
async current (req, res) {
|
||||
if (!req.user) return res.status(400).send('Not logged')
|
||||
if (!req.user) { return res.status(400).send('Not logged') }
|
||||
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
||||
res.json(user)
|
||||
},
|
||||
@@ -214,7 +214,7 @@ const userController = {
|
||||
|
||||
async update (req, res) {
|
||||
// user to modify
|
||||
user = await User.findByPk(req.body.id)
|
||||
const user = await User.findByPk(req.body.id)
|
||||
|
||||
if (!user) { return res.status(404).json({ success: false, message: 'User not found!' }) }
|
||||
|
||||
|
||||
@@ -21,10 +21,10 @@ api.use(cookieParser())
|
||||
api.use(bodyParser.urlencoded({ extended: false }))
|
||||
api.use(bodyParser.json())
|
||||
|
||||
const jwt = expressJwt({
|
||||
secret: config.secret,
|
||||
credentialsRequired: false,
|
||||
})
|
||||
// const jwt = expressJwt({
|
||||
// secret: config.secret,
|
||||
// credentialsRequired: false
|
||||
// })
|
||||
|
||||
// api.use(jwt)
|
||||
|
||||
@@ -95,7 +95,6 @@ api.get('/export/:type', exportController.export)
|
||||
// get events in this range
|
||||
api.get('/event/:month/:year', eventController.getAll)
|
||||
|
||||
|
||||
// Handle 404
|
||||
api.use((req, res) => {
|
||||
debug('404 Page not found: %s', req.path)
|
||||
|
||||
@@ -76,7 +76,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
cc: follower || [],
|
||||
content,
|
||||
summary: null,
|
||||
sensitive: false,
|
||||
sensitive: false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@ module.exports = (sequelize, DataTypes) => {
|
||||
object: DataTypes.JSON
|
||||
}, {})
|
||||
fed_users.associate = function (models) {
|
||||
fed_users.belongsTo(models.instances)
|
||||
// associations can be defined here
|
||||
};
|
||||
}
|
||||
return fed_users
|
||||
}
|
||||
15
server/api/models/instances.js
Normal file
15
server/api/models/instances.js
Normal file
@@ -0,0 +1,15 @@
|
||||
'use strict'
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const instances = sequelize.define('instances', {
|
||||
domain: DataTypes.STRING,
|
||||
name: DataTypes.STRING,
|
||||
blocked: DataTypes.BOOLEAN,
|
||||
data: DataTypes.JSON
|
||||
}, {})
|
||||
|
||||
instances.associate = function (models) {
|
||||
instances.hasMany(models.fed_users)
|
||||
}
|
||||
|
||||
return instances
|
||||
}
|
||||
@@ -7,7 +7,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
index: true,
|
||||
primaryKey: true
|
||||
},
|
||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false },
|
||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
|
||||
}, {})
|
||||
|
||||
tag.associate = function (models) {
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = (sequelize, DataTypes) => {
|
||||
recover_code: DataTypes.STRING,
|
||||
is_admin: DataTypes.BOOLEAN,
|
||||
is_active: DataTypes.BOOLEAN,
|
||||
rsa: DataTypes.JSON,
|
||||
rsa: DataTypes.JSON
|
||||
}, {
|
||||
scopes: {
|
||||
withoutPassword: {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const { event: Event, comment: Comment } = require('../api/models')
|
||||
const config = require('config')
|
||||
const debug = require('debug')('fediverse:comment')
|
||||
|
||||
module.exports = {
|
||||
@@ -7,7 +6,7 @@ module.exports = {
|
||||
const body = req.body
|
||||
// search for related event
|
||||
const inReplyTo = body.object.inReplyTo
|
||||
const match = inReplyTo.match('.*\/federation\/m\/(.*)')
|
||||
const match = inReplyTo.match('.*/federation/m/(.*)')
|
||||
if (!match || match.length < 2) {
|
||||
debug('Comment not found %s', inReplyTo)
|
||||
return res.status(404).send('Event not found!')
|
||||
|
||||
@@ -14,12 +14,12 @@ module.exports = {
|
||||
},
|
||||
|
||||
async unboost (req, res) {
|
||||
const match = req.body.object.match*`${config.baseurl}/federation/m/(.*)`)
|
||||
if (!match || match.length < 2) return res.status(404).send('Event not found!')
|
||||
const match = req.body.object.match(`${config.baseurl}/federation/m/(.*)`)
|
||||
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
|
||||
debug('unboost %s', match[1])
|
||||
const event = await Event.findByPk(Number(match[1]))
|
||||
if (!event) return res.status(404).send('Event not found!')
|
||||
await event.update({ boost: [...event.boost.filter(actor => actor !== body.actor )]})
|
||||
if (!event) { return res.status(404).send('Event not found!') }
|
||||
await event.update({ boost: event.boost.filter(actor => actor !== req.body.actor) })
|
||||
},
|
||||
|
||||
async bookmark (req, res) {
|
||||
@@ -40,7 +40,7 @@ module.exports = {
|
||||
const event = await Event.findByPk(Number(match[1]))
|
||||
debug('%s unbookmark %s (%d)', body.actor, event.title, event.likes.length)
|
||||
if (!event) { return res.status(404).send('Event not found!') }
|
||||
await event.update({ likes: [...event.likes.filter(actor => actor !== body.actor)] })
|
||||
await event.update({ likes: event.likes.filter(actor => actor !== body.actor) })
|
||||
res.sendStatus(201)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
return res.status(400).send('Bad things')
|
||||
}
|
||||
|
||||
if (req.fedi_user) await user.removeFollowers(req.fedi_user.id)
|
||||
if (req.fedi_user) { await user.removeFollowers(req.fedi_user.id) }
|
||||
debug('%s unfollowed by %s', username, body.actor)
|
||||
res.sendStatus(200)
|
||||
}
|
||||
|
||||
@@ -11,16 +11,16 @@ const settingsController = require('../api/controller/settings')
|
||||
const Helpers = {
|
||||
|
||||
// ignore unimplemented ping url from fediverse
|
||||
async spamFilter (req, res, next) {
|
||||
spamFilter (req, res, next) {
|
||||
const urlToIgnore = [
|
||||
'/api/v1/instance',
|
||||
'/api/meta',
|
||||
'/api/statusnet/version.json',
|
||||
'/api/gnusocial/version.json',
|
||||
'/api/statusnet/config.json',
|
||||
'/poco',
|
||||
'/poco'
|
||||
]
|
||||
if (urlToIgnore.includes(req.path)) return res.status(404).send('Not Found')
|
||||
if (urlToIgnore.includes(req.path)) { return res.status(404).send('Not Found') }
|
||||
next()
|
||||
},
|
||||
|
||||
@@ -69,7 +69,7 @@ const Helpers = {
|
||||
let recipients = {}
|
||||
instanceAdmin.followers.forEach(follower => {
|
||||
const sharedInbox = follower.object.endpoints.sharedInbox
|
||||
if (!recipients[sharedInbox]) recipients[sharedInbox] = []
|
||||
if (!recipients[sharedInbox]) { recipients[sharedInbox] = [] }
|
||||
recipients[sharedInbox].push(follower.ap_id)
|
||||
})
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@ const debug = require('debug')('federation')
|
||||
*/
|
||||
|
||||
router.use(cors())
|
||||
|
||||
// is federation enabled? middleware
|
||||
router.use((req, res, next) => {
|
||||
if(settingsController.settings.enable_federation) return next()
|
||||
if (settingsController.settings.enable_federation) { return next() }
|
||||
debug('Federation disabled!')
|
||||
res.status(401).send('Federation disabled')
|
||||
next(false)
|
||||
@@ -27,7 +29,7 @@ router.use(express.json({ type: ['application/json', 'application/activity+json'
|
||||
|
||||
router.get('/m/:event_id', async (req, res) => {
|
||||
const event_id = req.params.event_id
|
||||
if (req.accepts('html')) return res.redirect(301, `/event/${event_id}`)
|
||||
if (req.accepts('html')) { return res.redirect(301, `/event/${event_id}`) }
|
||||
|
||||
const event = await Event.findByPk(req.params.event_id, { include: [ User, Tag, Place ] })
|
||||
if (!event) { return res.status(404).send('Not found') }
|
||||
@@ -57,7 +59,7 @@ router.post('/u/:name/inbox', Helpers.verifySignature, async (req, res) => {
|
||||
Ego.boost(req, res)
|
||||
break
|
||||
case 'Note':
|
||||
console.error('This is a note ! I probably should not receive this')
|
||||
debug('This is a note! I probably should create a comment here')
|
||||
break
|
||||
case 'Like':
|
||||
Ego.bookmark(req, res)
|
||||
@@ -70,7 +72,7 @@ router.post('/u/:name/inbox', Helpers.verifySignature, async (req, res) => {
|
||||
if (b.object.type === 'Note' && b.object.inReplyTo) {
|
||||
await Comments.create(req, res)
|
||||
} else {
|
||||
console.error('Create what? ', b.object.type)
|
||||
debug('Create with unsupported Object or not a reply => %s ', b.object.type)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ const debug = require('debug')('fediverse:user')
|
||||
module.exports = {
|
||||
async get (req, res) {
|
||||
const name = req.params.name
|
||||
if (!name) return res.status(400).send('Bad request.')
|
||||
if (!name) { return res.status(400).send('Bad request.') }
|
||||
const user = await User.findOne({ where: { username: name } })
|
||||
if (!user) return res.status(404).send(`No record found for ${name}`)
|
||||
if (!user) { return res.status(404).send(`No record found for ${name}`) }
|
||||
const ret = {
|
||||
'@context': [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
@@ -44,9 +44,9 @@ module.exports = {
|
||||
const name = req.params.name
|
||||
const page = req.query.page
|
||||
debug('Retrieve %s followers', name)
|
||||
if (!name) return res.status(400).send('Bad request.')
|
||||
if (!name) { return res.status(400).send('Bad request.') }
|
||||
const user = await User.findOne({ where: { username: name }, include: { model: FedUsers, as: 'followers' } })
|
||||
if (!user) return res.status(404).send(`No record found for ${name}`)
|
||||
if (!user) { return res.status(404).send(`No record found for ${name}`) }
|
||||
|
||||
res.type('application/activity+json; charset=utf-8')
|
||||
|
||||
@@ -58,7 +58,7 @@ module.exports = {
|
||||
type: 'OrderedCollection',
|
||||
totalItems: user.followers.length,
|
||||
first: `${config.baseurl}/federation/u/${name}/followers?page=true`,
|
||||
last: `${config.baseurl}/federation/u/${name}/followers?page=true`,
|
||||
last: `${config.baseurl}/federation/u/${name}/followers?page=true`
|
||||
})
|
||||
}
|
||||
return res.json({
|
||||
@@ -75,13 +75,13 @@ module.exports = {
|
||||
const name = req.params.name
|
||||
const page = req.query.page
|
||||
|
||||
if (!name) return res.status(400).send('Bad request.')
|
||||
if (!name) { return res.status(400).send('Bad request.') }
|
||||
const user = await User.findOne({
|
||||
include: [ { model: Event, include: [ Place, Tag ] } ],
|
||||
where: { username: name }
|
||||
})
|
||||
|
||||
if (!user) return res.status(404).send(`No record found for ${name}`)
|
||||
if (!user) { return res.status(404).send(`No record found for ${name}`) }
|
||||
|
||||
debug('Inside outbox, should return all events from this user')
|
||||
|
||||
|
||||
@@ -10,12 +10,11 @@ const debug = require('debug')('webfinger')
|
||||
router.use(cors())
|
||||
router.use((req, res, next) => {
|
||||
// is federation enabled ?
|
||||
if (req.settings.enable_federation) return next()
|
||||
if (req.settings.enable_federation) { return next() }
|
||||
debug('Federation disabled')
|
||||
res.status(404).send('Federation disabled')
|
||||
})
|
||||
|
||||
|
||||
router.get('/webfinger', async (req, res) => {
|
||||
if (!req.query || !req.query.resource || !req.query.resource.includes('acct:')) {
|
||||
debug('Bad webfinger request => %s', resource.query)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -12,7 +12,8 @@ module.exports = {
|
||||
},
|
||||
weigth: {
|
||||
type: Sequelize.INTEGER,
|
||||
defaultValue: 0, allowNull: false
|
||||
defaultValue: 0,
|
||||
allowNull: false
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
@@ -28,4 +29,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('tags')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -8,7 +8,7 @@ module.exports = {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.STRING,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -26,4 +26,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('settings')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -8,7 +8,7 @@ module.exports = {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
username: {
|
||||
type: Sequelize.STRING,
|
||||
@@ -43,6 +43,6 @@ module.exports = {
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('users');
|
||||
return queryInterface.dropTable('users')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -32,19 +32,19 @@ module.exports = {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'places',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'SET NULL',
|
||||
onDelete: 'SET NULL'
|
||||
},
|
||||
userId: {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'users',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'SET NULL',
|
||||
onDelete: 'SET NULL'
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
@@ -60,4 +60,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('events')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -18,10 +18,10 @@ module.exports = {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'events',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'SET NULL',
|
||||
onDelete: 'SET NULL'
|
||||
},
|
||||
data: Sequelize.JSON,
|
||||
createdAt: {
|
||||
@@ -38,4 +38,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('comments')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -23,4 +23,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('fed_users')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -32,4 +32,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('user_followers')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
filters: Sequelize.JSON,
|
||||
email: Sequelize.STRING,
|
||||
@@ -33,4 +33,4 @@ module.exports = {
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('notifications')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -12,4 +12,4 @@ module.exports = {
|
||||
return queryInterface.removeIndex('notifications',
|
||||
['actions', 'type'])
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -16,25 +16,25 @@ module.exports = {
|
||||
primaryKey: true,
|
||||
references: {
|
||||
model: 'events',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
onDelete: 'CASCADE'
|
||||
},
|
||||
tagTag: {
|
||||
primaryKey: true,
|
||||
type: Sequelize.STRING,
|
||||
references: {
|
||||
model: 'tags',
|
||||
key: 'tag',
|
||||
key: 'tag'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
},
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('event_tags')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
'use strict';
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
@@ -16,20 +16,20 @@ module.exports = {
|
||||
primaryKey: true,
|
||||
references: {
|
||||
model: 'events',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
onDelete: 'CASCADE'
|
||||
},
|
||||
notificationId: {
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'notifications',
|
||||
key: 'id',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE',
|
||||
onDelete: 'CASCADE'
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
36
server/migrations/20191027130750-create-instances.js
Normal file
36
server/migrations/20191027130750-create-instances.js
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict'
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.createTable('instances', {
|
||||
id: {
|
||||
allowNull: false,
|
||||
autoIncrement: true,
|
||||
primaryKey: true,
|
||||
type: Sequelize.INTEGER
|
||||
},
|
||||
domain: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
name: {
|
||||
type: Sequelize.STRING
|
||||
},
|
||||
blocked: {
|
||||
type: Sequelize.BOOLEAN
|
||||
},
|
||||
data: {
|
||||
type: Sequelize.JSON
|
||||
},
|
||||
createdAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
},
|
||||
updatedAt: {
|
||||
allowNull: false,
|
||||
type: Sequelize.DATE
|
||||
}
|
||||
})
|
||||
},
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropTable('instances')
|
||||
}
|
||||
}
|
||||
19
server/migrations/20191027132035-fed_users_instances.js
Normal file
19
server/migrations/20191027132035-fed_users_instances.js
Normal file
@@ -0,0 +1,19 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface, Sequelize) => {
|
||||
return queryInterface.addColumn('fed_users', 'instanceId', {
|
||||
type: Sequelize.INTEGER,
|
||||
references: {
|
||||
model: 'instances',
|
||||
key: 'id'
|
||||
},
|
||||
onUpdate: 'CASCADE',
|
||||
onDelete: 'CASCADE'
|
||||
})
|
||||
},
|
||||
|
||||
down: (queryInterface, Sequelize) => {
|
||||
return queryInterface.dropColumn('fed_users', 'instanceId')
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ const { event: Event, notification: Notification, event_notification: EventNotif
|
||||
const eventController = require('./api/controller/event')
|
||||
|
||||
const notifier = {
|
||||
async sendNotification (notification, event) {
|
||||
sendNotification (notification, event) {
|
||||
const promises = []
|
||||
debug('Send %s notification %s', notification.type, notification.action)
|
||||
let p
|
||||
@@ -19,6 +19,7 @@ const notifier = {
|
||||
case 'admin_email':
|
||||
p = mail.send([config.smtp.auth.user, config.admin_email], 'event', { event, to_confirm: !event.is_visible, config, notification })
|
||||
promises.push(p)
|
||||
break
|
||||
case 'ap':
|
||||
p = fediverseHelpers.sendEvent(event, event.user, notification.action)
|
||||
promises.push(p)
|
||||
@@ -26,7 +27,7 @@ const notifier = {
|
||||
return Promise.all(promises)
|
||||
},
|
||||
async notifyEvent (action, eventId) {
|
||||
let event = await Event.findByPk(eventId, {
|
||||
const event = await Event.findByPk(eventId, {
|
||||
|
||||
include: [ Tag, Place, Notification, { model: User, include: { model: FedUsers, as: 'followers' } } ]
|
||||
})
|
||||
@@ -59,7 +60,7 @@ const notifier = {
|
||||
if (!event.place) { return }
|
||||
const notification = await Notification.findByPk(e.notificationId)
|
||||
try {
|
||||
await sendNotification(type, notification, event)
|
||||
await notifier.sendNotification(notification, event)
|
||||
e.status = 'sent'
|
||||
return e.save()
|
||||
} catch (err) {
|
||||
|
||||
@@ -148,7 +148,7 @@ export const mutations = {
|
||||
export const actions = {
|
||||
// this method is called server side only for each request
|
||||
// we use it to get configuration from db, setting locale, etc...
|
||||
async nuxtServerInit ({ commit }, { app, store, req }) {
|
||||
nuxtServerInit ({ commit }, { app, store, req }) {
|
||||
const settings = req.settings
|
||||
commit('setSettings', settings)
|
||||
// apply settings
|
||||
@@ -157,7 +157,7 @@ export const actions = {
|
||||
async updateEvents ({ commit }, page) {
|
||||
const month = moment().month()
|
||||
const year = moment().year()
|
||||
commit('setPast', page.year<year || page.year===year && page.month<=month )
|
||||
commit('setPast', page.year < year || (page.year === year && page.month <= month))
|
||||
const events = await this.$axios.$get(`/event/${page.month - 1}/${page.year}`)
|
||||
commit('setEvents', events)
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user