Split types and typings
[oweals/peertube.git] / server / helpers / actor.ts
1 import { ActorModel } from '../models/activitypub/actor'
2 import * as Bluebird from 'bluebird'
3 import { MActorFull, MActorAccountChannelId } from '../types/models'
4
5 type ActorFetchByUrlType = 'all' | 'association-ids'
6
7 function fetchActorByUrl (url: string, fetchType: ActorFetchByUrlType): Bluebird<MActorFull | MActorAccountChannelId> {
8   if (fetchType === 'all') return ActorModel.loadByUrlAndPopulateAccountAndChannel(url)
9
10   if (fetchType === 'association-ids') return ActorModel.loadByUrl(url)
11 }
12
13 export {
14   ActorFetchByUrlType,
15   fetchActorByUrl
16 }