use internal place id in AP place representation

This commit is contained in:
lesion 2024-12-23 22:45:43 +01:00
parent 4a6009eaab
commit 2de042daaa
No known key found for this signature in database
GPG key ID: 352918250B012177
3 changed files with 1 additions and 45 deletions

View file

@ -93,7 +93,7 @@ module.exports = (sequelize, DataTypes) => {
startTime: DateTime.fromSeconds(this.start_datetime, opt).toISO(), startTime: DateTime.fromSeconds(this.start_datetime, opt).toISO(),
...( this.end_datetime ? { endTime : DateTime.fromSeconds(this.end_datetime, opt).toISO() } : {} ), ...( this.end_datetime ? { endTime : DateTime.fromSeconds(this.end_datetime, opt).toISO() } : {} ),
location: { location: {
id: `${config.baseurl}/federation/p/${this.place.slug}`, id: this.place?.ap_id ?? `${config.baseurl}/federation/p/${this.place.id}`,
type: 'Place', type: 'Place',
name: this.place.name, name: this.place.name,
address: this.place.address, address: this.place.address,

View file

@ -6,11 +6,6 @@ module.exports = (sequelize, DataTypes) =>
index: true, index: true,
allowNull: false allowNull: false
}, },
slug: {
type: DataTypes.STRING,
index: true,
unique: true
},
address: DataTypes.STRING, address: DataTypes.STRING,
latitude: DataTypes.FLOAT, latitude: DataTypes.FLOAT,
longitude: DataTypes.FLOAT, longitude: DataTypes.FLOAT,

View file

@ -1,39 +0,0 @@
const SequelizeSlugify = require('sequelize-slugify')
let Place = require('../api/models/place')
module.exports = {
up: async (queryInterface, Sequelize) => {
const transaction = await queryInterface.sequelize.transaction()
try {
await queryInterface.addColumn('places', 'slug', { type: Sequelize.STRING })
const place = Place(queryInterface.sequelize, Sequelize.DataTypes)
await SequelizeSlugify.slugifyModel(place, { source: ['name'], overwrite: false })
const places = await place.findAll({transaction })
for(const place of places) {
await place.regenerateSlug(transaction)
await place.save()
}
await queryInterface.changeColumn('places', 'slug', {
type: Sequelize.STRING,
index: true,
unique: true
})
await transaction.commit()
} catch (e) {
console.error(e)
if (transaction) {
await transaction.rollback()
}
return Promise.reject(e)
}
},
down: (queryInterface, Sequelize) => {
/**
* Add reverting commands here.
*
* Example:
* await queryInterface.dropTable('users');
*/
}
};