From 608624252466acf9f1d9ee1c1170bd4fe4d18d18 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 11:00:25 +0100 Subject: Rename Pod -> Server --- server/models/account/account-follow.ts | 4 ++-- server/models/account/account-interface.ts | 11 ++++----- server/models/account/account.ts | 37 +++++++++++++++++++----------- 3 files changed, 30 insertions(+), 22 deletions(-) (limited to 'server/models/account') diff --git a/server/models/account/account-follow.ts b/server/models/account/account-follow.ts index 6d7592326..c940d7cd4 100644 --- a/server/models/account/account-follow.ts +++ b/server/models/account/account-follow.ts @@ -101,7 +101,7 @@ listFollowingForApi = function (id: number, start: number, count: number, sort: model: AccountFollow['sequelize'].models.Account, as: 'AccountFollowing', required: true, - include: [ AccountFollow['sequelize'].models.Pod ] + include: [ AccountFollow['sequelize'].models.Server ] } ] } @@ -125,7 +125,7 @@ listFollowersForApi = function (id: number, start: number, count: number, sort: model: AccountFollow[ 'sequelize' ].models.Account, required: true, as: 'AccountFollower', - include: [ AccountFollow['sequelize'].models.Pod ] + include: [ AccountFollow['sequelize'].models.Server ] }, { model: AccountFollow['sequelize'].models.Account, diff --git a/server/models/account/account-interface.ts b/server/models/account/account-interface.ts index ce1afec02..1a567fb7a 100644 --- a/server/models/account/account-interface.ts +++ b/server/models/account/account-interface.ts @@ -1,8 +1,7 @@ import * as Bluebird from 'bluebird' import * as Sequelize from 'sequelize' import { Account as FormattedAccount, ActivityPubActor } from '../../../shared' -import { ResultList } from '../../../shared/models/result-list.model' -import { PodInstance } from '../pod/pod-interface' +import { ServerInstance } from '../server/server-interface' import { VideoChannelInstance } from '../video/video-channel-interface' export namespace AccountMethods { @@ -11,7 +10,7 @@ export namespace AccountMethods { export type Load = (id: number) => Bluebird export type LoadByUUID = (uuid: string) => Bluebird export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird - export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird + export type LoadAccountByServerAndUUID = (uuid: string, serverId: number, transaction: Sequelize.Transaction) => Bluebird export type LoadLocalByName = (name: string) => Bluebird export type LoadByNameAndHost = (name: string, host: string) => Bluebird export type ListOwned = () => Bluebird @@ -27,7 +26,7 @@ export namespace AccountMethods { export interface AccountClass { loadApplication: AccountMethods.LoadApplication - loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID + loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID load: AccountMethods.Load loadByUUID: AccountMethods.LoadByUUID loadByUrl: AccountMethods.LoadByUrl @@ -51,7 +50,7 @@ export interface AccountAttributes { uuid?: string - podId?: number + serverId?: number userId?: number applicationId?: number } @@ -69,7 +68,7 @@ export interface AccountInstance extends AccountClass, AccountAttributes, Sequel createdAt: Date updatedAt: Date - Pod: PodInstance + Server: ServerInstance VideoChannels: VideoChannelInstance[] } diff --git a/server/models/account/account.ts b/server/models/account/account.ts index e90eaae5e..ee00c5aef 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -26,7 +26,7 @@ import { sendDeleteAccount } from '../../lib/activitypub/send-request' import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' let Account: Sequelize.Model -let loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID +let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID let load: AccountMethods.Load let loadApplication: AccountMethods.LoadApplication let loadByUUID: AccountMethods.LoadByUUID @@ -170,7 +170,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes fields: [ 'name' ] }, { - fields: [ 'podId' ] + fields: [ 'serverId' ] }, { fields: [ 'userId' ], @@ -181,7 +181,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes unique: true }, { - fields: [ 'name', 'podId', 'applicationId' ], + fields: [ 'name', 'serverId', 'applicationId' ], unique: true } ], @@ -191,7 +191,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes const classMethods = [ associate, - loadAccountByPodAndUUID, + loadAccountByServerAndUUID, loadApplication, load, loadByUUID, @@ -217,9 +217,9 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes // --------------------------------------------------------------------------- function associate (models) { - Account.belongsTo(models.Pod, { + Account.belongsTo(models.Server, { foreignKey: { - name: 'podId', + name: 'serverId', allowNull: true }, onDelete: 'cascade' @@ -278,19 +278,28 @@ function afterDestroy (account: AccountInstance) { } 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, @@ -317,7 +326,7 @@ toActivityPubObject = function (this: AccountInstance) { } isOwned = function (this: AccountInstance) { - return this.podId === null + return this.serverId === null } getFollowerSharedInboxUrls = function (this: AccountInstance) { @@ -356,7 +365,7 @@ getPublicKeyUrl = function (this: AccountInstance) { listOwned = function () { const query: Sequelize.FindOptions = { where: { - podId: null + serverId: null } } @@ -417,7 +426,7 @@ loadByNameAndHost = function (name: string, host: string) { }, include: [ { - model: Account['sequelize'].models.Pod, + model: Account['sequelize'].models.Server, required: true, where: { host @@ -440,10 +449,10 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) { 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 = { where: { - podId, + serverId, uuid }, transaction -- cgit v1.2.3