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