aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/server-commands/videos/channels.ts
blob: 3c0d4b7238ada806a48e78fbe797a880fa64532a (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
import { PeerTubeServer } from '../server/server'

function setDefaultVideoChannel (servers: PeerTubeServer[]) {
  const tasks: Promise<any>[] = []

  for (const server of servers) {
    const p = server.users.getMyInfo()
      .then(user => { server.store.channel = user.videoChannels[0] })

    tasks.push(p)
  }

  return Promise.all(tasks)
}

async function setDefaultChannelAvatar (serversArg: PeerTubeServer | PeerTubeServer[], channelName: string = 'root_channel') {
  const servers = Array.isArray(serversArg)
    ? serversArg
    : [ serversArg ]

  for (const server of servers) {
    await server.channels.updateImage({ channelName, fixture: 'avatar.png', type: 'avatar' })
  }
}

export {
  setDefaultVideoChannel,
  setDefaultChannelAvatar
}