aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-05-11 11:15:29 +0200
committerChocobozzz <me@florianbigard.com>2021-05-11 11:32:31 +0200
commit7d9ba5c08999c6482f0bc5e0c09c6f55b7724090 (patch)
tree5f4ea1f06dcb781c9e61062522b53a28a401111f /server/types/models/account
parentc07902b9083ab5756436cd020bed5bdfa51028bf (diff)
downloadPeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.gz
PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.zst
PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.zip
Cleanup models directory organization
Diffstat (limited to 'server/types/models/account')
-rw-r--r--server/types/models/account/account.ts6
-rw-r--r--server/types/models/account/actor-follow.ts65
-rw-r--r--server/types/models/account/actor-image.ts12
-rw-r--r--server/types/models/account/actor.ts166
-rw-r--r--server/types/models/account/index.ts3
5 files changed, 3 insertions, 249 deletions
diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts
index 9513acad8..984841291 100644
--- a/server/types/models/account/account.ts
+++ b/server/types/models/account/account.ts
@@ -1,7 +1,5 @@
1import { FunctionProperties, PickWith } from '@shared/core-utils' 1import { FunctionProperties, PickWith } from '@shared/core-utils'
2import { AccountModel } from '../../../models/account/account' 2import { AccountModel } from '../../../models/account/account'
3import { MChannelDefault } from '../video/video-channels'
4import { MAccountBlocklistId } from './account-blocklist'
5import { 3import {
6 MActor, 4 MActor,
7 MActorAPAccount, 5 MActorAPAccount,
@@ -15,7 +13,9 @@ import {
15 MActorSummary, 13 MActorSummary,
16 MActorSummaryFormattable, 14 MActorSummaryFormattable,
17 MActorUrl 15 MActorUrl
18} from './actor' 16} from '../actor'
17import { MChannelDefault } from '../video/video-channels'
18import { MAccountBlocklistId } from './account-blocklist'
19 19
20type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> 20type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
21 21
diff --git a/server/types/models/account/actor-follow.ts b/server/types/models/account/actor-follow.ts
deleted file mode 100644
index 8e19c6140..000000000
--- a/server/types/models/account/actor-follow.ts
+++ /dev/null
@@ -1,65 +0,0 @@
1import { PickWith } from '@shared/core-utils'
2import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
3import {
4 MActor,
5 MActorChannelAccountActor,
6 MActorDefault,
7 MActorDefaultAccountChannel,
8 MActorDefaultChannelId,
9 MActorFormattable,
10 MActorHost,
11 MActorUsername
12} from './actor'
13
14type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
15
16// ############################################################################
17
18export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
19
20// ############################################################################
21
22export type MActorFollowFollowingHost =
23 MActorFollow &
24 Use<'ActorFollowing', MActorUsername & MActorHost>
25
26// ############################################################################
27
28// With actors or actors default
29
30export type MActorFollowActors =
31 MActorFollow &
32 Use<'ActorFollower', MActor> &
33 Use<'ActorFollowing', MActor>
34
35export type MActorFollowActorsDefault =
36 MActorFollow &
37 Use<'ActorFollower', MActorDefault> &
38 Use<'ActorFollowing', MActorDefault>
39
40export type MActorFollowFull =
41 MActorFollow &
42 Use<'ActorFollower', MActorDefaultAccountChannel> &
43 Use<'ActorFollowing', MActorDefaultAccountChannel>
44
45// ############################################################################
46
47// For subscriptions
48
49export type MActorFollowActorsDefaultSubscription =
50 MActorFollow &
51 Use<'ActorFollower', MActorDefault> &
52 Use<'ActorFollowing', MActorDefaultChannelId>
53
54export type MActorFollowSubscriptions =
55 MActorFollow &
56 Use<'ActorFollowing', MActorChannelAccountActor>
57
58// ############################################################################
59
60// Format for API or AP object
61
62export type MActorFollowFormattable =
63 Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
64 Use<'ActorFollower', MActorFormattable> &
65 Use<'ActorFollowing', MActorFormattable>
diff --git a/server/types/models/account/actor-image.ts b/server/types/models/account/actor-image.ts
deleted file mode 100644
index e59f8b141..000000000
--- a/server/types/models/account/actor-image.ts
+++ /dev/null
@@ -1,12 +0,0 @@
1import { ActorImageModel } from '../../../models/account/actor-image'
2import { FunctionProperties } from '@shared/core-utils'
3
4export type MActorImage = ActorImageModel
5
6// ############################################################################
7
8// Format for API or AP object
9
10export type MActorImageFormattable =
11 FunctionProperties<MActorImage> &
12 Pick<MActorImage, 'filename' | 'createdAt' | 'updatedAt'>
diff --git a/server/types/models/account/actor.ts b/server/types/models/account/actor.ts
deleted file mode 100644
index 0b620872e..000000000
--- a/server/types/models/account/actor.ts
+++ /dev/null
@@ -1,166 +0,0 @@
1
2import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils'
3import { ActorModel } from '../../../models/activitypub/actor'
4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
6import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
7import { MActorImage, MActorImageFormattable } from './actor-image'
8
9type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
10type UseOpt<K extends keyof ActorModel, M> = PickWithOpt<ActorModel, K, M>
11
12// ############################################################################
13
14export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server' | 'Banner'>
15
16// ############################################################################
17
18export type MActorUrl = Pick<MActor, 'url'>
19export type MActorId = Pick<MActor, 'id'>
20export type MActorUsername = Pick<MActor, 'preferredUsername'>
21
22export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
23export type MActorAudience = MActorUrl & MActorFollowersUrl
24export type MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'>
25export type MActorSignature = MActorAccountChannelId
26
27export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
28
29// ############################################################################
30
31// Some association attributes
32
33export type MActorHost = Use<'Server', MServerHost>
34export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
35
36export type MActorDefaultLight =
37 MActorLight &
38 Use<'Server', MServerHost> &
39 Use<'Avatar', MActorImage>
40
41export type MActorAccountId =
42 MActor &
43 Use<'Account', MAccountId>
44export type MActorAccountIdActor =
45 MActor &
46 Use<'Account', MAccountIdActor>
47
48export type MActorChannelId =
49 MActor &
50 Use<'VideoChannel', MChannelId>
51export type MActorChannelIdActor =
52 MActor &
53 Use<'VideoChannel', MChannelIdActor>
54
55export type MActorAccountChannelId = MActorAccountId & MActorChannelId
56export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
57
58// ############################################################################
59
60// Include raw account/channel/server
61
62export type MActorAccount =
63 MActor &
64 Use<'Account', MAccount>
65
66export type MActorChannel =
67 MActor &
68 Use<'VideoChannel', MChannel>
69
70export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
71
72export type MActorServer =
73 MActor &
74 Use<'Server', MServer>
75
76// ############################################################################
77
78// Complex actor associations
79
80export type MActorImages =
81 MActor &
82 Use<'Avatar', MActorImage> &
83 UseOpt<'Banner', MActorImage>
84
85export type MActorDefault =
86 MActor &
87 Use<'Server', MServer> &
88 Use<'Avatar', MActorImage>
89
90export type MActorDefaultChannelId =
91 MActorDefault &
92 Use<'VideoChannel', MChannelId>
93
94export type MActorDefaultBanner =
95 MActor &
96 Use<'Server', MServer> &
97 Use<'Avatar', MActorImage> &
98 Use<'Banner', MActorImage>
99
100// Actor with channel that is associated to an account and its actor
101// Actor -> VideoChannel -> Account -> Actor
102export type MActorChannelAccountActor =
103 MActor &
104 Use<'VideoChannel', MChannelAccountActor>
105
106export type MActorFull =
107 MActor &
108 Use<'Server', MServer> &
109 Use<'Avatar', MActorImage> &
110 Use<'Banner', MActorImage> &
111 Use<'Account', MAccount> &
112 Use<'VideoChannel', MChannelAccountActor>
113
114// Same than ActorFull, but the account and the channel have their actor
115export type MActorFullActor =
116 MActor &
117 Use<'Server', MServer> &
118 Use<'Avatar', MActorImage> &
119 Use<'Banner', MActorImage> &
120 Use<'Account', MAccountDefault> &
121 Use<'VideoChannel', MChannelAccountDefault>
122
123// ############################################################################
124
125// API
126
127export type MActorSummary =
128 FunctionProperties<MActor> &
129 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
130 Use<'Server', MServerHost> &
131 Use<'Avatar', MActorImage>
132
133export type MActorSummaryBlocks =
134 MActorSummary &
135 Use<'Server', MServerHostBlocks>
136
137export type MActorAPI =
138 Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
139 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
140
141// ############################################################################
142
143// Format for API or AP object
144
145export type MActorSummaryFormattable =
146 FunctionProperties<MActor> &
147 Pick<MActor, 'url' | 'preferredUsername'> &
148 Use<'Server', MServerHost> &
149 Use<'Avatar', MActorImageFormattable>
150
151export type MActorFormattable =
152 MActorSummaryFormattable &
153 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt' | 'remoteCreatedAt' | 'bannerId' | 'avatarId'> &
154 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> &
155 UseOpt<'Banner', MActorImageFormattable>
156
157type MActorAPBase =
158 MActor &
159 Use<'Avatar', MActorImage>
160
161export type MActorAPAccount =
162 MActorAPBase
163
164export type MActorAPChannel =
165 MActorAPBase &
166 Use<'Banner', MActorImage>
diff --git a/server/types/models/account/index.ts b/server/types/models/account/index.ts
index e3fc00f94..dab2eea7e 100644
--- a/server/types/models/account/index.ts
+++ b/server/types/models/account/index.ts
@@ -1,5 +1,2 @@
1export * from './account' 1export * from './account'
2export * from './account-blocklist' 2export * from './account-blocklist'
3export * from './actor-follow'
4export * from './actor-image'
5export * from './actor'