Avatar set for anonymous users: new 'none' choice (that will fallback to Converse new colorized avatars).
This commit is contained in:
parent
099ff28c76
commit
c6c365abf0
@ -8,6 +8,7 @@
|
||||
|
||||
### Minor changes and fixes
|
||||
|
||||
* Avatar set for anonymous users: new 'none' choice (that will fallback to Converse new colorized avatars).
|
||||
* New translation: Albanian.
|
||||
* Translation updates: Crotian, Japanese.
|
||||
|
||||
|
@ -181,6 +181,7 @@ avatar_set_option_fenec: "Fenecs (Mobilizon mascot)"
|
||||
avatar_set_option_abstract: Abstract
|
||||
avatar_set_option_legacy: "Legacy Sepia avatars (those included in previous plugin
|
||||
versions)"
|
||||
avatar_set_option_none: None
|
||||
|
||||
converse_theme_label: "ConverseJS theme"
|
||||
converse_theme_description: "Please choose the converseJS theme you want to use."
|
||||
|
@ -87,8 +87,8 @@ class ExternalAuthOIDC {
|
||||
private readonly redirectUrl: string
|
||||
private readonly connectUrl: string
|
||||
private readonly externalVirtualhost: string
|
||||
private readonly avatarsDir: string
|
||||
private readonly avatarsFiles: string[]
|
||||
private readonly avatarsDir: string | undefined
|
||||
private readonly avatarsFiles: string[] | undefined
|
||||
|
||||
private readonly encryptionOptions = {
|
||||
algorithm: 'aes256' as string,
|
||||
@ -129,8 +129,8 @@ class ExternalAuthOIDC {
|
||||
connectUrl: string
|
||||
redirectUrl: string
|
||||
externalVirtualhost: string
|
||||
avatarsDir: string
|
||||
avatarsFiles: string[]
|
||||
avatarsDir?: string
|
||||
avatarsFiles?: string[]
|
||||
}) {
|
||||
this.logger = {
|
||||
debug: (s) => params.logger.debug('[ExternalAuthOIDC] ' + s),
|
||||
@ -591,8 +591,8 @@ class ExternalAuthOIDC {
|
||||
*/
|
||||
private async getRandomAvatar (): Promise<undefined | ExternalAccountInfos['avatar']> {
|
||||
try {
|
||||
if (!this.avatarsDir || !this.avatarsFiles.length) {
|
||||
throw new Error('Seems there is no default avatars')
|
||||
if (!this.avatarsDir || !this.avatarsFiles?.length) {
|
||||
return undefined
|
||||
}
|
||||
|
||||
const file = this.avatarsFiles[Math.floor(Math.random() * this.avatarsFiles.length)]
|
||||
|
@ -102,14 +102,23 @@ async function getProsodyFilePaths (options: RegisterServerOptions): Promise<Pro
|
||||
}
|
||||
|
||||
let avatarSet: AvatarSet = (settings['avatar-set'] ?? 'sepia') as AvatarSet
|
||||
let avatarsDir
|
||||
let avatarsFiles
|
||||
let botAvatarsDir
|
||||
let botAvatarsFiles
|
||||
if (avatarSet === 'none') {
|
||||
botAvatarsDir = path.resolve(__dirname, '../../bot_avatars/', 'sepia') // fallback to default avatars for the bot
|
||||
botAvatarsFiles = await _listAvatars(botAvatarsDir)
|
||||
} else {
|
||||
if (!['sepia', 'cat', 'bird', 'fenec', 'abstract', '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/', avatarSet)
|
||||
const botAvatarsFiles = await _listAvatars(botAvatarsDir)
|
||||
avatarsDir = path.resolve(__dirname, '../../avatars/', avatarSet)
|
||||
avatarsFiles = await _listAvatars(avatarsDir)
|
||||
botAvatarsDir = path.resolve(__dirname, '../../bot_avatars/', avatarSet)
|
||||
botAvatarsFiles = await _listAvatars(botAvatarsDir)
|
||||
}
|
||||
|
||||
return {
|
||||
dir: dir,
|
||||
@ -356,7 +365,9 @@ async function getProsodyConfig (options: RegisterServerOptionsV5): Promise<Pros
|
||||
|
||||
config.useManageRoomsApi(apikey)
|
||||
config.usePeertubeVCards(basePeertubeUrl)
|
||||
if (paths.avatars && paths.avatarsFiles) {
|
||||
config.useAnonymousRandomVCards(paths.avatars, paths.avatarsFiles)
|
||||
}
|
||||
|
||||
if (useBots) {
|
||||
config.useBotsVirtualHost(paths.botAvatars, paths.botAvatarsFiles)
|
||||
|
@ -12,8 +12,8 @@ interface ProsodyFilePaths {
|
||||
certs?: string
|
||||
certsDirIsCustom: boolean
|
||||
modules: string
|
||||
avatars: string
|
||||
avatarsFiles: string[]
|
||||
avatars?: string
|
||||
avatarsFiles?: string[]
|
||||
botAvatars: string
|
||||
botAvatarsFiles: string[]
|
||||
exec?: string
|
||||
|
@ -13,7 +13,7 @@ import { LivechatProsodyAuth } from './prosody/auth'
|
||||
import { loc } from './loc'
|
||||
const escapeHTML = require('escape-html')
|
||||
|
||||
type AvatarSet = 'sepia' | 'cat' | 'bird' | 'fenec' | 'abstract' | 'legacy'
|
||||
type AvatarSet = 'sepia' | 'cat' | 'bird' | 'fenec' | 'abstract' | 'legacy' | 'none'
|
||||
|
||||
async function initSettings (options: RegisterServerOptions): Promise<void> {
|
||||
const { peertubeHelpers, settingsManager } = options
|
||||
@ -510,7 +510,8 @@ function initThemingSettings ({ registerSetting }: RegisterServerOptions): void
|
||||
{ value: 'bird', label: loc('avatar_set_option_bird') },
|
||||
{ value: 'fenec', label: loc('avatar_set_option_fenec') },
|
||||
{ value: 'abstract', label: loc('avatar_set_option_abstract') },
|
||||
{ value: 'legacy', label: loc('avatar_set_option_legacy') }
|
||||
{ value: 'legacy', label: loc('avatar_set_option_legacy') },
|
||||
{ value: 'none', label: loc('avatar_set_option_none') }
|
||||
] as Array<{
|
||||
value: AvatarSet
|
||||
label: string
|
||||
|
Loading…
Reference in New Issue
Block a user