mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
use internal place id in AP place representation
This commit is contained in:
parent
4a6009eaab
commit
2de042daaa
3 changed files with 1 additions and 45 deletions
|
@ -93,7 +93,7 @@ module.exports = (sequelize, DataTypes) => {
|
|||
startTime: DateTime.fromSeconds(this.start_datetime, opt).toISO(),
|
||||
...( this.end_datetime ? { endTime : DateTime.fromSeconds(this.end_datetime, opt).toISO() } : {} ),
|
||||
location: {
|
||||
id: `${config.baseurl}/federation/p/${this.place.slug}`,
|
||||
id: this.place?.ap_id ?? `${config.baseurl}/federation/p/${this.place.id}`,
|
||||
type: 'Place',
|
||||
name: this.place.name,
|
||||
address: this.place.address,
|
||||
|
|
|
@ -6,11 +6,6 @@ module.exports = (sequelize, DataTypes) =>
|
|||
index: true,
|
||||
allowNull: false
|
||||
},
|
||||
slug: {
|
||||
type: DataTypes.STRING,
|
||||
index: true,
|
||||
unique: true
|
||||
},
|
||||
address: DataTypes.STRING,
|
||||
latitude: DataTypes.FLOAT,
|
||||
longitude: DataTypes.FLOAT,
|
||||
|
|
|
@ -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');
|
||||
*/
|
||||
}
|
||||
};
|
Loading…
Reference in a new issue