diff --git a/server/api/models/event.js b/server/api/models/event.js index da344314..6e3ce599 100644 --- a/server/api/models/event.js +++ b/server/api/models/event.js @@ -71,6 +71,21 @@ module.exports = (sequelize, DataTypes) => { }) } + let tags = this.tags?.map(tag => ({ + type: 'Hashtag', + name: '#' + tag.tag, + href: `${config.baseurl}/tag/${tag.tag}` + })) ?? [] + + // add default fedi hashtags if needed on local events only + if (!this.ap_id && settings.default_fedi_hashtags.length) { + settings.default_fedi_hashtags.foreach(t => tags.push({ + type: 'Hashtag', + name: '#' + t, + href: `${config.baseurl}/tag/${t}` + })) + } + return { id: this?.ap_id ?? `${config.baseurl}/federation/m/${this.id}`, name: this.title, @@ -86,11 +101,7 @@ module.exports = (sequelize, DataTypes) => { longitude: this.place.longitude }, attachment, - tag: this.tags && this.tags.map(tag => ({ - type: 'Hashtag', - name: '#' + tag.tag, - href: `${config.baseurl}/tag/${tag.tag}` - })), + tag: tags, published: this.createdAt, ...( type != 'Create' ? { updated: this.updatedAt } : {} ), attributedTo: `${config.baseurl}/federation/u/${username}`, diff --git a/server/federation/helpers.js b/server/federation/helpers.js index 3ff4e3c3..d913e2b9 100644 --- a/server/federation/helpers.js +++ b/server/federation/helpers.js @@ -165,7 +165,6 @@ const Helpers = { "@id": "toot:focalPoint" } }] - body.object.tag.push({type: 'Hashtag', name: config.default_fedi_hashtag, href: `/tags/${config.default_fedi_hashtag}`}) const task = new Task({ name: 'AP', method: Helpers.signAndSend,