aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/actor/actor-follow.ts
blob: 84042e22832c00af091209fb79da80d437542a77 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { PickWith } from '@shared/typescript-utils'
import { ActorFollowModel } from '../../../models/actor/actor-follow'
import {
  MActor,
  MActorChannelAccountActor,
  MActorDefault,
  MActorDefaultAccountChannel,
  MActorDefaultChannelId,
  MActorFormattable,
  MActorHostOnly,
  MActorUsername
} from './actor'

type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>

// ############################################################################

export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>

// ############################################################################

export type MActorFollowFollowingHost =
  MActorFollow &
  Use<'ActorFollowing', MActorUsername & MActorHostOnly>

// ############################################################################

// With actors or actors default

export type MActorFollowActors =
  MActorFollow &
  Use<'ActorFollower', MActor> &
  Use<'ActorFollowing', MActor>

export type MActorFollowActorsDefault =
  MActorFollow &
  Use<'ActorFollower', MActorDefault> &
  Use<'ActorFollowing', MActorDefault>

export type MActorFollowFull =
  MActorFollow &
  Use<'ActorFollower', MActorDefaultAccountChannel> &
  Use<'ActorFollowing', MActorDefaultAccountChannel>

// ############################################################################

// For subscriptions

export type MActorFollowActorsDefaultSubscription =
  MActorFollow &
  Use<'ActorFollower', MActorDefault> &
  Use<'ActorFollowing', MActorDefaultChannelId>

export type MActorFollowSubscriptions =
  MActorFollow &
  Use<'ActorFollowing', MActorChannelAccountActor>

// ############################################################################

// Format for API or AP object

export type MActorFollowFormattable =
  Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
  Use<'ActorFollower', MActorFormattable> &
  Use<'ActorFollowing', MActorFormattable>