Builtin-Prosody: use Peertube's avatar.

This commit is contained in:
John Livingston
2022-01-05 18:53:44 +01:00
parent be592aeacf
commit 6afb640df2
4 changed files with 94 additions and 8 deletions

View File

@ -108,14 +108,14 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
const apikey = await getAPIKey(options)
valuesToHideInDiagnostic.set('APIKey', apikey)
let baseApiUrl = settings['prosody-peertube-uri'] as string
if (baseApiUrl && !/^https?:\/\/[a-z0-9.-_]+(?::\d+)?$/.test(baseApiUrl)) {
let basePeertubeUrl = settings['prosody-peertube-uri'] as string
if (basePeertubeUrl && !/^https?:\/\/[a-z0-9.-_]+(?::\d+)?$/.test(basePeertubeUrl)) {
throw new Error('Invalid prosody-peertube-uri')
}
if (!baseApiUrl) {
baseApiUrl = options.peertubeHelpers.config.getWebserverUrl()
if (!basePeertubeUrl) {
basePeertubeUrl = options.peertubeHelpers.config.getWebserverUrl()
}
baseApiUrl += getBaseRouterRoute(options) + 'api/'
const baseApiUrl = basePeertubeUrl + getBaseRouterRoute(options) + 'api/'
const authApiUrl = baseApiUrl + 'user' // FIXME: should be protected by apikey, but mod_auth_http cant handle params
const roomApiUrl = baseApiUrl + 'room?apikey=' + apikey + '&jid={room.jid|jid_node}'
@ -152,6 +152,7 @@ async function getProsodyConfig (options: RegisterServerOptions): Promise<Prosod
config.useDefaultPersistent()
config.useListRoomsApi(apikey)
config.usePeertubeVCards(basePeertubeUrl)
config.useTestModule(apikey, testApiUrl)

View File

@ -157,9 +157,9 @@ class ProsodyConfigContent {
'uptime', // Report how long server has been running
'ping', // Replies to XMPP pings with pongs
'bosh', // Enable BOSH clients, aka "Jabber over HTTP"
'posix', // POSIX functionality, sends server to background, enables syslog, etc.
'pep', // Enables users to publish their avatar, mood, activity, playing music and more
'vcard_legacy' // Conversion between legacy vCard and PEP Avatar, vcard
'posix' // POSIX functionality, sends server to background, enables syslog, etc.
// 'pep', // Enables users to publish their avatar, mood, activity, playing music and more
// 'vcard_legacy' // Conversion between legacy vCard and PEP Avatar, vcard
// 'vcard4' // User profiles (stored in PEP)
])
@ -301,6 +301,13 @@ class ProsodyConfigContent {
this.muc.set('peertubelivechat_test_peertube_api_url', apiurl)
}
usePeertubeVCards (peertubeUrl: string): void {
if (this.authenticated) {
this.authenticated.add('modules_enabled', 'vcard_peertubelivechat')
this.authenticated.set('peertubelivechat_vcard_peertube_url', peertubeUrl)
}
}
setLog (level: ProsodyLogLevel, syslog?: ProsodyLogLevel[]): void {
let log = ''
log += 'log = {\n'