add default fedi hashtags to AP representation on local events

This commit is contained in:
lesion 2024-10-31 11:57:34 +01:00
parent 1260d6715d
commit da0aab13d7
No known key found for this signature in database
GPG key ID: 352918250B012177
2 changed files with 16 additions and 6 deletions

View file

@ -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 { return {
id: this?.ap_id ?? `${config.baseurl}/federation/m/${this.id}`, id: this?.ap_id ?? `${config.baseurl}/federation/m/${this.id}`,
name: this.title, name: this.title,
@ -86,11 +101,7 @@ module.exports = (sequelize, DataTypes) => {
longitude: this.place.longitude longitude: this.place.longitude
}, },
attachment, attachment,
tag: this.tags && this.tags.map(tag => ({ tag: tags,
type: 'Hashtag',
name: '#' + tag.tag,
href: `${config.baseurl}/tag/${tag.tag}`
})),
published: this.createdAt, published: this.createdAt,
...( type != 'Create' ? { updated: this.updatedAt } : {} ), ...( type != 'Create' ? { updated: this.updatedAt } : {} ),
attributedTo: `${config.baseurl}/federation/u/${username}`, attributedTo: `${config.baseurl}/federation/u/${username}`,

View file

@ -165,7 +165,6 @@ const Helpers = {
"@id": "toot:focalPoint" "@id": "toot:focalPoint"
} }
}] }]
body.object.tag.push({type: 'Hashtag', name: config.default_fedi_hashtag, href: `/tags/${config.default_fedi_hashtag}`})
const task = new Task({ const task = new Task({
name: 'AP', name: 'AP',
method: Helpers.signAndSend, method: Helpers.signAndSend,