import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants'
let Account: Sequelize.Model<AccountInstance, AccountAttributes>
-let loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
+let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
let load: AccountMethods.Load
let loadApplication: AccountMethods.LoadApplication
let loadByUUID: AccountMethods.LoadByUUID
fields: [ 'name' ]
},
{
- fields: [ 'podId' ]
+ fields: [ 'serverId' ]
},
{
fields: [ 'userId' ],
unique: true
},
{
- fields: [ 'name', 'podId', 'applicationId' ],
+ fields: [ 'name', 'serverId', 'applicationId' ],
unique: true
}
],
const classMethods = [
associate,
- loadAccountByPodAndUUID,
+ loadAccountByServerAndUUID,
loadApplication,
load,
loadByUUID,
// ---------------------------------------------------------------------------
function associate (models) {
- Account.belongsTo(models.Pod, {
+ Account.belongsTo(models.Server, {
foreignKey: {
- name: 'podId',
+ name: 'serverId',
allowNull: true
},
onDelete: 'cascade'
name: 'accountId',
allowNull: false
},
- as: 'following',
onDelete: 'cascade'
})
name: 'targetAccountId',
allowNull: false
},
- as: 'followers',
onDelete: 'cascade'
})
}
}
toFormattedJSON = function (this: AccountInstance) {
- let host = this.Pod ? this.Pod.host : CONFIG.WEBSERVER.HOST
+ let host = CONFIG.WEBSERVER.HOST
+ let score: number
+
+ if (this.Server) {
+ host = this.Server.host
+ score = this.Server.score as number
+ }
const json = {
id: this.id,
host,
- name: this.name
+ score,
+ name: this.name,
+ createdAt: this.createdAt,
+ updatedAt: this.updatedAt
}
return json
}
toActivityPubObject = function (this: AccountInstance) {
- const type = this.podId ? 'Application' as 'Application' : 'Person' as 'Person'
+ const type = this.serverId ? 'Application' as 'Application' : 'Person' as 'Person'
const json = {
type,
}
isOwned = function (this: AccountInstance) {
- return this.podId === null
+ return this.serverId === null
}
getFollowerSharedInboxUrls = function (this: AccountInstance) {
listOwned = function () {
const query: Sequelize.FindOptions<AccountAttributes> = {
where: {
- podId: null
+ serverId: null
}
}
},
include: [
{
- model: Account['sequelize'].models.Pod,
+ model: Account['sequelize'].models.Server,
required: true,
where: {
host
return Account.findOne(query)
}
-loadAccountByPodAndUUID = function (uuid: string, podId: number, transaction: Sequelize.Transaction) {
+loadAccountByServerAndUUID = function (uuid: string, serverId: number, transaction: Sequelize.Transaction) {
const query: Sequelize.FindOptions<AccountAttributes> = {
where: {
- podId,
+ serverId,
uuid
},
transaction