[lint] linting
This commit is contained in:
@@ -34,7 +34,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
password: '',
|
password: '',
|
||||||
email: '',
|
email: '',
|
||||||
loading: false,
|
loading: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -61,7 +61,7 @@ export default {
|
|||||||
Message({ message: this.$t('login.check_email'), type: 'success' })
|
Message({ message: this.$t('login.check_email'), type: 'success' })
|
||||||
},
|
},
|
||||||
async submit (e) {
|
async submit (e) {
|
||||||
if (this.disabled) return false
|
if (this.disabled) { return false }
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
try {
|
try {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ export default {
|
|||||||
disable_gamification: {
|
disable_gamification: {
|
||||||
get () { return this.settings.disable_gamification },
|
get () { return this.settings.disable_gamification },
|
||||||
set (value) { this.setSetting({ key: 'disable_gamification', value }) }
|
set (value) { this.setSetting({ key: 'disable_gamification', value }) }
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -57,7 +57,7 @@ export default {
|
|||||||
recurrent_event_visible: {
|
recurrent_event_visible: {
|
||||||
get () { return this.settings.recurrent_event_visible },
|
get () { return this.settings.recurrent_event_visible },
|
||||||
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
|
set (value) { this.setSetting({ key: 'recurrent_event_visible', value }) }
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
methods: mapActions(['setSetting'])
|
methods: mapActions(['setSetting'])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export default [
|
export default [
|
||||||
'Europe/Rome',
|
'Europe/Rome',
|
||||||
'Europe/Paris',
|
'Europe/Paris'
|
||||||
]
|
]
|
||||||
@@ -137,7 +137,7 @@ export default {
|
|||||||
due: 'alle',
|
due: 'alle',
|
||||||
from: 'Dalle',
|
from: 'Dalle',
|
||||||
image_too_big: 'Immagine troppo grande! Massimo 4M',
|
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: {
|
admin: {
|
||||||
|
|||||||
@@ -118,7 +118,6 @@ import List from '@/components/List'
|
|||||||
import { Message } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Add',
|
|
||||||
name: 'newEvent',
|
name: 'newEvent',
|
||||||
components: { List },
|
components: { List },
|
||||||
validate ({ store }) {
|
validate ({ store }) {
|
||||||
@@ -241,6 +240,7 @@ export default {
|
|||||||
} else if (freq === '1d') {
|
} else if (freq === '1d') {
|
||||||
return this.$t('event.recurrent_each_day')
|
return this.$t('event.recurrent_each_day')
|
||||||
}
|
}
|
||||||
|
return
|
||||||
},
|
},
|
||||||
todayEvents () {
|
todayEvents () {
|
||||||
if (this.event.type === 'multidate') {
|
if (this.event.type === 'multidate') {
|
||||||
@@ -250,11 +250,11 @@ export default {
|
|||||||
return this.events.filter(e =>
|
return this.events.filter(e =>
|
||||||
!e.multidate
|
!e.multidate
|
||||||
? date_start.isSame(moment.unix(e.start_datetime), 'day') ||
|
? 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.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') {
|
} else if (this.event.type === 'recurrent') {
|
||||||
|
return []
|
||||||
} else {
|
} else {
|
||||||
const date = moment(this.date)
|
const date = moment(this.date)
|
||||||
return this.events.filter(e =>
|
return this.events.filter(e =>
|
||||||
@@ -292,13 +292,17 @@ export default {
|
|||||||
switch (Number(this.activeTab)) {
|
switch (Number(this.activeTab)) {
|
||||||
case 0 + t:
|
case 0 + t:
|
||||||
return true
|
return true
|
||||||
|
break
|
||||||
case 1 + t:
|
case 1 + t:
|
||||||
return this.event.title.length > 0
|
return this.event.title.length > 0
|
||||||
|
break
|
||||||
case 2 + t:
|
case 2 + t:
|
||||||
return this.event.place.name.length > 0 &&
|
return this.event.place.name.length > 0 &&
|
||||||
this.event.place.address.length > 0
|
this.event.place.address.length > 0
|
||||||
|
break
|
||||||
case 3 + t:
|
case 3 + t:
|
||||||
if (this.date && this.time.start) { return true }
|
if (this.date && this.time.start) { return true }
|
||||||
|
break
|
||||||
case 4 + t:
|
case 4 + t:
|
||||||
return this.event.place.name.length > 0 &&
|
return this.event.place.name.length > 0 &&
|
||||||
this.event.place.address.length > 0 &&
|
this.event.place.address.length > 0 &&
|
||||||
@@ -312,7 +316,7 @@ export default {
|
|||||||
recurrentDays () {
|
recurrentDays () {
|
||||||
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }
|
if (this.event.type !== 'recurrent' || !this.date || !this.date.length) { return }
|
||||||
const type = this.event.recurrent.type
|
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 () {
|
next () {
|
||||||
this.activeTab = String(Number(this.activeTab) + 1)
|
this.activeTab = String(Number(this.activeTab) + 1)
|
||||||
|
|||||||
@@ -52,8 +52,8 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapActions } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import { Message, MessageBox } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
import Users from '../components/admin/Users'
|
import Users from '../components/admin/Users'
|
||||||
import Places from '../components/admin/Places'
|
import Places from '../components/admin/Places'
|
||||||
import Settings from '../components/admin/Settings'
|
import Settings from '../components/admin/Settings'
|
||||||
@@ -91,7 +91,7 @@ export default {
|
|||||||
paginatedEvents () {
|
paginatedEvents () {
|
||||||
return this.events.slice((this.eventPage - 1) * this.perPage,
|
return this.events.slice((this.eventPage - 1) * this.perPage,
|
||||||
this.eventPage * this.perPage)
|
this.eventPage * this.perPage)
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
preview (id) {
|
preview (id) {
|
||||||
|
|||||||
@@ -16,21 +16,20 @@
|
|||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
import { mapState } from 'vuex'
|
||||||
import Event from '../../components/Event'
|
import Event from '../../components/Event'
|
||||||
import moment from 'dayjs'
|
|
||||||
import get from 'lodash/get'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
layout: 'event_iframe',
|
layout: 'event_iframe',
|
||||||
components: { Event },
|
components: { Event },
|
||||||
data: {
|
data () {
|
||||||
loading: true
|
return {
|
||||||
|
loading: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async asyncData ({ $axios, params, error, store }) {
|
async asyncData ({ $axios, params, error, store }) {
|
||||||
try {
|
try {
|
||||||
const [ id, start_datetime ] = params.event_id.split('_')
|
const [ id, start_datetime ] = params.event_id.split('_')
|
||||||
const event = await $axios.$get(`/event/${id}`)
|
const event = await $axios.$get(`/event/${id}`)
|
||||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||||
event.end_datetime = event.end_datetime
|
|
||||||
return { event, id: Number(id) }
|
return { event, id: Number(id) }
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
error({ statusCode: 404, message: 'Event not found' })
|
error({ statusCode: 404, message: 'Event not found' })
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
List(:events="events" :title='title')
|
List(:events="events" :title='title')
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapState } from 'vuex'
|
|
||||||
import List from '../../components/List'
|
import List from '../../components/List'
|
||||||
import moment from 'dayjs'
|
|
||||||
import get from 'lodash/get'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
layout: 'iframe',
|
layout: 'iframe',
|
||||||
@@ -19,7 +16,6 @@ export default {
|
|||||||
const title = query.title
|
const title = query.title
|
||||||
const tags = query.tags
|
const tags = query.tags
|
||||||
const places = query.places
|
const places = query.places
|
||||||
const now = new Date()
|
|
||||||
|
|
||||||
let params = []
|
let params = []
|
||||||
if (places) { params.push(`places=${places}`) }
|
if (places) { params.push(`places=${places}`) }
|
||||||
|
|||||||
@@ -61,26 +61,29 @@
|
|||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapActions, mapGetters } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
import { MessageBox } from 'element-ui'
|
|
||||||
import EventAdmin from './eventAdmin'
|
import EventAdmin from './eventAdmin'
|
||||||
import moment from 'dayjs'
|
import moment from 'dayjs'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Event',
|
name: 'Event',
|
||||||
transition: null,
|
transition: null,
|
||||||
|
components: { EventAdmin },
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
copied: false
|
copied: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { EventAdmin },
|
|
||||||
head () {
|
head () {
|
||||||
if (!this.event) { return {} }
|
if (!this.event) { return {} }
|
||||||
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate', type: 'application/rss+xml',
|
const tags_feed = this.event.tags.map(tag => ({ rel: 'alternate',
|
||||||
title: `${this.settings.title} events tagged ${tag}`, href: this.settings.baseurl + `/feed/rss?tags=${tag}` }))
|
type: 'application/rss+xml',
|
||||||
const place_feed = { rel: 'alternate', type: 'application/rss+xml',
|
title: `${this.settings.title} events tagged ${tag}`,
|
||||||
title: `${this.settings.title} events @${this.event.place.name}`, href: this.settings.baseurl + `/feed/rss?places=${this.event.placeId}` }
|
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 {
|
return {
|
||||||
title: `${this.settings.title} - ${this.event.title}`,
|
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 is used as unique identifier. Do not use `vmid` for it as it will not work
|
||||||
{ hid: 'description',
|
{ hid: 'description',
|
||||||
name: 'description',
|
name: 'description',
|
||||||
content: this.event.description.replace("\n",'').slice(0, 1000) },
|
content: this.event.description.replace('\n', '').slice(0, 1000) },
|
||||||
{ hid: 'og-description',
|
{ hid: 'og-description',
|
||||||
name: '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-title', property: 'og:title', content: this.event.title },
|
||||||
{ hid: 'og-url', property: 'og:url', content: `${this.settings.baseurl}/event/${this.event.id}` },
|
{ hid: 'og-url', property: 'og:url', content: `${this.settings.baseurl}/event/${this.event.id}` },
|
||||||
{ property: 'og:type', content: 'event' },
|
{ property: 'og:type', content: 'event' },
|
||||||
@@ -99,11 +102,11 @@ export default {
|
|||||||
{ property: 'og:site_name', content: this.settings.title },
|
{ property: 'og:site_name', content: this.settings.title },
|
||||||
{ property: 'og:updated_time', content: moment.unix(this.event.start_datetime).format() },
|
{ property: 'og:updated_time', content: moment.unix(this.event.start_datetime).format() },
|
||||||
{ property: 'article:published_time', content: moment.unix(this.event.start_datetime).format() },
|
{ property: 'article:published_time', content: moment.unix(this.event.start_datetime).format() },
|
||||||
{ property: 'article:section', content: 'event'},
|
{ property: 'article:section', content: 'event' },
|
||||||
{ property: 'twitter:card', content: 'summary'},
|
{ property: 'twitter:card', content: 'summary' },
|
||||||
{ property: 'twitter:title', content: this.event.title },
|
{ property: 'twitter:title', content: this.event.title },
|
||||||
{ property: 'twitter:image', content: `${this.settings.baseurl}${this.imgPath}` },
|
{ 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: [
|
link: [
|
||||||
{ rel: 'image_src', href: `${this.settings.baseurl}${this.imgPath}` },
|
{ rel: 'image_src', href: `${this.settings.baseurl}${this.imgPath}` },
|
||||||
@@ -118,7 +121,6 @@ export default {
|
|||||||
const [ id, start_datetime ] = params.id.split('_')
|
const [ id, start_datetime ] = params.id.split('_')
|
||||||
const event = await $axios.$get(`/event/${id}`)
|
const event = await $axios.$get(`/event/${id}`)
|
||||||
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
event.start_datetime = start_datetime ? Number(start_datetime) : event.start_datetime
|
||||||
event.end_datetime = event.end_datetime
|
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
const events = await $axios.$get(`/event/${now.getMonth()}/${now.getFullYear()}`)
|
||||||
store.commit('setEvents', events)
|
store.commit('setEvents', events)
|
||||||
@@ -168,11 +170,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyLink () {
|
copyLink () {
|
||||||
this.copied=true
|
this.copied = true
|
||||||
setTimeout(() => this.copied=false, 3000)
|
setTimeout(() => { this.copied = false }, 3000)
|
||||||
},
|
},
|
||||||
comment_filter (value) {
|
comment_filter (value) {
|
||||||
return value.replace(/<a.*href="([^">]+).*>(?:.(?!\<\/a\>))*.<\/a>/, (orig, url) => {
|
return value.replace(/<a.*href="([^">]+).*>(?:.(?!<\/a>))*.<\/a>/, (orig, url) => {
|
||||||
// get extension
|
// get extension
|
||||||
const ext = url.slice(-4)
|
const ext = url.slice(-4)
|
||||||
if (['.mp3', '.ogg'].includes(ext)) {
|
if (['.mp3', '.ogg'].includes(ext)) {
|
||||||
@@ -181,7 +183,7 @@ export default {
|
|||||||
return orig
|
return orig
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@@ -247,7 +249,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@media only screen and (max-width: 768px) {
|
@media only screen and (max-width: 768px) {
|
||||||
#eventDetail {
|
#eventDetail {
|
||||||
.menu {
|
.menu {
|
||||||
|
|||||||
@@ -53,11 +53,8 @@
|
|||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { mapState, mapGetters } from 'vuex'
|
import { mapState, mapGetters } from 'vuex'
|
||||||
import Calendar from '@/components/Calendar'
|
|
||||||
import List from '@/components/List'
|
import List from '@/components/List'
|
||||||
import Search from '@/components/Search'
|
import Search from '@/components/Search'
|
||||||
|
|
||||||
import { intersection } from 'lodash'
|
|
||||||
import { Message } from 'element-ui'
|
import { Message } from 'element-ui'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -68,12 +65,6 @@ export default {
|
|||||||
title: `${this.settings.title} - ${this.$t('common.export')}`
|
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 () {
|
data () {
|
||||||
return {
|
return {
|
||||||
type: 'rss',
|
type: 'rss',
|
||||||
@@ -81,6 +72,12 @@ export default {
|
|||||||
list: { title: 'Gancio' }
|
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: {
|
methods: {
|
||||||
copy (msg) {
|
copy (msg) {
|
||||||
this.$copyText(msg).then(e => console.error('ok ', e)).catch(e => console.error('err ', e))
|
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 {
|
export default {
|
||||||
name: 'Index',
|
name: 'Index',
|
||||||
computed: mapState(['settings']),
|
computed: mapState(['settings']),
|
||||||
mounted (ctx) {
|
|
||||||
moment.tz.setDefault(this.settings.instance_timezone)
|
|
||||||
},
|
|
||||||
async fetch ({ store, $axios }) {
|
async fetch ({ store, $axios }) {
|
||||||
try {
|
try {
|
||||||
moment.tz.setDefault(store.state.settings.instance_timezone)
|
moment.tz.setDefault(store.state.settings.instance_timezone)
|
||||||
@@ -28,6 +25,9 @@ export default {
|
|||||||
console.error(e)
|
console.error(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted (ctx) {
|
||||||
|
moment.tz.setDefault(this.settings.instance_timezone)
|
||||||
|
},
|
||||||
components: { Nav, Home }
|
components: { Nav, Home }
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async change_password () {
|
async change_password () {
|
||||||
try {
|
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({
|
Message({
|
||||||
showClose: true,
|
showClose: true,
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default {
|
|||||||
},
|
},
|
||||||
async asyncData ({ $axios, params }) {
|
async asyncData ({ $axios, params }) {
|
||||||
const user = await $axios.$get('/auth/user')
|
const user = await $axios.$get('/auth/user')
|
||||||
return { user, username_editable: user.username.length===0 }
|
return { user, username_editable: user.username.length === 0 }
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(['settings']),
|
...mapState(['settings']),
|
||||||
@@ -77,8 +77,8 @@ export default {
|
|||||||
cancelButtonText: this.$t('common.cancel'),
|
cancelButtonText: this.$t('common.cancel'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
}).then(async () => {
|
}).then(async () => {
|
||||||
this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
|
this.user = await this.$axios.$put('/user', { ...this.user, password: this.password })
|
||||||
}).catch( e => {
|
}).catch(e => {
|
||||||
Message({ message: e, showClose: true, type: 'warning' })
|
Message({ message: e, showClose: true, type: 'warning' })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import Vue from 'vue'
|
|||||||
import moment from 'moment-timezone'
|
import moment from 'moment-timezone'
|
||||||
|
|
||||||
export default ({ app, store }) => {
|
export default ({ app, store }) => {
|
||||||
|
|
||||||
// set timezone to instance_timezone!!
|
// set timezone to instance_timezone!!
|
||||||
// to show local time relative to event's place
|
// to show local time relative to event's place
|
||||||
// not where in the worlds I'm looking at the page from
|
// not where in the worlds I'm looking at the page from
|
||||||
@@ -18,7 +17,7 @@ export default ({ app, store }) => {
|
|||||||
// shown in mobile homepage
|
// shown in mobile homepage
|
||||||
Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM'))
|
Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM'))
|
||||||
|
|
||||||
Vue.filter('to', value => moment().to(value.start_datetime*1000))
|
Vue.filter('to', value => moment().to(value.start_datetime * 1000))
|
||||||
// format event start/end datetime based on page
|
// format event start/end datetime based on page
|
||||||
Vue.filter('when', (event, where) => {
|
Vue.filter('when', (event, where) => {
|
||||||
moment.locale(store.state.locale)
|
moment.locale(store.state.locale)
|
||||||
|
|||||||
@@ -7,10 +7,9 @@ import messages from '../locales'
|
|||||||
Vue.use(VueI18n)
|
Vue.use(VueI18n)
|
||||||
|
|
||||||
export default async ({ app, store, req }) => {
|
export default async ({ app, store, req }) => {
|
||||||
|
|
||||||
if (process.server) {
|
if (process.server) {
|
||||||
store.commit('setLocale', req.settings.locale)
|
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) {
|
if (store.state.user_locale) {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ const moment = require('moment-timezone')
|
|||||||
const { Op } = require('sequelize')
|
const { Op } = require('sequelize')
|
||||||
const lodash = require('lodash')
|
const lodash = require('lodash')
|
||||||
const { event: Event, comment: Comment, tag: Tag, place: Place,
|
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 Sequelize = require('sequelize')
|
||||||
const exportController = require('./export')
|
const exportController = require('./export')
|
||||||
const debug = require('debug')('controller:event')
|
const debug = require('debug')('controller:event')
|
||||||
@@ -142,7 +142,7 @@ const eventController = {
|
|||||||
async unconfirm (req, res) {
|
async unconfirm (req, res) {
|
||||||
const id = Number(req.params.event_id)
|
const id = Number(req.params.event_id)
|
||||||
const event = await Event.findByPk(id)
|
const event = await Event.findByPk(id)
|
||||||
if (!event) { return sendStatus(404) }
|
if (!event) { return req.sendStatus(404) }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
event.is_visible = false
|
event.is_visible = false
|
||||||
@@ -219,7 +219,7 @@ const eventController = {
|
|||||||
{ start_datetime: { [Op.between]: [start.unix(), end.unix()] } }
|
{ start_datetime: { [Op.between]: [start.unix(), end.unix()] } }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
attributes: { exclude: ['createdAt', 'updatedAt', 'placeId' ] },
|
attributes: { exclude: [ 'createdAt', 'updatedAt', 'placeId' ] },
|
||||||
order: [[Tag, 'weigth', 'DESC']],
|
order: [[Tag, 'weigth', 'DESC']],
|
||||||
include: [
|
include: [
|
||||||
{ model: Comment, required: false, attributes: ['id'] },
|
{ model: Comment, required: false, attributes: ['id'] },
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ const exportController = {
|
|||||||
url: `${req.settings.baseurl}/event/${e.id}`,
|
url: `${req.settings.baseurl}/event/${e.id}`,
|
||||||
alarms: [{
|
alarms: [{
|
||||||
action: 'display',
|
action: 'display',
|
||||||
trigger: {hours: 1, before: true}
|
trigger: { hours: 1, before: true }
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ const userController = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async current (req, res) {
|
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' } })
|
const user = await User.findByPk(req.user.id, { include: { model: FedUsers, as: 'followers' } })
|
||||||
res.json(user)
|
res.json(user)
|
||||||
},
|
},
|
||||||
@@ -214,7 +214,7 @@ const userController = {
|
|||||||
|
|
||||||
async update (req, res) {
|
async update (req, res) {
|
||||||
// user to modify
|
// 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!' }) }
|
if (!user) { return res.status(404).json({ success: false, message: 'User not found!' }) }
|
||||||
|
|
||||||
|
|||||||
@@ -21,16 +21,16 @@ api.use(cookieParser())
|
|||||||
api.use(bodyParser.urlencoded({ extended: false }))
|
api.use(bodyParser.urlencoded({ extended: false }))
|
||||||
api.use(bodyParser.json())
|
api.use(bodyParser.json())
|
||||||
|
|
||||||
const jwt = expressJwt({
|
// const jwt = expressJwt({
|
||||||
secret: config.secret,
|
// secret: config.secret,
|
||||||
credentialsRequired: false,
|
// credentialsRequired: false
|
||||||
})
|
// })
|
||||||
|
|
||||||
// api.use(jwt)
|
// api.use(jwt)
|
||||||
|
|
||||||
// AUTH
|
// AUTH
|
||||||
api.post('/auth/login', userController.login)
|
api.post('/auth/login', userController.login)
|
||||||
api.get('/auth/user', fillUser, userController.current)
|
api.get('/auth/user', fillUser, userController.current)
|
||||||
|
|
||||||
api.post('/user/recover', userController.forgotPassword)
|
api.post('/user/recover', userController.forgotPassword)
|
||||||
api.post('/user/check_recover_code', userController.checkRecoverCode)
|
api.post('/user/check_recover_code', userController.checkRecoverCode)
|
||||||
@@ -38,7 +38,7 @@ api.post('/user/recover_password', userController.updatePasswordWithRecoverCode)
|
|||||||
|
|
||||||
// register and add users
|
// register and add users
|
||||||
api.post('/user/register', userController.register)
|
api.post('/user/register', userController.register)
|
||||||
api.post('/user', isAuth, isAdmin, userController.create)
|
api.post('/user', isAuth, isAdmin, userController.create)
|
||||||
|
|
||||||
// update user
|
// update user
|
||||||
api.put('/user', isAuth, userController.update)
|
api.put('/user', isAuth, userController.update)
|
||||||
@@ -95,7 +95,6 @@ api.get('/export/:type', exportController.export)
|
|||||||
// get events in this range
|
// get events in this range
|
||||||
api.get('/event/:month/:year', eventController.getAll)
|
api.get('/event/:month/:year', eventController.getAll)
|
||||||
|
|
||||||
|
|
||||||
// Handle 404
|
// Handle 404
|
||||||
api.use((req, res) => {
|
api.use((req, res) => {
|
||||||
debug('404 Page not found: %s', req.path)
|
debug('404 Page not found: %s', req.path)
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
cc: follower || [],
|
cc: follower || [],
|
||||||
content,
|
content,
|
||||||
summary: null,
|
summary: null,
|
||||||
sensitive: false,
|
sensitive: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,5 +10,5 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
}
|
}
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
return event_notification
|
return event_notification
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
},
|
},
|
||||||
object: DataTypes.JSON
|
object: DataTypes.JSON
|
||||||
}, {})
|
}, {})
|
||||||
fed_users.associate = function(models) {
|
fed_users.associate = function (models) {
|
||||||
|
fed_users.belongsTo(models.instances)
|
||||||
// associations can be defined here
|
// associations can be defined here
|
||||||
};
|
}
|
||||||
return fed_users
|
return fed_users
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,7 @@ let sequelize = null
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
sequelize = new Sequelize(config.db)
|
sequelize = new Sequelize(config.db)
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
consola.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`)
|
consola.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`)
|
||||||
process.exit(-1)
|
process.exit(-1)
|
||||||
}
|
}
|
||||||
|
|||||||
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,
|
index: true,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false },
|
weigth: { type: DataTypes.INTEGER, defaultValue: 0, allowNull: false }
|
||||||
}, {})
|
}, {})
|
||||||
|
|
||||||
tag.associate = function (models) {
|
tag.associate = function (models) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||||||
recover_code: DataTypes.STRING,
|
recover_code: DataTypes.STRING,
|
||||||
is_admin: DataTypes.BOOLEAN,
|
is_admin: DataTypes.BOOLEAN,
|
||||||
is_active: DataTypes.BOOLEAN,
|
is_active: DataTypes.BOOLEAN,
|
||||||
rsa: DataTypes.JSON,
|
rsa: DataTypes.JSON
|
||||||
}, {
|
}, {
|
||||||
scopes: {
|
scopes: {
|
||||||
withoutPassword: {
|
withoutPassword: {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
const { event: Event, comment: Comment } = require('../api/models')
|
const { event: Event, comment: Comment } = require('../api/models')
|
||||||
const config = require('config')
|
|
||||||
const debug = require('debug')('fediverse:comment')
|
const debug = require('debug')('fediverse:comment')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -7,7 +6,7 @@ module.exports = {
|
|||||||
const body = req.body
|
const body = req.body
|
||||||
// search for related event
|
// search for related event
|
||||||
const inReplyTo = body.object.inReplyTo
|
const inReplyTo = body.object.inReplyTo
|
||||||
const match = inReplyTo.match('.*\/federation\/m\/(.*)')
|
const match = inReplyTo.match('.*/federation/m/(.*)')
|
||||||
if (!match || match.length < 2) {
|
if (!match || match.length < 2) {
|
||||||
debug('Comment not found %s', inReplyTo)
|
debug('Comment not found %s', inReplyTo)
|
||||||
return res.status(404).send('Event not found!')
|
return res.status(404).send('Event not found!')
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async unboost (req, res) {
|
async unboost (req, res) {
|
||||||
const match = req.body.object.match*`${config.baseurl}/federation/m/(.*)`)
|
const match = req.body.object.match(`${config.baseurl}/federation/m/(.*)`)
|
||||||
if (!match || match.length < 2) return res.status(404).send('Event not found!')
|
if (!match || match.length < 2) { return res.status(404).send('Event not found!') }
|
||||||
debug('unboost %s', match[1])
|
debug('unboost %s', match[1])
|
||||||
const event = await Event.findByPk(Number(match[1]))
|
const event = await Event.findByPk(Number(match[1]))
|
||||||
if (!event) return res.status(404).send('Event not found!')
|
if (!event) { return res.status(404).send('Event not found!') }
|
||||||
await event.update({ boost: [...event.boost.filter(actor => actor !== body.actor )]})
|
await event.update({ boost: event.boost.filter(actor => actor !== req.body.actor) })
|
||||||
},
|
},
|
||||||
|
|
||||||
async bookmark (req, res) {
|
async bookmark (req, res) {
|
||||||
@@ -40,7 +40,7 @@ module.exports = {
|
|||||||
const event = await Event.findByPk(Number(match[1]))
|
const event = await Event.findByPk(Number(match[1]))
|
||||||
debug('%s unbookmark %s (%d)', body.actor, event.title, event.likes.length)
|
debug('%s unbookmark %s (%d)', body.actor, event.title, event.likes.length)
|
||||||
if (!event) { return res.status(404).send('Event not found!') }
|
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)
|
res.sendStatus(201)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ module.exports = {
|
|||||||
const body = req.body
|
const body = req.body
|
||||||
if (typeof body.object !== 'string') { return }
|
if (typeof body.object !== 'string') { return }
|
||||||
const username = body.object.replace(`${config.baseurl}/federation/u/`, '')
|
const username = body.object.replace(`${config.baseurl}/federation/u/`, '')
|
||||||
const user = await User.findOne({ where: { username }, include: { model: FedUsers, as: 'followers' }})
|
const user = await User.findOne({ where: { username }, include: { model: FedUsers, as: 'followers' } })
|
||||||
if (!user) { return res.status(404).send('User not found') }
|
if (!user) { return res.status(404).send('User not found') }
|
||||||
|
|
||||||
// check for duplicate
|
// check for duplicate
|
||||||
if (!user.followers.includes(body.actor)) {
|
if (!user.followers.includes(body.actor)) {
|
||||||
await user.addFollowers([req.fedi_user.id])
|
await user.addFollowers([req.fedi_user.id])
|
||||||
// await user.update({ followers: [...user.followers, body.actor] })
|
// await user.update({ followers: [...user.followers, body.actor] })
|
||||||
debug('%s followed by %s (%d)', username, body.actor, user.followers.length+1)
|
debug('%s followed by %s (%d)', username, body.actor, user.followers.length + 1)
|
||||||
} else {
|
} else {
|
||||||
debug('duplicate %s followed by %s', username, body.actor)
|
debug('duplicate %s followed by %s', username, body.actor)
|
||||||
}
|
}
|
||||||
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
async unfollow (req, res) {
|
async unfollow (req, res) {
|
||||||
const body = req.body
|
const body = req.body
|
||||||
const username = body.object.object.replace(`${config.baseurl}/federation/u/`, '')
|
const username = body.object.object.replace(`${config.baseurl}/federation/u/`, '')
|
||||||
const user = await User.findOne({ where: { username }, include: { model: FedUsers, as: 'followers'} })
|
const user = await User.findOne({ where: { username }, include: { model: FedUsers, as: 'followers' } })
|
||||||
if (!user) { return res.status(404).send('User not found') }
|
if (!user) { return res.status(404).send('User not found') }
|
||||||
|
|
||||||
if (body.actor !== body.object.actor || body.actor !== req.fedi_user.id) {
|
if (body.actor !== body.object.actor || body.actor !== req.fedi_user.id) {
|
||||||
@@ -45,7 +45,7 @@ module.exports = {
|
|||||||
return res.status(400).send('Bad things')
|
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)
|
debug('%s unfollowed by %s', username, body.actor)
|
||||||
res.sendStatus(200)
|
res.sendStatus(200)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,16 @@ const settingsController = require('../api/controller/settings')
|
|||||||
const Helpers = {
|
const Helpers = {
|
||||||
|
|
||||||
// ignore unimplemented ping url from fediverse
|
// ignore unimplemented ping url from fediverse
|
||||||
async spamFilter (req, res, next) {
|
spamFilter (req, res, next) {
|
||||||
const urlToIgnore = [
|
const urlToIgnore = [
|
||||||
'/api/v1/instance',
|
'/api/v1/instance',
|
||||||
'/api/meta',
|
'/api/meta',
|
||||||
'/api/statusnet/version.json',
|
'/api/statusnet/version.json',
|
||||||
'/api/gnusocial/version.json',
|
'/api/gnusocial/version.json',
|
||||||
'/api/statusnet/config.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()
|
next()
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -52,7 +52,7 @@ const Helpers = {
|
|||||||
debug('sign %s => %s', ret.status, await ret.text())
|
debug('sign %s => %s', ret.status, await ret.text())
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendEvent (event, user, type='Create') {
|
async sendEvent (event, user, type = 'Create') {
|
||||||
if (!settingsController.settings.enable_federation) {
|
if (!settingsController.settings.enable_federation) {
|
||||||
debug('event not send, federation disabled')
|
debug('event not send, federation disabled')
|
||||||
return
|
return
|
||||||
@@ -60,7 +60,7 @@ const Helpers = {
|
|||||||
|
|
||||||
// event is sent by user that published it and by the admin instance
|
// event is sent by user that published it and by the admin instance
|
||||||
// collect followers from admin and user
|
// collect followers from admin and user
|
||||||
const instanceAdmin = await User.findOne({ where: { email: config.admin_email }, include: { model: FedUsers, as: 'followers' } })
|
const instanceAdmin = await User.findOne({ where: { email: config.admin_email }, include: { model: FedUsers, as: 'followers' } })
|
||||||
if (!instanceAdmin || !instanceAdmin.username) {
|
if (!instanceAdmin || !instanceAdmin.username) {
|
||||||
debug('Instance admin not found (there is no user with email => %s)', config.admin_email)
|
debug('Instance admin not found (there is no user with email => %s)', config.admin_email)
|
||||||
return
|
return
|
||||||
@@ -69,18 +69,18 @@ const Helpers = {
|
|||||||
let recipients = {}
|
let recipients = {}
|
||||||
instanceAdmin.followers.forEach(follower => {
|
instanceAdmin.followers.forEach(follower => {
|
||||||
const sharedInbox = follower.object.endpoints.sharedInbox
|
const sharedInbox = follower.object.endpoints.sharedInbox
|
||||||
if (!recipients[sharedInbox]) recipients[sharedInbox] = []
|
if (!recipients[sharedInbox]) { recipients[sharedInbox] = [] }
|
||||||
recipients[sharedInbox].push(follower.ap_id)
|
recipients[sharedInbox].push(follower.ap_id)
|
||||||
})
|
})
|
||||||
|
|
||||||
for(const sharedInbox in recipients) {
|
for (const sharedInbox in recipients) {
|
||||||
debug('Notify %s with event %s (from admin %s) cc => %d', sharedInbox, event.title, instanceAdmin.username, recipients[sharedInbox].length)
|
debug('Notify %s with event %s (from admin %s) cc => %d', sharedInbox, event.title, instanceAdmin.username, recipients[sharedInbox].length)
|
||||||
const body = {
|
const body = {
|
||||||
id: `${config.baseurl}/federation/m/${event.id}#create`,
|
id: `${config.baseurl}/federation/m/${event.id}#create`,
|
||||||
type,
|
type,
|
||||||
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
||||||
cc: [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]],
|
cc: [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]],
|
||||||
//cc: recipients[sharedInbox],
|
// cc: recipients[sharedInbox],
|
||||||
actor: `${config.baseurl}/federation/u/${instanceAdmin.username}`,
|
actor: `${config.baseurl}/federation/u/${instanceAdmin.username}`,
|
||||||
// object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]])
|
// object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]])
|
||||||
object: event.toAP(instanceAdmin.username, recipients[sharedInbox])
|
object: event.toAP(instanceAdmin.username, recipients[sharedInbox])
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ const debug = require('debug')('federation')
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
router.use(cors())
|
router.use(cors())
|
||||||
|
|
||||||
|
// is federation enabled? middleware
|
||||||
router.use((req, res, next) => {
|
router.use((req, res, next) => {
|
||||||
if(settingsController.settings.enable_federation) return next()
|
if (settingsController.settings.enable_federation) { return next() }
|
||||||
debug('Federation disabled!')
|
debug('Federation disabled!')
|
||||||
res.status(401).send('Federation disabled')
|
res.status(401).send('Federation disabled')
|
||||||
next(false)
|
next(false)
|
||||||
@@ -27,7 +29,7 @@ router.use(express.json({ type: ['application/json', 'application/activity+json'
|
|||||||
|
|
||||||
router.get('/m/:event_id', async (req, res) => {
|
router.get('/m/:event_id', async (req, res) => {
|
||||||
const event_id = req.params.event_id
|
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 ] })
|
const event = await Event.findByPk(req.params.event_id, { include: [ User, Tag, Place ] })
|
||||||
if (!event) { return res.status(404).send('Not found') }
|
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)
|
Ego.boost(req, res)
|
||||||
break
|
break
|
||||||
case 'Note':
|
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
|
break
|
||||||
case 'Like':
|
case 'Like':
|
||||||
Ego.bookmark(req, res)
|
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) {
|
if (b.object.type === 'Note' && b.object.inReplyTo) {
|
||||||
await Comments.create(req, res)
|
await Comments.create(req, res)
|
||||||
} else {
|
} else {
|
||||||
console.error('Create what? ', b.object.type)
|
debug('Create with unsupported Object or not a reply => %s ', b.object.type)
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ const debug = require('debug')('fediverse:user')
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
async get (req, res) {
|
async get (req, res) {
|
||||||
const name = req.params.name
|
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 }})
|
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 = {
|
const ret = {
|
||||||
'@context': [
|
'@context': [
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
@@ -44,9 +44,9 @@ module.exports = {
|
|||||||
const name = req.params.name
|
const name = req.params.name
|
||||||
const page = req.query.page
|
const page = req.query.page
|
||||||
debug('Retrieve %s followers', name)
|
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' }})
|
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')
|
res.type('application/activity+json; charset=utf-8')
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ module.exports = {
|
|||||||
type: 'OrderedCollection',
|
type: 'OrderedCollection',
|
||||||
totalItems: user.followers.length,
|
totalItems: user.followers.length,
|
||||||
first: `${config.baseurl}/federation/u/${name}/followers?page=true`,
|
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({
|
return res.json({
|
||||||
@@ -66,7 +66,7 @@ module.exports = {
|
|||||||
id: `${config.baseurl}/federation/u/${name}/followers?page=${page}`,
|
id: `${config.baseurl}/federation/u/${name}/followers?page=${page}`,
|
||||||
type: 'OrderedCollectionPage',
|
type: 'OrderedCollectionPage',
|
||||||
totalItems: user.followers.length,
|
totalItems: user.followers.length,
|
||||||
partOf: `${config.baseurl}/federation/u/${name}/followers` ,
|
partOf: `${config.baseurl}/federation/u/${name}/followers`,
|
||||||
orderedItems: user.followers
|
orderedItems: user.followers
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -75,13 +75,13 @@ module.exports = {
|
|||||||
const name = req.params.name
|
const name = req.params.name
|
||||||
const page = req.query.page
|
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({
|
const user = await User.findOne({
|
||||||
include: [ { model: Event, include: [ Place, Tag ] } ],
|
include: [ { model: Event, include: [ Place, Tag ] } ],
|
||||||
where: { username: name }
|
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')
|
debug('Inside outbox, should return all events from this user')
|
||||||
|
|
||||||
@@ -105,7 +105,7 @@ module.exports = {
|
|||||||
id: `${config.baseurl}/federation/u/${name}/outbox?page=${page}`,
|
id: `${config.baseurl}/federation/u/${name}/outbox?page=${page}`,
|
||||||
type: 'OrderedCollectionPage',
|
type: 'OrderedCollectionPage',
|
||||||
totalItems: user.events.length,
|
totalItems: user.events.length,
|
||||||
partOf: `${config.baseurl}/federation/u/${name}/outbox` ,
|
partOf: `${config.baseurl}/federation/u/${name}/outbox`,
|
||||||
orderedItems: user.events.map(e => ({
|
orderedItems: user.events.map(e => ({
|
||||||
id: `${config.baseurl}/federation/m/${e.id}#create`,
|
id: `${config.baseurl}/federation/m/${e.id}#create`,
|
||||||
type: 'Create',
|
type: 'Create',
|
||||||
|
|||||||
@@ -10,12 +10,11 @@ const debug = require('debug')('webfinger')
|
|||||||
router.use(cors())
|
router.use(cors())
|
||||||
router.use((req, res, next) => {
|
router.use((req, res, next) => {
|
||||||
// is federation enabled ?
|
// is federation enabled ?
|
||||||
if (req.settings.enable_federation) return next()
|
if (req.settings.enable_federation) { return next() }
|
||||||
debug('Federation disabled')
|
debug('Federation disabled')
|
||||||
res.status(404).send('Federation disabled')
|
res.status(404).send('Federation disabled')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
router.get('/webfinger', async (req, res) => {
|
router.get('/webfinger', async (req, res) => {
|
||||||
if (!req.query || !req.query.resource || !req.query.resource.includes('acct:')) {
|
if (!req.query || !req.query.resource || !req.query.resource.includes('acct:')) {
|
||||||
debug('Bad webfinger request => %s', resource.query)
|
debug('Bad webfinger request => %s', resource.query)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ module.exports = {
|
|||||||
consola.info(`Save configuration to ${config_path}`)
|
consola.info(`Save configuration to ${config_path}`)
|
||||||
try {
|
try {
|
||||||
fs.writeFileSync(config_path, JSON.stringify(config, null, 2))
|
fs.writeFileSync(config_path, JSON.stringify(config, null, 2))
|
||||||
} catch(e) {
|
} catch (e) {
|
||||||
consola.warn(` ⚠️ ${e}. You can specify configuration path using '--config'`)
|
consola.warn(` ⚠️ ${e}. You can specify configuration path using '--config'`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ async function main () {
|
|||||||
await nuxt.ready()
|
await nuxt.ready()
|
||||||
}
|
}
|
||||||
nuxt.listen()
|
nuxt.listen()
|
||||||
consola.info('Listen on %s:%d , visit me here => %s', config.server.host, config.server.port, config.baseurl )
|
consola.info('Listen on %s:%d , visit me here => %s', config.server.host, config.server.port, config.baseurl)
|
||||||
|
|
||||||
// close connections/port/unix socket
|
// close connections/port/unix socket
|
||||||
function shutdown () {
|
function shutdown () {
|
||||||
|
|||||||
@@ -1,31 +1,32 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('tags',
|
return queryInterface.createTable('tags',
|
||||||
{
|
{
|
||||||
tag: {
|
tag: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
index: true,
|
index: true,
|
||||||
primaryKey: true
|
primaryKey: true
|
||||||
},
|
},
|
||||||
weigth: {
|
weigth: {
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER,
|
||||||
defaultValue: 0, allowNull: false
|
defaultValue: 0,
|
||||||
},
|
allowNull: false
|
||||||
createdAt: {
|
},
|
||||||
allowNull: false,
|
createdAt: {
|
||||||
type: Sequelize.DATE
|
allowNull: false,
|
||||||
},
|
type: Sequelize.DATE
|
||||||
updatedAt: {
|
},
|
||||||
allowNull: false,
|
updatedAt: {
|
||||||
type: Sequelize.DATE
|
allowNull: false,
|
||||||
}
|
type: Sequelize.DATE
|
||||||
})
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('tags')
|
return queryInterface.dropTable('tags')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,31 +1,31 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('places',
|
return queryInterface.createTable('places',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
unique: true,
|
unique: true,
|
||||||
index: true,
|
index: true,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
address: Sequelize.STRING,
|
address: Sequelize.STRING,
|
||||||
createdAt: {
|
createdAt: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: Sequelize.DATE
|
type: Sequelize.DATE
|
||||||
},
|
},
|
||||||
updatedAt: {
|
updatedAt: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: Sequelize.DATE
|
type: Sequelize.DATE
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -26,4 +26,4 @@ module.exports = {
|
|||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('settings')
|
return queryInterface.dropTable('settings')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -8,7 +8,7 @@ module.exports = {
|
|||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER
|
||||||
},
|
},
|
||||||
username: {
|
username: {
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
@@ -43,6 +43,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('users');
|
return queryInterface.dropTable('users')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,63 +1,63 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('events',
|
return queryInterface.createTable('events',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
autoIncrement: true
|
autoIncrement: true
|
||||||
},
|
|
||||||
title: Sequelize.STRING,
|
|
||||||
slug: Sequelize.STRING,
|
|
||||||
description: Sequelize.TEXT,
|
|
||||||
multidate: Sequelize.BOOLEAN,
|
|
||||||
start_datetime: {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
index: true
|
|
||||||
},
|
|
||||||
end_datetime: {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
index: true
|
|
||||||
},
|
|
||||||
image_path: Sequelize.STRING,
|
|
||||||
is_visible: Sequelize.BOOLEAN,
|
|
||||||
recurrent: Sequelize.JSON,
|
|
||||||
// parent: Sequelize.INTEGER
|
|
||||||
likes: { type: Sequelize.JSON, defaultValue: [] },
|
|
||||||
boost: { type: Sequelize.JSON, defaultValue: [] },
|
|
||||||
placeId: {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: 'places',
|
|
||||||
key: 'id',
|
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
title: Sequelize.STRING,
|
||||||
onDelete: 'SET NULL',
|
slug: Sequelize.STRING,
|
||||||
},
|
description: Sequelize.TEXT,
|
||||||
userId: {
|
multidate: Sequelize.BOOLEAN,
|
||||||
type: Sequelize.INTEGER,
|
start_datetime: {
|
||||||
references: {
|
type: Sequelize.INTEGER,
|
||||||
model: 'users',
|
index: true
|
||||||
key: 'id',
|
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
end_datetime: {
|
||||||
onDelete: 'SET NULL',
|
type: Sequelize.INTEGER,
|
||||||
},
|
index: true
|
||||||
createdAt: {
|
},
|
||||||
allowNull: false,
|
image_path: Sequelize.STRING,
|
||||||
type: Sequelize.DATE
|
is_visible: Sequelize.BOOLEAN,
|
||||||
},
|
recurrent: Sequelize.JSON,
|
||||||
updatedAt: {
|
// parent: Sequelize.INTEGER
|
||||||
allowNull: false,
|
likes: { type: Sequelize.JSON, defaultValue: [] },
|
||||||
type: Sequelize.DATE
|
boost: { type: Sequelize.JSON, defaultValue: [] },
|
||||||
}
|
placeId: {
|
||||||
})
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'places',
|
||||||
|
key: 'id'
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'SET NULL'
|
||||||
|
},
|
||||||
|
userId: {
|
||||||
|
type: Sequelize.INTEGER,
|
||||||
|
references: {
|
||||||
|
model: 'users',
|
||||||
|
key: 'id'
|
||||||
|
},
|
||||||
|
onUpdate: 'CASCADE',
|
||||||
|
onDelete: 'SET NULL'
|
||||||
|
},
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('events')
|
return queryInterface.dropTable('events')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,41 +1,41 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('comments',
|
return queryInterface.createTable('comments',
|
||||||
{
|
{
|
||||||
id: {
|
id: {
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
autoIncrement: true
|
autoIncrement: true
|
||||||
},
|
|
||||||
activitypub_id: {
|
|
||||||
type: Sequelize.STRING(18),
|
|
||||||
index: true,
|
|
||||||
unique: true
|
|
||||||
},
|
|
||||||
eventId: {
|
|
||||||
type: Sequelize.INTEGER,
|
|
||||||
references: {
|
|
||||||
model: 'events',
|
|
||||||
key: 'id',
|
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
activitypub_id: {
|
||||||
onDelete: 'SET NULL',
|
type: Sequelize.STRING(18),
|
||||||
},
|
index: true,
|
||||||
data: Sequelize.JSON,
|
unique: true
|
||||||
createdAt: {
|
},
|
||||||
allowNull: false,
|
eventId: {
|
||||||
type: Sequelize.DATE
|
type: Sequelize.INTEGER,
|
||||||
},
|
references: {
|
||||||
updatedAt: {
|
model: 'events',
|
||||||
allowNull: false,
|
key: 'id'
|
||||||
type: Sequelize.DATE
|
},
|
||||||
}
|
onUpdate: 'CASCADE',
|
||||||
})
|
onDelete: 'SET NULL'
|
||||||
|
},
|
||||||
|
data: Sequelize.JSON,
|
||||||
|
createdAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
},
|
||||||
|
updatedAt: {
|
||||||
|
allowNull: false,
|
||||||
|
type: Sequelize.DATE
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('comments')
|
return queryInterface.dropTable('comments')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -23,4 +23,4 @@ module.exports = {
|
|||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('fed_users')
|
return queryInterface.dropTable('fed_users')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -32,4 +32,4 @@ module.exports = {
|
|||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('user_followers')
|
return queryInterface.dropTable('user_followers')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.createTable('notifications',{
|
return queryInterface.createTable('notifications', {
|
||||||
id: {
|
id: {
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
autoIncrement: true,
|
autoIncrement: true,
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER
|
||||||
},
|
},
|
||||||
filters: Sequelize.JSON,
|
filters: Sequelize.JSON,
|
||||||
email: Sequelize.STRING,
|
email: Sequelize.STRING,
|
||||||
@@ -33,4 +33,4 @@ module.exports = {
|
|||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('notifications')
|
return queryInterface.dropTable('notifications')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -12,4 +12,4 @@ module.exports = {
|
|||||||
return queryInterface.removeIndex('notifications',
|
return queryInterface.removeIndex('notifications',
|
||||||
['actions', 'type'])
|
['actions', 'type'])
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -16,25 +16,25 @@ module.exports = {
|
|||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
references: {
|
references: {
|
||||||
model: 'events',
|
model: 'events',
|
||||||
key: 'id',
|
key: 'id'
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE'
|
||||||
},
|
},
|
||||||
tagTag: {
|
tagTag: {
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
type: Sequelize.STRING,
|
type: Sequelize.STRING,
|
||||||
references: {
|
references: {
|
||||||
model: 'tags',
|
model: 'tags',
|
||||||
key: 'tag',
|
key: 'tag'
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE'
|
||||||
},
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
down: (queryInterface, Sequelize) => {
|
down: (queryInterface, Sequelize) => {
|
||||||
return queryInterface.dropTable('event_tags')
|
return queryInterface.dropTable('event_tags')
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
'use strict';
|
'use strict'
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: (queryInterface, Sequelize) => {
|
up: (queryInterface, Sequelize) => {
|
||||||
@@ -16,20 +16,20 @@ module.exports = {
|
|||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
references: {
|
references: {
|
||||||
model: 'events',
|
model: 'events',
|
||||||
key: 'id',
|
key: 'id'
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
onUpdate: 'CASCADE',
|
||||||
onDelete: 'CASCADE',
|
onDelete: 'CASCADE'
|
||||||
},
|
},
|
||||||
notificationId: {
|
notificationId: {
|
||||||
primaryKey: true,
|
primaryKey: true,
|
||||||
type: Sequelize.INTEGER,
|
type: Sequelize.INTEGER,
|
||||||
references: {
|
references: {
|
||||||
model: 'notifications',
|
model: 'notifications',
|
||||||
key: 'id',
|
key: 'id'
|
||||||
},
|
},
|
||||||
onUpdate: 'CASCADE',
|
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 eventController = require('./api/controller/event')
|
||||||
|
|
||||||
const notifier = {
|
const notifier = {
|
||||||
async sendNotification (notification, event) {
|
sendNotification (notification, event) {
|
||||||
const promises = []
|
const promises = []
|
||||||
debug('Send %s notification %s', notification.type, notification.action)
|
debug('Send %s notification %s', notification.type, notification.action)
|
||||||
let p
|
let p
|
||||||
@@ -19,6 +19,7 @@ const notifier = {
|
|||||||
case 'admin_email':
|
case 'admin_email':
|
||||||
p = mail.send([config.smtp.auth.user, config.admin_email], 'event', { event, to_confirm: !event.is_visible, config, notification })
|
p = mail.send([config.smtp.auth.user, config.admin_email], 'event', { event, to_confirm: !event.is_visible, config, notification })
|
||||||
promises.push(p)
|
promises.push(p)
|
||||||
|
break
|
||||||
case 'ap':
|
case 'ap':
|
||||||
p = fediverseHelpers.sendEvent(event, event.user, notification.action)
|
p = fediverseHelpers.sendEvent(event, event.user, notification.action)
|
||||||
promises.push(p)
|
promises.push(p)
|
||||||
@@ -26,9 +27,9 @@ const notifier = {
|
|||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
},
|
},
|
||||||
async notifyEvent (action, eventId) {
|
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'}} ]
|
include: [ Tag, Place, Notification, { model: User, include: { model: FedUsers, as: 'followers' } } ]
|
||||||
})
|
})
|
||||||
|
|
||||||
debug('%s -> %s', action, event.title)
|
debug('%s -> %s', action, event.title)
|
||||||
@@ -59,7 +60,7 @@ const notifier = {
|
|||||||
if (!event.place) { return }
|
if (!event.place) { return }
|
||||||
const notification = await Notification.findByPk(e.notificationId)
|
const notification = await Notification.findByPk(e.notificationId)
|
||||||
try {
|
try {
|
||||||
await sendNotification(type, notification, event)
|
await notifier.sendNotification(notification, event)
|
||||||
e.status = 'sent'
|
e.status = 'sent'
|
||||||
return e.save()
|
return e.save()
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ export const mutations = {
|
|||||||
export const actions = {
|
export const actions = {
|
||||||
// this method is called server side only for each request
|
// this method is called server side only for each request
|
||||||
// we use it to get configuration from db, setting locale, etc...
|
// 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
|
const settings = req.settings
|
||||||
commit('setSettings', settings)
|
commit('setSettings', settings)
|
||||||
// apply settings
|
// apply settings
|
||||||
@@ -157,7 +157,7 @@ export const actions = {
|
|||||||
async updateEvents ({ commit }, page) {
|
async updateEvents ({ commit }, page) {
|
||||||
const month = moment().month()
|
const month = moment().month()
|
||||||
const year = moment().year()
|
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}`)
|
const events = await this.$axios.$get(`/event/${page.month - 1}/${page.year}`)
|
||||||
commit('setEvents', events)
|
commit('setEvents', events)
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user