default fedi hashtags has to be merged with event's tags

This commit is contained in:
lesion 2024-10-31 12:23:34 +01:00
parent da0aab13d7
commit 4376061191
No known key found for this signature in database
GPG key ID: 352918250B012177

View file

@ -1,3 +1,4 @@
const union = require('lodash/union')
const config = require('../../config') const config = require('../../config')
const { DateTime } = require('luxon') const { DateTime } = require('luxon')
@ -71,21 +72,19 @@ module.exports = (sequelize, DataTypes) => {
}) })
} }
let tags = this.tags?.map(tag => ({ let tags = this.tags.map(tag => tag.tag)
type: 'Hashtag',
name: '#' + tag.tag,
href: `${config.baseurl}/tag/${tag.tag}`
})) ?? []
// add default fedi hashtags if needed on local events only // add default fedi hashtags if needed on local events only
if (!this.ap_id && settings.default_fedi_hashtags.length) { if (!this.ap_id && settings.default_fedi_hashtags.length) {
settings.default_fedi_hashtags.foreach(t => tags.push({ tags = union(tags, settings.default_fedi_hashtags)
type: 'Hashtag',
name: '#' + t,
href: `${config.baseurl}/tag/${t}`
}))
} }
tags = tags?.map(tag => ({
type: 'Hashtag',
name: '#' + tag,
href: `${config.baseurl}/tag/${tag}`
})) ?? []
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,