]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/models/account/account-interface.ts
Put activity pub sends inside transactions
[github/Chocobozzz/PeerTube.git] / server / models / account / account-interface.ts
index 2ef3e2246c53221ee7e5030e7eb43e5797244223..b369766dc4d6b6ecd399715eded4163684c972c8 100644 (file)
@@ -1,43 +1,41 @@
-import * as Sequelize from 'sequelize'
 import * as Bluebird from 'bluebird'
-
-import { PodInstance } from '../pod/pod-interface'
+import * as Sequelize from 'sequelize'
+import { Account as FormattedAccount, ActivityPubActor } from '../../../shared'
+import { ServerInstance } from '../server/server-interface'
 import { VideoChannelInstance } from '../video/video-channel-interface'
-import { ActivityPubActor } from '../../../shared'
-import { ResultList } from '../../../shared/models/result-list.model'
 
 export namespace AccountMethods {
+  export type LoadApplication = () => Bluebird<AccountInstance>
+
   export type Load = (id: number) => Bluebird<AccountInstance>
   export type LoadByUUID = (uuid: string) => Bluebird<AccountInstance>
-  export type LoadByUrl = (url: string) => Bluebird<AccountInstance>
-  export type LoadAccountByPodAndUUID = (uuid: string, podId: number, transaction: Sequelize.Transaction) => Bluebird<AccountInstance>
-  export type LoadLocalAccountByName = (name: string) => Bluebird<AccountInstance>
-  export type ListOwned = () => Bluebird<AccountInstance[]>
-  export type ListFollowerUrlsForApi = (name: string, start: number, count: number) => Promise< ResultList<string> >
-  export type ListFollowingUrlsForApi = (name: string, start: number, count: number) => Promise< ResultList<string> >
+  export type LoadByUrl = (url: string, transaction?: Sequelize.Transaction) => Bluebird<AccountInstance>
+  export type LoadLocalByName = (name: string) => Bluebird<AccountInstance>
+  export type LoadByNameAndHost = (name: string, host: string) => Bluebird<AccountInstance>
+  export type ListByFollowersUrls = (followerUrls: string[], transaction: Sequelize.Transaction) => Bluebird<AccountInstance[]>
 
   export type ToActivityPubObject = (this: AccountInstance) => ActivityPubActor
+  export type ToFormattedJSON = (this: AccountInstance) => FormattedAccount
   export type IsOwned = (this: AccountInstance) => boolean
-  export type GetFollowerSharedInboxUrls = (this: AccountInstance) => Bluebird<string[]>
+  export type GetFollowerSharedInboxUrls = (this: AccountInstance, t: Sequelize.Transaction) => Bluebird<string[]>
   export type GetFollowingUrl = (this: AccountInstance) => string
   export type GetFollowersUrl = (this: AccountInstance) => string
   export type GetPublicKeyUrl = (this: AccountInstance) => string
 }
 
 export interface AccountClass {
-  loadAccountByPodAndUUID: AccountMethods.LoadAccountByPodAndUUID
+  loadApplication: AccountMethods.LoadApplication
   load: AccountMethods.Load
   loadByUUID: AccountMethods.LoadByUUID
   loadByUrl: AccountMethods.LoadByUrl
-  loadLocalAccountByName: AccountMethods.LoadLocalAccountByName
-  listOwned: AccountMethods.ListOwned
-  listFollowerUrlsForApi: AccountMethods.ListFollowerUrlsForApi
-  listFollowingUrlsForApi: AccountMethods.ListFollowingUrlsForApi
+  loadLocalByName: AccountMethods.LoadLocalByName
+  loadByNameAndHost: AccountMethods.LoadByNameAndHost
+  listByFollowersUrls: AccountMethods.ListByFollowersUrls
 }
 
 export interface AccountAttributes {
   name: string
-  url: string
+  url?: string
   publicKey: string
   privateKey: string
   followersCount: number
@@ -50,7 +48,7 @@ export interface AccountAttributes {
 
   uuid?: string
 
-  podId?: number
+  serverId?: number
   userId?: number
   applicationId?: number
 }
@@ -58,6 +56,7 @@ export interface AccountAttributes {
 export interface AccountInstance extends AccountClass, AccountAttributes, Sequelize.Instance<AccountAttributes> {
   isOwned: AccountMethods.IsOwned
   toActivityPubObject: AccountMethods.ToActivityPubObject
+  toFormattedJSON: AccountMethods.ToFormattedJSON
   getFollowerSharedInboxUrls: AccountMethods.GetFollowerSharedInboxUrls
   getFollowingUrl: AccountMethods.GetFollowingUrl
   getFollowersUrl: AccountMethods.GetFollowersUrl
@@ -67,7 +66,7 @@ export interface AccountInstance extends AccountClass, AccountAttributes, Sequel
   createdAt: Date
   updatedAt: Date
 
-  Pod: PodInstance
+  Server: ServerInstance
   VideoChannels: VideoChannelInstance[]
 }