diff --git a/config/default.json b/config/default.json index f13441e2..d465c4a0 100644 --- a/config/default.json +++ b/config/default.json @@ -20,6 +20,6 @@ "secure": true, "host": "" }, - "admin": "info@gancio.org", + "admin_email": "admin", "secret": "notsosecret" } diff --git a/pages/event/_id.vue b/pages/event/_id.vue index d36e901a..95e9eaf4 100644 --- a/pages/event/_id.vue +++ b/pages/event/_id.vue @@ -44,7 +44,7 @@ small.float-right 🔖 {{event.likes.length}} small.float-right.mr-3 ✊ {{event.boost.length}}
strong {{$tc('common.comments', event.comments.length)}} - - {{$t('event.interact_with_me_at')}} {{event.user && event.user.username}}@{{settings.baseurl|url2host}} + {{$t('event.interact_with_me_at')}} {{fedi_user}}@{{settings.baseurl|url2host}} .card-header(v-for='comment in event.comments' :key='comment.id') a.float-right(:href='comment.data.url') @@ -133,6 +133,10 @@ export default { computed: { ...mapGetters(['filteredEvents']), ...mapState(['settings']), + fedi_user () { + // TODO: + return this.settings.fedi_admin + }, next () { let found = false const event = this.filteredEvents.find(e => { diff --git a/server/api/controller/settings.js b/server/api/controller/settings.js index 39e06c07..9dc62d3a 100644 --- a/server/api/controller/settings.js +++ b/server/api/controller/settings.js @@ -1,4 +1,4 @@ -const { setting: Setting } = require('../models') +const { setting: Setting, user: User } = require('../models') const config = require('config') const consola = require('consola') const path = require('path') @@ -26,6 +26,12 @@ const settingsController = { } }) + // set fediverse admin actor + const fedi_admin = await User.findOne({ where: { email: config.admin_email }}) + if (fedi_admin) { + settingsController.settings['fedi_admin'] = fedi_admin.username + } + // // initialize user_locale if (config.user_locale && fs.existsSync(path.resolve(config.user_locale))) { const user_locale = fs.readdirSync(path.resolve(config.user_locale)) diff --git a/server/api/models/event.js b/server/api/models/event.js index 6a71f0ac..eb0b572e 100644 --- a/server/api/models/event.js +++ b/server/api/models/event.js @@ -38,7 +38,8 @@ module.exports = (sequelize, DataTypes) => { // event.prototype.toAP = function (username, follower = []) { - const tags = this.tags && this.tags.map(t => '#' + t.tag).join(' ') + const tags = this.tags && this.tags.map(t => ``).join(' ') + const content = `${this.title}
📍${this.place.name}
⏰ ${moment.unix(this.start_datetime).format('dddd, D MMMM (HH:mm)')}

@@ -57,13 +58,14 @@ module.exports = (sequelize, DataTypes) => { } return { - type: 'Note', id: `${config.baseurl}/federation/m/${this.id}`, url: `${config.baseurl}/federation/m/${this.id}`, - attachment, + type: 'Note', + // attachment, tag: this.tags.map(tag => ({ type: 'Hashtag', - name: '#' + tag.tag + name: '#' + tag.tag, + href: '/tags/' + tag.tag })), published: this.createdAt, attributedTo: `${config.baseurl}/federation/u/${username}`, @@ -72,7 +74,12 @@ module.exports = (sequelize, DataTypes) => { content, summary: null, sensitive: false, - // } + startTime: moment.unix(this.start_datetime), + location: { + type: 'Place', + name: this.place.name, + address: this.place.address + } } } diff --git a/server/federation/helpers.js b/server/federation/helpers.js index 334ad271..08697a63 100644 --- a/server/federation/helpers.js +++ b/server/federation/helpers.js @@ -85,10 +85,15 @@ const Helpers = { // object: event.toAP(instanceAdmin.username, [`${config.baseurl}/federation/u/${instanceAdmin.username}/followers`, ...recipients[sharedInbox]]) object: event.toAP(instanceAdmin.username, recipients[sharedInbox]) } - body['@context'] = 'https://www.w3.org/ns/activitystreams' + body['@context'] = [ + 'https://www.w3.org/ns/activitystreams', + 'https://w3id.org/security/v1', + { Hashtag: 'as:Hashtag' } ] Helpers.signAndSend(body, instanceAdmin, sharedInbox) } + return + // TODO // in case the event is published by the Admin itself do not add user if (instanceAdmin.id === user.id) { debug('Event published by instance Admin') diff --git a/server/firstrun.js b/server/firstrun.js index 02968596..b3595e79 100644 --- a/server/firstrun.js +++ b/server/firstrun.js @@ -45,7 +45,7 @@ module.exports = { await db.user.create({ email: admin.email, password: admin.password, - username: admin.email, + username: config.title.toLowerCase().replace(/ /g, ''), display_name: config.title, is_admin: true, is_active: true