mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
minor on Event AP representation
This commit is contained in:
parent
57e5c6aabc
commit
e3832ab838
1 changed files with 8 additions and 8 deletions
|
@ -53,12 +53,11 @@ Resource.belongsTo(Event)
|
||||||
Event.hasMany(Event, { as: 'child', foreignKey: 'parentId' })
|
Event.hasMany(Event, { as: 'child', foreignKey: 'parentId' })
|
||||||
Event.belongsTo(Event, { as: 'parent' })
|
Event.belongsTo(Event, { as: 'parent' })
|
||||||
|
|
||||||
Event.prototype.toAP = function (username, locale, follower = []) {
|
Event.prototype.toAP = function (username, locale, to = []) {
|
||||||
const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_'))
|
const tags = this.tags && this.tags.map(t => t.tag.replace(/[ #]/g, '_'))
|
||||||
|
|
||||||
const plainDescription = htmlToText.fromString(this.description.replace('\n', '').slice(0, 1000))
|
const plainDescription = htmlToText.fromString(this.description.replace('\n', '').slice(0, 1000))
|
||||||
const summary = `
|
const summary = `
|
||||||
📍 ${this.place.name}
|
📍 ${this.place && this.place.name}
|
||||||
📅 ${moment.unix(this.start_datetime).locale(locale).format('dddd, D MMMM (HH:mm)')}
|
📅 ${moment.unix(this.start_datetime).locale(locale).format('dddd, D MMMM (HH:mm)')}
|
||||||
|
|
||||||
${plainDescription}
|
${plainDescription}
|
||||||
|
@ -78,6 +77,8 @@ Event.prototype.toAP = function (username, locale, follower = []) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
to.push('https://www.w3.org/ns/activitystreams#Public')
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: `${config.baseurl}/federation/m/${this.id}`,
|
id: `${config.baseurl}/federation/m/${this.id}`,
|
||||||
name: this.title,
|
name: this.title,
|
||||||
|
@ -86,7 +87,7 @@ Event.prototype.toAP = function (username, locale, follower = []) {
|
||||||
startTime: moment.unix(this.start_datetime).locale(locale).format(),
|
startTime: moment.unix(this.start_datetime).locale(locale).format(),
|
||||||
endTime: moment.unix(this.end_datetime).locale(locale).format(),
|
endTime: moment.unix(this.end_datetime).locale(locale).format(),
|
||||||
location: {
|
location: {
|
||||||
name: this.place.name
|
name: this.place && this.place.name
|
||||||
},
|
},
|
||||||
attachment,
|
attachment,
|
||||||
tag: tags.map(tag => ({
|
tag: tags.map(tag => ({
|
||||||
|
@ -96,10 +97,9 @@ Event.prototype.toAP = function (username, locale, follower = []) {
|
||||||
})),
|
})),
|
||||||
published: this.createdAt,
|
published: this.createdAt,
|
||||||
attributedTo: `${config.baseurl}/federation/u/${username}`,
|
attributedTo: `${config.baseurl}/federation/u/${username}`,
|
||||||
to: follower || [],
|
to,
|
||||||
cc: ['https://www.w3.org/ns/activitystreams#Public', `${config.baseurl}/federation/u/${username}/followers`],
|
cc: [`${config.baseurl}/federation/u/${username}/followers`],
|
||||||
summary,
|
summary
|
||||||
sensitive: false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue