aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/account
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-23 17:36:15 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:53 +0100
commit39445ead45aaaea801ec09991b8dd2464f722e47 (patch)
tree9306c6b89115dabdd4a7c31a59784134a0e1c804 /server/models/account
parent16b90975941b78d01d7202d441bf731a10048c16 (diff)
downloadPeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.tar.gz
PeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.tar.zst
PeerTube-39445ead45aaaea801ec09991b8dd2464f722e47.zip
Cleanup models
Diffstat (limited to 'server/models/account')
-rw-r--r--server/models/account/account-interface.ts4
-rw-r--r--server/models/account/account.ts28
2 files changed, 1 insertions, 31 deletions
diff --git a/server/models/account/account-interface.ts b/server/models/account/account-interface.ts
index e30260f76..2e4b0382d 100644
--- a/server/models/account/account-interface.ts
+++ b/server/models/account/account-interface.ts
@@ -10,10 +10,8 @@ export namespace AccountMethods {
10 export type Load = (id: number) => Bluebird<AccountInstance> 10 export type Load = (id: number) => Bluebird<AccountInstance>
11 export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance> 11 export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
12 export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance> 12 export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
13 export type LoadAccountByServerAndUUID = (uuid: string, serverId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
14 export type LoadLocalByName = (name: string) => Bluebird<AccountInstance> 13 export type LoadLocalByName = (name: string) => Bluebird<AccountInstance>
15 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance> 14 export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
16 export type ListOwned = () => Bluebird<AccountInstance[]>
17 15
18 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor 16 export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
19 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount 17 export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
@@ -26,13 +24,11 @@ export namespace AccountMethods {
26 24
27export interface AccountClass { 25export interface AccountClass {
28 loadApplication: AccountMethods.LoadApplication 26 loadApplication: AccountMethods.LoadApplication
29 loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
30 load: AccountMethods.Load 27 load: AccountMethods.Load
31 loadByUUID: AccountMethods.LoadByUUID 28 loadByUUID: AccountMethods.LoadByUUID
32 loadByUrl: AccountMethods.LoadByUrl 29 loadByUrl: AccountMethods.LoadByUrl
33 loadLocalByName: AccountMethods.LoadLocalByName 30 loadLocalByName: AccountMethods.LoadLocalByName
34 loadByNameAndHost: AccountMethods.LoadByNameAndHost 31 loadByNameAndHost: AccountMethods.LoadByNameAndHost
35 listOwned: AccountMethods.ListOwned
36} 32}
37 33
38export interface AccountAttributes { 34export interface AccountAttributes {
diff --git a/server/models/account/account.ts b/server/models/account/account.ts
index 9a2921501..f2bd325f3 100644
--- a/server/models/account/account.ts
+++ b/server/models/account/account.ts
@@ -20,14 +20,12 @@ import { addMethodsToModel } from '../utils'
20import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface' 20import { AccountAttributes, AccountInstance, AccountMethods } from './account-interface'
21 21
22let Account: Sequelize.Model<AccountInstance, AccountAttributes> 22let Account: Sequelize.Model<AccountInstance, AccountAttributes>
23let loadAccountByServerAndUUID: AccountMethods.LoadAccountByServerAndUUID
24let load: AccountMethods.Load 23let load: AccountMethods.Load
25let loadApplication: AccountMethods.LoadApplication 24let loadApplication: AccountMethods.LoadApplication
26let loadByUUID: AccountMethods.LoadByUUID 25let loadByUUID: AccountMethods.LoadByUUID
27let loadByUrl: AccountMethods.LoadByUrl 26let loadByUrl: AccountMethods.LoadByUrl
28let loadLocalByName: AccountMethods.LoadLocalByName 27let loadLocalByName: AccountMethods.LoadLocalByName
29let loadByNameAndHost: AccountMethods.LoadByNameAndHost 28let loadByNameAndHost: AccountMethods.LoadByNameAndHost
30let listOwned: AccountMethods.ListOwned
31let isOwned: AccountMethods.IsOwned 29let isOwned: AccountMethods.IsOwned
32let toActivityPubObject: AccountMethods.ToActivityPubObject 30let toActivityPubObject: AccountMethods.ToActivityPubObject
33let toFormattedJSON: AccountMethods.ToFormattedJSON 31let toFormattedJSON: AccountMethods.ToFormattedJSON
@@ -185,14 +183,12 @@ export default function defineAccount (sequelize: Sequelize.Sequelize, DataTypes
185 183
186 const classMethods = [ 184 const classMethods = [
187 associate, 185 associate,
188 loadAccountByServerAndUUID,
189 loadApplication, 186 loadApplication,
190 load, 187 load,
191 loadByUUID, 188 loadByUUID,
192 loadByUrl, 189 loadByUrl,
193 loadLocalByName, 190 loadLocalByName,
194 loadByNameAndHost, 191 loadByNameAndHost
195 listOwned
196 ] 192 ]
197 const instanceMethods = [ 193 const instanceMethods = [
198 isOwned, 194 isOwned,
@@ -355,16 +351,6 @@ getPublicKeyUrl = function (this: AccountInstance) {
355 351
356// ------------------------------ STATICS ------------------------------ 352// ------------------------------ STATICS ------------------------------
357 353
358listOwned = function () {
359 const query: Sequelize.FindOptions<AccountAttributes> = {
360 where: {
361 serverId: null
362 }
363 }
364
365 return Account.findAll(query)
366}
367
368loadApplication = function () { 354loadApplication = function () {
369 return Account.findOne({ 355 return Account.findOne({
370 include: [ 356 include: [
@@ -441,15 +427,3 @@ loadByUrl = function (url: string, transaction?: Sequelize.Transaction) {
441 427
442 return Account.findOne(query) 428 return Account.findOne(query)
443} 429}
444
445loadAccountByServerAndUUID = function (uuid: string, serverId: number, transaction: Sequelize.Transaction) {
446 const query: Sequelize.FindOptions<AccountAttributes> = {
447 where: {
448 serverId,
449 uuid
450 },
451 transaction
452 }
453
454 return Account.find(query)
455}