aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/account
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-20 19:05:31 +0200
committerChocobozzz <me@florianbigard.com>2019-08-20 19:23:10 +0200
commit1ca9f7c3f7afac2af4c4c25b98426731f7e789c6 (patch)
tree27fe65c4ea5e9250d2523033d5c65b315bfca23d /server/typings/models/account
parent0283eaac2a8e73006c66df3cf5bb9012e37450e5 (diff)
downloadPeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.gz
PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.zst
PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.zip
Type toFormattedJSON
Diffstat (limited to 'server/typings/models/account')
-rw-r--r--server/typings/models/account/account-blocklist.ts10
-rw-r--r--server/typings/models/account/account.ts21
-rw-r--r--server/typings/models/account/actor-follow.ts16
-rw-r--r--server/typings/models/account/actor.ts23
-rw-r--r--server/typings/models/account/avatar.ts8
5 files changed, 68 insertions, 10 deletions
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts
index d20d97aa8..c9cb55332 100644
--- a/server/typings/models/account/account-blocklist.ts
+++ b/server/typings/models/account/account-blocklist.ts
@@ -1,6 +1,6 @@
1import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 1import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccountDefault } from './account' 3import { MAccountDefault, MAccountFormattable } from './account'
4 4
5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> 5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
6 6
@@ -15,3 +15,11 @@ export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
15export type MAccountBlocklistAccounts = MAccountBlocklist & 15export type MAccountBlocklistAccounts = MAccountBlocklist &
16 Use<'ByAccount', MAccountDefault> & 16 Use<'ByAccount', MAccountDefault> &
17 Use<'BlockedAccount', MAccountDefault> 17 Use<'BlockedAccount', MAccountDefault>
18
19// ############################################################################
20
21// Format for API or AP object
22
23export type MAccountBlocklistFormattable = Pick<MAccountBlocklist, 'createdAt'> &
24 Use<'ByAccount', MAccountFormattable> &
25 Use<'BlockedAccount', MAccountFormattable>
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts
index 9a8784e6b..33940517e 100644
--- a/server/typings/models/account/account.ts
+++ b/server/typings/models/account/account.ts
@@ -9,9 +9,11 @@ import {
9 MActorId, 9 MActorId,
10 MActorServer, 10 MActorServer,
11 MActorSummary, 11 MActorSummary,
12 MActorUrl 12 MActorSummaryFormattable,
13 MActorUrl,
14 MActorFormattable
13} from './actor' 15} from './actor'
14import { PickWith } from '../../utils' 16import { FunctionProperties, PickWith } from '../../utils'
15import { MAccountBlocklistId } from './account-blocklist' 17import { MAccountBlocklistId } from './account-blocklist'
16import { MChannelDefault } from '@server/typings/models' 18import { MChannelDefault } from '@server/typings/models'
17 19
@@ -67,7 +69,8 @@ export type MAccountServer = MAccount &
67 69
68// For API 70// For API
69 71
70export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & 72export type MAccountSummary = FunctionProperties<MAccount> &
73 Pick<MAccount, 'id' | 'name'> &
71 Use<'Actor', MActorSummary> 74 Use<'Actor', MActorSummary>
72 75
73export type MAccountSummaryBlocks = MAccountSummary & 76export type MAccountSummaryBlocks = MAccountSummary &
@@ -75,3 +78,15 @@ export type MAccountSummaryBlocks = MAccountSummary &
75 78
76export type MAccountAPI = MAccount & 79export type MAccountAPI = MAccount &
77 Use<'Actor', MActorAPI> 80 Use<'Actor', MActorAPI>
81
82// ############################################################################
83
84// Format for API or AP object
85
86export type MAccountSummaryFormattable = FunctionProperties<MAccount> &
87 Pick<MAccount, 'id' | 'name'> &
88 Use<'Actor', MActorSummaryFormattable>
89
90export type MAccountFormattable = FunctionProperties<MAccount> &
91 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
92 Use<'Actor', MActorFormattable>
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts
index 87050ac63..17a47b8df 100644
--- a/server/typings/models/account/actor-follow.ts
+++ b/server/typings/models/account/actor-follow.ts
@@ -3,14 +3,15 @@ import {
3 MActor, 3 MActor,
4 MActorAccount, 4 MActorAccount,
5 MActorAccountChannel, 5 MActorAccountChannel,
6 MActorChannel,
7 MActorChannelAccountActor, 6 MActorChannelAccountActor,
8 MActorDefault, 7 MActorDefault,
8 MActorFormattable,
9 MActorHost, 9 MActorHost,
10 MActorUsername 10 MActorUsername
11} from './actor' 11} from './actor'
12import { PickWith } from '../../utils' 12import { PickWith } from '../../utils'
13import { ActorModel } from '@server/models/activitypub/actor' 13import { ActorModel } from '@server/models/activitypub/actor'
14import { MChannelDefault } from '@server/typings/models'
14 15
15type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> 16type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
16 17
@@ -43,9 +44,12 @@ export type MActorFollowFull = MActorFollow &
43 44
44// For subscriptions 45// For subscriptions
45 46
47type SubscriptionFollowing = MActorDefault &
48 PickWith<ActorModel, 'VideoChannel', MChannelDefault>
49
46export type MActorFollowActorsDefaultSubscription = MActorFollow & 50export type MActorFollowActorsDefaultSubscription = MActorFollow &
47 Use<'ActorFollower', MActorDefault> & 51 Use<'ActorFollower', MActorDefault> &
48 Use<'ActorFollowing', MActorDefault & MActorChannel> 52 Use<'ActorFollowing', SubscriptionFollowing>
49 53
50export type MActorFollowFollowingFullFollowerAccount = MActorFollow & 54export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
51 Use<'ActorFollower', MActorAccount> & 55 Use<'ActorFollower', MActorAccount> &
@@ -53,3 +57,11 @@ export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
53 57
54export type MActorFollowSubscriptions = MActorFollow & 58export type MActorFollowSubscriptions = MActorFollow &
55 Use<'ActorFollowing', MActorChannelAccountActor> 59 Use<'ActorFollowing', MActorChannelAccountActor>
60
61// ############################################################################
62
63// Format for API or AP object
64
65export type MActorFollowFormattable = Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
66 Use<'ActorFollower', MActorFormattable> &
67 Use<'ActorFollowing', MActorFormattable>
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts
index 7d99a433b..14ab2cd5b 100644
--- a/server/typings/models/account/actor.ts
+++ b/server/typings/models/account/actor.ts
@@ -1,8 +1,8 @@
1import { ActorModel } from '../../../models/activitypub/actor' 1import { ActorModel } from '../../../models/activitypub/actor'
2import { PickWith } from '../../utils' 2import { FunctionProperties, PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' 3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4import { MServer, MServerHost, MServerHostBlocks } from '../server' 4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MAvatar } from './avatar' 5import { MAvatar, MAvatarFormattable } from './avatar'
6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' 6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
7 7
8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> 8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
@@ -29,6 +29,7 @@ export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
29// Some association attributes 29// Some association attributes
30 30
31export type MActorHost = Use<'Server', MServerHost> 31export type MActorHost = Use<'Server', MServerHost>
32export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed>
32 33
33export type MActorDefaultLight = MActorLight & 34export type MActorDefaultLight = MActorLight &
34 Use<'Server', MServerHost> & 35 Use<'Server', MServerHost> &
@@ -92,7 +93,8 @@ export type MActorFullActor = MActor &
92 93
93// API 94// API
94 95
95export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & 96export type MActorSummary = FunctionProperties<MActor> &
97 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
96 Use<'Server', MServerHost> & 98 Use<'Server', MServerHost> &
97 Use<'Avatar', MAvatar> 99 Use<'Avatar', MAvatar>
98 100
@@ -101,3 +103,16 @@ export type MActorSummaryBlocks = MActorSummary &
101 103
102export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | 104export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
103 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> 105 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
106
107// ############################################################################
108
109// Format for API or AP object
110
111export type MActorSummaryFormattable = FunctionProperties<MActor> &
112 Pick<MActor, 'url' | 'preferredUsername'> &
113 Use<'Server', MServerHost> &
114 Use<'Avatar', MAvatarFormattable>
115
116export type MActorFormattable = MActorSummaryFormattable &
117 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
118 Use<'Server', MServer>
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts
index 257c48bfc..8af6cc787 100644
--- a/server/typings/models/account/avatar.ts
+++ b/server/typings/models/account/avatar.ts
@@ -1,3 +1,11 @@
1import { AvatarModel } from '../../../models/avatar/avatar' 1import { AvatarModel } from '../../../models/avatar/avatar'
2import { FunctionProperties } from '@server/typings/utils'
2 3
3export type MAvatar = AvatarModel 4export type MAvatar = AvatarModel
5
6// ############################################################################
7
8// Format for API or AP object
9
10export type MAvatarFormattable = FunctionProperties<MAvatar> &
11 Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'>