diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-15 11:00:25 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-27 19:40:51 +0100 |
commit | 608624252466acf9f1d9ee1c1170bd4fe4d18d18 (patch) | |
tree | 47eab55bb5421b7fe88e0b2ac743a436fd9561cf /server/models/account | |
parent | 51548b31815c6f96f314ae96588a9adca150519d (diff) | |
download | PeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.tar.gz PeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.tar.zst PeerTube-608624252466acf9f1d9ee1c1170bd4fe4d18d18.zip |
Rename Pod -> Server
Diffstat (limited to 'server/models/account')
-rw-r--r-- | server/models/account/account-follow.ts | 4 | ||||
-rw-r--r-- | server/models/account/account-interface.ts | 11 | ||||
-rw-r--r-- | server/models/account/account.ts | 37 |
3 files changed, 30 insertions, 22 deletions
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: | |||
101 | model: AccountFollow['sequelize'].models.Account, | 101 | model: AccountFollow['sequelize'].models.Account, |
102 | as: 'AccountFollowing', | 102 | as: 'AccountFollowing', |
103 | required: true, | 103 | required: true, |
104 | include: [ AccountFollow['sequelize'].models.Pod ] | 104 | include: [ AccountFollow['sequelize'].models.Server ] |
105 | } | 105 | } |
106 | ] | 106 | ] |
107 | } | 107 | } |
@@ -125,7 +125,7 @@ listFollowersForApi = function (id: number, start: number, count: number, sort: | |||
125 | model: AccountFollow[ 'sequelize' ].models.Account, | 125 | model: AccountFollow[ 'sequelize' ].models.Account, |
126 | required: true, | 126 | required: true, |
127 | as: 'AccountFollower', | 127 | as: 'AccountFollower', |
128 | include: [ AccountFollow['sequelize'].models.Pod ] | 128 | include: [ AccountFollow['sequelize'].models.Server ] |
129 | }, | 129 | }, |
130 | { | 130 | { |
131 | model: AccountFollow['sequelize'].models.Account, | 131 | 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 @@ | |||
1 | import * as Bluebird from 'bluebird' | 1 | import * as Bluebird from 'bluebird' |
2 | import * as Sequelize from 'sequelize' | 2 | import * as Sequelize from 'sequelize' |
3 | import { Account as FormattedAccount, ActivityPubActor } from '../../../shared' | 3 | import { Account as FormattedAccount, ActivityPubActor } from '../../../shared' |
4 | import { ResultList } from '../../../shared/models/result-list.model' | 4 | import { ServerInstance } from '../server/server-interface' |
5 | import { PodInstance } from '../pod/pod-interface' | ||
6 | import { VideoChannelInstance } from '../video/video-channel-interface' | 5 | import { VideoChannelInstance } from '../video/video-channel-interface' |
7 | 6 | ||
8 | export namespace AccountMethods { | 7 | export namespace AccountMethods { |
@@ -11,7 +10,7 @@ export namespace AccountMethods { | |||
11 | export type Load = (id: number) => Bluebird<AccountInstance> | 10 | export type Load = (id: number) => Bluebird<AccountInstance> |
12 | export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance> | 11 | export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance> |
13 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> | 12 | export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> |
14 | export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance> | 13 | export type LoadAccountByServerAndUUID = (uuid: string, serverId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance> |
15 | export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> | 14 | export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> |
16 | export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> | 15 | export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> |
17 | export type ListOwned = () => Bluebird<AccountInstance[]> | 16 | export type ListOwned = () => Bluebird<AccountInstance[]> |
@@ -27,7 +26,7 @@ export namespace AccountMethods { | |||
27 | 26 | ||
28 | export interface AccountClass { | 27 | export interface AccountClass { |
29 | loadApplication: AccountMethods.LoadApplication | 28 | loadApplication: AccountMethods.LoadApplication |
30 | loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID | 29 | loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID |
31 | load: AccountMethods.Load | 30 | load: AccountMethods.Load |
32 | loadByUUID: AccountMethods.LoadByUUID | 31 | loadByUUID: AccountMethods.LoadByUUID |
33 | loadByUrl: AccountMethods.LoadByUrl | 32 | loadByUrl: AccountMethods.LoadByUrl |
@@ -51,7 +50,7 @@ export interface AccountAttributes { | |||
51 | 50 | ||
52 | uuid?: string | 51 | uuid?: string |
53 | 52 | ||
54 | podId?: number | 53 | serverId?: number |
55 | userId?: number | 54 | userId?: number |
56 | applicationId?: number | 55 | applicationId?: number |
57 | } | 56 | } |
@@ -69,7 +68,7 @@ export interface AccountInstance extends AccountClass, AccountAttributes, Sequel | |||
69 | createdAt: Date | 68 | createdAt: Date |
70 | updatedAt: Date | 69 | updatedAt: Date |
71 | 70 | ||
72 | Pod: PodInstance | 71 | Server: ServerInstance |
73 | VideoChannels: VideoChannelInstance[] | 72 | VideoChannels: VideoChannelInstance[] |
74 | } | 73 | } |
75 | 74 | ||
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' | |||
26 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' | 26 | import { CONFIG, CONSTRAINTS_FIELDS } from '../../initializers/constants' |
27 | 27 | ||
28 | let Account: Sequelize.Model<AccountInstance, AccountAttributes> | 28 | let Account: Sequelize.Model<AccountInstance, AccountAttributes> |
29 | let loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID | 29 | let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID |
30 | let load: AccountMethods.Load | 30 | let load: AccountMethods.Load |
31 | let loadApplication: AccountMethods.LoadApplication | 31 | let loadApplication: AccountMethods.LoadApplication |
32 | let loadByUUID: AccountMethods.LoadByUUID | 32 | let loadByUUID: AccountMethods.LoadByUUID |
@@ -170,7 +170,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
170 | fields: [ 'name' ] | 170 | fields: [ 'name' ] |
171 | }, | 171 | }, |
172 | { | 172 | { |
173 | fields: [ 'podId' ] | 173 | fields: [ 'serverId' ] |
174 | }, | 174 | }, |
175 | { | 175 | { |
176 | fields: [ 'userId' ], | 176 | fields: [ 'userId' ], |
@@ -181,7 +181,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
181 | unique: true | 181 | unique: true |
182 | }, | 182 | }, |
183 | { | 183 | { |
184 | fields: [ 'name', 'podId', 'applicationId' ], | 184 | fields: [ 'name', 'serverId', 'applicationId' ], |
185 | unique: true | 185 | unique: true |
186 | } | 186 | } |
187 | ], | 187 | ], |
@@ -191,7 +191,7 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
191 | 191 | ||
192 | const classMethods = [ | 192 | const classMethods = [ |
193 | associate, | 193 | associate, |
194 | loadAccountByPodAndUUID, | 194 | loadAccountByServerAndUUID, |
195 | loadApplication, | 195 | loadApplication, |
196 | load, | 196 | load, |
197 | loadByUUID, | 197 | loadByUUID, |
@@ -217,9 +217,9 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes | |||
217 | // --------------------------------------------------------------------------- | 217 | // --------------------------------------------------------------------------- |
218 | 218 | ||
219 | function associate (models) { | 219 | function associate (models) { |
220 | Account.belongsTo(models.Pod, { | 220 | Account.belongsTo(models.Server, { |
221 | foreignKey: { | 221 | foreignKey: { |
222 | name: 'podId', | 222 | name: 'serverId', |
223 | allowNull: true | 223 | allowNull: true |
224 | }, | 224 | }, |
225 | onDelete: 'cascade' | 225 | onDelete: 'cascade' |
@@ -278,19 +278,28 @@ function afterDestroy (account: AccountInstance) { | |||
278 | } | 278 | } |
279 | 279 | ||
280 | toFormattedJSON = function (this: AccountInstance) { | 280 | toFormattedJSON = function (this: AccountInstance) { |
281 | let host = this.Pod ? this.Pod.host : CONFIG.WEBSERVER.HOST | 281 | let host = CONFIG.WEBSERVER.HOST |
282 | let score: number | ||
283 | |||
284 | if (this.Server) { | ||
285 | host = this.Server.host | ||
286 | score = this.Server.score as number | ||
287 | } | ||
282 | 288 | ||
283 | const json = { | 289 | const json = { |
284 | id: this.id, | 290 | id: this.id, |
285 | host, | 291 | host, |
286 | name: this.name | 292 | score, |
293 | name: this.name, | ||
294 | createdAt: this.createdAt, | ||
295 | updatedAt: this.updatedAt | ||
287 | } | 296 | } |
288 | 297 | ||
289 | return json | 298 | return json |
290 | } | 299 | } |
291 | 300 | ||
292 | toActivityPubObject = function (this: AccountInstance) { | 301 | toActivityPubObject = function (this: AccountInstance) { |
293 | const type = this.podId ? 'Application' as 'Application' : 'Person' as 'Person' | 302 | const type = this.serverId ? 'Application' as 'Application' : 'Person' as 'Person' |
294 | 303 | ||
295 | const json = { | 304 | const json = { |
296 | type, | 305 | type, |
@@ -317,7 +326,7 @@ toActivityPubObject = function (this: AccountInstance) { | |||
317 | } | 326 | } |
318 | 327 | ||
319 | isOwned = function (this: AccountInstance) { | 328 | isOwned = function (this: AccountInstance) { |
320 | return this.podId === null | 329 | return this.serverId === null |
321 | } | 330 | } |
322 | 331 | ||
323 | getFollowerSharedInboxUrls = function (this: AccountInstance) { | 332 | getFollowerSharedInboxUrls = function (this: AccountInstance) { |
@@ -356,7 +365,7 @@ getPublicKeyUrl = function (this: AccountInstance) { | |||
356 | listOwned = function () { | 365 | listOwned = function () { |
357 | const query: Sequelize.FindOptions<AccountAttributes> = { | 366 | const query: Sequelize.FindOptions<AccountAttributes> = { |
358 | where: { | 367 | where: { |
359 | podId: null | 368 | serverId: null |
360 | } | 369 | } |
361 | } | 370 | } |
362 | 371 | ||
@@ -417,7 +426,7 @@ loadByNameAndHost = function (name: string, host: string) { | |||
417 | }, | 426 | }, |
418 | include: [ | 427 | include: [ |
419 | { | 428 | { |
420 | model: Account['sequelize'].models.Pod, | 429 | model: Account['sequelize'].models.Server, |
421 | required: true, | 430 | required: true, |
422 | where: { | 431 | where: { |
423 | host | 432 | host |
@@ -440,10 +449,10 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) { | |||
440 | return Account.findOne(query) | 449 | return Account.findOne(query) |
441 | } | 450 | } |
442 | 451 | ||
443 | loadAccountByPodAndUUID = function (uuid: string, podId: number, transaction: Sequelize.Transaction) { | 452 | loadAccountByServerAndUUID = function (uuid: string, serverId: number, transaction: Sequelize.Transaction) { |
444 | const query: Sequelize.FindOptions<AccountAttributes> = { | 453 | const query: Sequelize.FindOptions<AccountAttributes> = { |
445 | where: { | 454 | where: { |
446 | podId, | 455 | serverId, |
447 | uuid | 456 | uuid |
448 | }, | 457 | }, |
449 | transaction | 458 | transaction |