diff options
Diffstat (limited to 'packages/server-commands/src/videos/channels.ts')
-rw-r--r-- | packages/server-commands/src/videos/channels.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/server-commands/src/videos/channels.ts b/packages/server-commands/src/videos/channels.ts new file mode 100644 index 000000000..e3487d024 --- /dev/null +++ b/packages/server-commands/src/videos/channels.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { PeerTubeServer } from '../server/server.js' | ||
2 | |||
3 | function setDefaultVideoChannel (servers: PeerTubeServer[]) { | ||
4 | const tasks: Promise<any>[] = [] | ||
5 | |||
6 | for (const server of servers) { | ||
7 | const p = server.users.getMyInfo() | ||
8 | .then(user => { server.store.channel = user.videoChannels[0] }) | ||
9 | |||
10 | tasks.push(p) | ||
11 | } | ||
12 | |||
13 | return Promise.all(tasks) | ||
14 | } | ||
15 | |||
16 | async function setDefaultChannelAvatar (serversArg: PeerTubeServer | PeerTubeServer[], channelName: string = 'root_channel') { | ||
17 | const servers = Array.isArray(serversArg) | ||
18 | ? serversArg | ||
19 | : [ serversArg ] | ||
20 | |||
21 | for (const server of servers) { | ||
22 | await server.channels.updateImage({ channelName, fixture: 'avatar.png', type: 'avatar' }) | ||
23 | } | ||
24 | } | ||
25 | |||
26 | export { | ||
27 | setDefaultVideoChannel, | ||
28 | setDefaultChannelAvatar | ||
29 | } | ||