channels.ts 755 B

1234567891011121314151617181920212223242526272829
  1. import { PeerTubeServer } from '../server/server'
  2. function setDefaultVideoChannel (servers: PeerTubeServer[]) {
  3. const tasks: Promise<any>[] = []
  4. for (const server of servers) {
  5. const p = server.users.getMyInfo()
  6. .then(user => { server.store.channel = user.videoChannels[0] })
  7. tasks.push(p)
  8. }
  9. return Promise.all(tasks)
  10. }
  11. async function setDefaultChannelAvatar (serversArg: PeerTubeServer | PeerTubeServer[], channelName: string = 'root_channel') {
  12. const servers = Array.isArray(serversArg)
  13. ? serversArg
  14. : [ serversArg ]
  15. for (const server of servers) {
  16. await server.channels.updateImage({ channelName, fixture: 'avatar.png', type: 'avatar' })
  17. }
  18. }
  19. export {
  20. setDefaultVideoChannel,
  21. setDefaultChannelAvatar
  22. }