New avatars:
* new settings to change the avatar set * user documentation
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||
import type { Config as XMPPBotConfig } from 'xmppjs-chat-bot'
|
||||
import type { ProsodyLogLevel } from './config/content'
|
||||
import type { AvatarSet } from '../settings'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { getBaseRouterRoute, RegisterServerOptionsV5 } from '../helpers'
|
||||
@ -31,7 +32,7 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
|
||||
const dir = await getWorkingDir(options)
|
||||
const settings = await options.settingsManager.getSettings([
|
||||
'use-system-prosody', 'prosody-room-allow-s2s', 'prosody-certificates-dir'
|
||||
'use-system-prosody', 'prosody-room-allow-s2s', 'prosody-certificates-dir', 'avatar-set'
|
||||
])
|
||||
let exec
|
||||
let execArgs: string[] = []
|
||||
@ -94,9 +95,14 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
certsDir = path.resolve(dir, 'data')
|
||||
}
|
||||
|
||||
const avatarsDir = path.resolve(__dirname, '../../avatars/sepia')
|
||||
let avatarSet: AvatarSet = (settings['avatar-set'] ?? 'sepia') as AvatarSet
|
||||
if (!['sepia', 'legacy'].includes(avatarSet)) {
|
||||
logger.error('Invalid avatar-set setting, using sepia as default')
|
||||
avatarSet = 'sepia'
|
||||
}
|
||||
const avatarsDir = path.resolve(__dirname, '../../avatars/', avatarSet)
|
||||
const avatarsFiles = await _listAvatars(avatarsDir)
|
||||
const botAvatarsDir = path.resolve(__dirname, '../../bot_avatars/sepia')
|
||||
const botAvatarsDir = path.resolve(__dirname, '../../bot_avatars/', avatarSet)
|
||||
const botAvatarsFiles = await _listAvatars(botAvatarsDir)
|
||||
|
||||
return {
|
||||
|
@ -5,6 +5,8 @@ import { RoomChannel } from './room-channel'
|
||||
import { BotsCtl } from './bots/ctl'
|
||||
import { loc } from './loc'
|
||||
|
||||
type AvatarSet = 'sepia' | 'legacy'
|
||||
|
||||
async function initSettings (options: RegisterServerOptions): Promise<void> {
|
||||
const { peertubeHelpers, registerSetting, settingsManager } = options
|
||||
|
||||
@ -214,6 +216,22 @@ Please read
|
||||
descriptionHTML: loc('theming_advanced_description')
|
||||
})
|
||||
|
||||
registerSetting({
|
||||
name: 'avatar-set',
|
||||
label: loc('avatar_set_label'),
|
||||
descriptionHTML: loc('avatar_set_description'),
|
||||
type: 'select',
|
||||
default: 'sepia' as AvatarSet,
|
||||
private: true,
|
||||
options: [
|
||||
{ value: 'sepia', label: loc('avatar_set_option_sepia') },
|
||||
{ value: 'legacy', label: loc('avatar_set_option_legacy') }
|
||||
] as Array<{
|
||||
value: AvatarSet
|
||||
label: string
|
||||
}>
|
||||
})
|
||||
|
||||
registerSetting({
|
||||
name: 'converse-theme',
|
||||
label: loc('converse_theme_label'),
|
||||
@ -434,5 +452,6 @@ Please read
|
||||
}
|
||||
|
||||
export {
|
||||
initSettings
|
||||
initSettings,
|
||||
AvatarSet
|
||||
}
|
||||
|
Reference in New Issue
Block a user