Using types declarations from the official @peertube/peertube-types package.
This commit is contained in:
parent
c1fb7b69ed
commit
7db856ce0f
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## ???
|
||||||
|
|
||||||
|
### Changes
|
||||||
|
|
||||||
|
* This plugin is now using types declarations from the official @peertube/peertube-types package.
|
||||||
|
|
||||||
## 5.4.0
|
## 5.4.0
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
|
80
client/@types/peertube.d.ts
vendored
80
client/@types/peertube.d.ts
vendored
@ -1,80 +0,0 @@
|
|||||||
// TODO: import @types/peertube when available
|
|
||||||
|
|
||||||
interface RegisterClientHookOptions {
|
|
||||||
target: string // FIXME
|
|
||||||
handler: Function
|
|
||||||
priority?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegisterClientHelpers {
|
|
||||||
getBaseStaticRoute: () => string
|
|
||||||
// NB: getBaseRouterRoute will come with Peertube > 3.2.1 (3.3.0?)
|
|
||||||
getBaseRouterRoute?: () => string
|
|
||||||
isLoggedIn: () => boolean
|
|
||||||
getAuthHeader: () => { 'Authorization': string } | undefined
|
|
||||||
getSettings: () => Promise<{ [ name: string ]: string }>
|
|
||||||
notifier: {
|
|
||||||
info: (text: string, title?: string, timeout?: number) => void
|
|
||||||
error: (text: string, title?: string, timeout?: number) => void
|
|
||||||
success: (text: string, title?: string, timeout?: number) => void
|
|
||||||
}
|
|
||||||
showModal: (input: {
|
|
||||||
title: string
|
|
||||||
content: string
|
|
||||||
close?: boolean
|
|
||||||
cancel?: { value: string, action?: () => void }
|
|
||||||
confirm?: { value: string, action?: () => void }
|
|
||||||
}) => void
|
|
||||||
markdownRenderer: {
|
|
||||||
textMarkdownToHTML: (textMarkdown: string) => Promise<string>
|
|
||||||
enhancedMarkdownToHTML: (enhancedMarkdown: string) => Promise<string>
|
|
||||||
}
|
|
||||||
translate: (toTranslate: string) => Promise<string>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegisterClientFormFieldOptions {
|
|
||||||
name: string
|
|
||||||
label: string
|
|
||||||
type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
|
|
||||||
descriptionHTML?: string
|
|
||||||
default?: string | boolean
|
|
||||||
hidden?: (options: any) => boolean
|
|
||||||
}
|
|
||||||
interface RegisterClientSettingsScript {
|
|
||||||
isSettingHidden: (options: {
|
|
||||||
setting: RegisterClientFormFieldOptions
|
|
||||||
formValues: { [name: string]: any }
|
|
||||||
}) => boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegisterClientVideoFieldOptions {
|
|
||||||
type: 'update' | 'upload' | 'import-url' | 'import-torrent' | 'go-live'
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegisterOptions {
|
|
||||||
registerHook: (options: RegisterClientHookOptions) => void
|
|
||||||
peertubeHelpers: RegisterClientHelpers
|
|
||||||
registerSettingsScript: (options: RegisterClientSettingsScript) => void
|
|
||||||
registerVideoField: (
|
|
||||||
commonOptions: RegisterClientFormFieldOptions,
|
|
||||||
videoFormOptions: RegisterClientVideoFieldOptions
|
|
||||||
) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Video {
|
|
||||||
isLive: boolean
|
|
||||||
isLocal: boolean
|
|
||||||
name: string
|
|
||||||
originInstanceUrl: string
|
|
||||||
uuid: string
|
|
||||||
channel: Channel
|
|
||||||
byAccount: string
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Channel {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
displayName: string
|
|
||||||
url: string
|
|
||||||
host: string
|
|
||||||
}
|
|
@ -1,10 +1,12 @@
|
|||||||
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||||
|
import type { Video } from '@peertube/peertube-types'
|
||||||
import type { ChatType, ProsodyListRoomsResult } from 'shared/lib/types'
|
import type { ChatType, ProsodyListRoomsResult } from 'shared/lib/types'
|
||||||
|
|
||||||
interface ActionPluginSettingsParams {
|
interface ActionPluginSettingsParams {
|
||||||
npmName: string
|
npmName: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function register ({ registerHook, registerSettingsScript, peertubeHelpers }: RegisterOptions): void {
|
function register ({ registerHook, registerSettingsScript, peertubeHelpers }: RegisterClientOptions): void {
|
||||||
function getBaseRoute (): string {
|
function getBaseRoute (): string {
|
||||||
// NB: this will come with Peertube > 3.2.1 (3.3.0?)
|
// NB: this will come with Peertube > 3.2.1 (3.3.0?)
|
||||||
if (peertubeHelpers.getBaseRouterRoute) {
|
if (peertubeHelpers.getBaseRouterRoute) {
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||||
|
import type { RegisterClientFormFieldOptions } from '@peertube/peertube-types'
|
||||||
|
|
||||||
async function register ({ peertubeHelpers, registerHook, registerVideoField }: RegisterOptions): Promise<void> {
|
async function register ({ peertubeHelpers, registerHook, registerVideoField }: RegisterClientOptions): Promise<void> {
|
||||||
registerHook({
|
registerHook({
|
||||||
target: 'action:router.navigation-end',
|
target: 'action:router.navigation-end',
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "es6",
|
"module": "es6",
|
||||||
|
"moduleResolution": "node",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { Video } from '@peertube/peertube-types'
|
||||||
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||||
import { videoHasWebchat } from 'shared/lib/video'
|
import { videoHasWebchat } from 'shared/lib/video'
|
||||||
import { logger } from './videowatch/logger'
|
import { logger } from './videowatch/logger'
|
||||||
import { closeSVG, openBlankChatSVG, openChatSVG, shareChatUrlSVG } from './videowatch/buttons'
|
import { closeSVG, openBlankChatSVG, openChatSVG, shareChatUrlSVG } from './videowatch/buttons'
|
||||||
@ -11,7 +13,7 @@ interface VideoWatchLoadedHookOptions {
|
|||||||
playlist?: any
|
playlist?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
function guessIsMine (registerOptions: RegisterClientOptions, video: Video): boolean {
|
||||||
// Note: this is not safe, but it is not a problem:
|
// Note: this is not safe, but it is not a problem:
|
||||||
// this function is used for non critical functions
|
// this function is used for non critical functions
|
||||||
try {
|
try {
|
||||||
@ -28,7 +30,7 @@ function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
|||||||
if (!username) {
|
if (!username) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (username !== video.byAccount) {
|
if (username !== video.account?.name) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -38,7 +40,7 @@ function guessIsMine (registerOptions: RegisterOptions, video: Video): boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function guessIamIModerator (_registerOptions: RegisterOptions): boolean {
|
function guessIamIModerator (_registerOptions: RegisterClientOptions): boolean {
|
||||||
// Note: this is not safe, but it is not a problem:
|
// Note: this is not safe, but it is not a problem:
|
||||||
// this function is used for non critical functions
|
// this function is used for non critical functions
|
||||||
try {
|
try {
|
||||||
@ -59,7 +61,7 @@ function guessIamIModerator (_registerOptions: RegisterOptions): boolean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function register (registerOptions: RegisterOptions): void {
|
function register (registerOptions: RegisterClientOptions): void {
|
||||||
const { registerHook, peertubeHelpers } = registerOptions
|
const { registerHook, peertubeHelpers } = registerOptions
|
||||||
let settings: any = {}
|
let settings: any = {}
|
||||||
|
|
||||||
@ -161,7 +163,7 @@ function register (registerOptions: RegisterOptions): void {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info('Trying to load the chat for video ' + video.uuid + '.')
|
logger.info(`Trying to load the chat for video ${video.uuid}.`)
|
||||||
const iframeUri = getIframeUri(registerOptions, settings, video)
|
const iframeUri = getIframeUri(registerOptions, settings, video)
|
||||||
if (!iframeUri) {
|
if (!iframeUri) {
|
||||||
logger.error('Incorrect iframe uri')
|
logger.error('Incorrect iframe uri')
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||||
|
import type { Video } from '@peertube/peertube-types'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
import { getIframeUri, UriOptions } from './uri'
|
import { getIframeUri, UriOptions } from './uri'
|
||||||
import { isAutoColorsAvailable } from 'shared/lib/autocolors'
|
import { isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||||
@ -10,7 +12,7 @@ interface ShareForm {
|
|||||||
autoColors?: HTMLInputElement
|
autoColors?: HTMLInputElement
|
||||||
}
|
}
|
||||||
|
|
||||||
async function shareChatUrl (registerOptions: RegisterOptions, settings: any, video: Video): Promise<void> {
|
async function shareChatUrl (registerOptions: RegisterClientOptions, settings: any, video: Video): Promise<void> {
|
||||||
const peertubeHelpers = registerOptions.peertubeHelpers
|
const peertubeHelpers = registerOptions.peertubeHelpers
|
||||||
|
|
||||||
const [
|
const [
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { RegisterClientOptions } from '@peertube/peertube-types/client'
|
||||||
|
import type { Video } from '@peertube/peertube-types'
|
||||||
import type { ChatType } from 'shared/lib/types'
|
import type { ChatType } from 'shared/lib/types'
|
||||||
import { AutoColors, isAutoColorsAvailable } from 'shared/lib/autocolors'
|
import { AutoColors, isAutoColorsAvailable } from 'shared/lib/autocolors'
|
||||||
import { logger } from './logger'
|
import { logger } from './logger'
|
||||||
@ -9,7 +11,7 @@ interface UriOptions {
|
|||||||
permanent?: boolean
|
permanent?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
function getBaseRoute ({ peertubeHelpers }: RegisterOptions, permanent: boolean = false): string {
|
function getBaseRoute ({ peertubeHelpers }: RegisterClientOptions, permanent: boolean = false): string {
|
||||||
if (permanent) {
|
if (permanent) {
|
||||||
return '/plugins/livechat/router'
|
return '/plugins/livechat/router'
|
||||||
}
|
}
|
||||||
@ -23,7 +25,7 @@ function getBaseRoute ({ peertubeHelpers }: RegisterOptions, permanent: boolean
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getIframeUri (
|
function getIframeUri (
|
||||||
registerOptions: RegisterOptions, settings: any, video: Video, uriOptions: UriOptions = {}
|
registerOptions: RegisterClientOptions, settings: any, video: Video, uriOptions: UriOptions = {}
|
||||||
): string | null {
|
): string | null {
|
||||||
if (!settings) {
|
if (!settings) {
|
||||||
logger.error('Settings are not initialized, too soon to compute the iframeUri')
|
logger.error('Settings are not initialized, too soon to compute the iframeUri')
|
||||||
|
3053
package-lock.json
generated
3053
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -40,6 +40,7 @@
|
|||||||
"validate-color": "^2.2.1"
|
"validate-color": "^2.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@peertube/peertube-types": "^4.0.0-beta.3",
|
||||||
"@purtuga/esm-webpack-plugin": "^1.5.0",
|
"@purtuga/esm-webpack-plugin": "^1.5.0",
|
||||||
"@tsconfig/node12": "^1.0.9",
|
"@tsconfig/node12": "^1.0.9",
|
||||||
"@types/async": "^3.2.9",
|
"@types/async": "^3.2.9",
|
||||||
|
177
server/@types/peertube.d.ts
vendored
177
server/@types/peertube.d.ts
vendored
@ -1,177 +0,0 @@
|
|||||||
interface RegisterServerHookOptions {
|
|
||||||
target: string // FIXME
|
|
||||||
handler: Function
|
|
||||||
priority?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
type RegisterServerSettingOptionsType = 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' |
|
|
||||||
'markdown-text' | 'markdown-enhanced' |
|
|
||||||
'select' | 'html'
|
|
||||||
|
|
||||||
interface RegisterServerSettingOptions {
|
|
||||||
name?: string
|
|
||||||
label?: string
|
|
||||||
type: RegisterServerSettingOptionsType
|
|
||||||
descriptionHTML?: string
|
|
||||||
default?: string | boolean
|
|
||||||
private: boolean
|
|
||||||
options?: Array<{ value: string, label: string }>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PluginSettingsManager {
|
|
||||||
getSetting: (name: string) => Promise<string | boolean>
|
|
||||||
getSettings: (names: string[]) => Promise<{ [settingName: string]: string | boolean }>
|
|
||||||
setSetting: (name: string, value: string) => Promise<any>
|
|
||||||
onSettingsChange: (cb: (names: string[]) => Promise<any>) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PluginStorageManager {
|
|
||||||
getData: (key: string) => Promise<string>
|
|
||||||
storeData: (key: string, data: any) => Promise<any>
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PluginVideoCategoryManager {
|
|
||||||
addCategory: (categoryKey: number, categoryLabel: string) => boolean
|
|
||||||
deleteCategory: (categoryKey: number) => boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PluginVideoLicenceManager {
|
|
||||||
addLicence: (licenceKey: number, licenceLabel: string) => boolean
|
|
||||||
deleteLicence: (licenceKey: number) => boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PluginVideoLanguageManager {
|
|
||||||
addLanguage: (languageKey: string, languageLabel: string) => boolean
|
|
||||||
deleteLanguage: (languageKey: string) => boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
enum VideoPrivacy {
|
|
||||||
PUBLIC = 1,
|
|
||||||
UNLISTED = 2,
|
|
||||||
PRIVATE = 3,
|
|
||||||
INTERNAL = 4
|
|
||||||
}
|
|
||||||
|
|
||||||
enum VideoState {
|
|
||||||
PUBLISHED = 1,
|
|
||||||
TO_TRANSCODE = 2,
|
|
||||||
TO_IMPORT = 3,
|
|
||||||
WAITING_FOR_LIVE = 4,
|
|
||||||
LIVE_ENDED = 5
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MVideoThumbnail { // FIXME: this interface is not complete.
|
|
||||||
id?: number
|
|
||||||
uuid: string
|
|
||||||
name: string
|
|
||||||
category: number
|
|
||||||
licence: number
|
|
||||||
language: string
|
|
||||||
privacy: VideoPrivacy
|
|
||||||
nsfw: boolean
|
|
||||||
description: string
|
|
||||||
support: string
|
|
||||||
duration: number
|
|
||||||
videos: number
|
|
||||||
likes: number
|
|
||||||
dislikes: number
|
|
||||||
remote: boolean
|
|
||||||
isLive: boolean
|
|
||||||
url: string
|
|
||||||
commentsEnabled: boolean
|
|
||||||
downloadEnabled: boolean
|
|
||||||
state: VideoState
|
|
||||||
channelId: number
|
|
||||||
pluginData?: any
|
|
||||||
}
|
|
||||||
|
|
||||||
// Keep the order
|
|
||||||
enum UserRole {
|
|
||||||
ADMINISTRATOR = 0,
|
|
||||||
MODERATOR = 1,
|
|
||||||
USER = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MUserDefault { // FIXME: this interface is not complete
|
|
||||||
id?: string | number // FIXME: type is not clear... Documentation says string, but it seems to be number
|
|
||||||
username: string
|
|
||||||
email: string
|
|
||||||
blocked: boolean
|
|
||||||
role: UserRole
|
|
||||||
Account?: { // FIXME: can this be undefined?
|
|
||||||
name: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VideoBlacklistCreate {
|
|
||||||
reason?: string
|
|
||||||
unfederate?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
type ActorModel = any // FIXME
|
|
||||||
|
|
||||||
interface ServerConfig { // FIXME: this interface is not complete
|
|
||||||
serverVersion: string
|
|
||||||
serverCommit?: string
|
|
||||||
|
|
||||||
instance: {
|
|
||||||
name: string
|
|
||||||
shortDescription: string
|
|
||||||
isNSFW: boolean
|
|
||||||
// defaultNSFWPolicy: NSFWPolicyType
|
|
||||||
defaultClientRoute: string
|
|
||||||
customizations: {
|
|
||||||
javascript: string
|
|
||||||
css: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface PeerTubeHelpers {
|
|
||||||
logger: Logger
|
|
||||||
database: {
|
|
||||||
query: Function
|
|
||||||
}
|
|
||||||
videos: {
|
|
||||||
loadByUrl: (url: string) => Promise<MVideoThumbnail>
|
|
||||||
loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail>
|
|
||||||
removeVideo: (videoId: number) => Promise<void>
|
|
||||||
}
|
|
||||||
config: {
|
|
||||||
getWebserverUrl: () => string
|
|
||||||
getServerConfig: () => Promise<ServerConfig>
|
|
||||||
}
|
|
||||||
moderation: {
|
|
||||||
blockServer: (options: { byAccountId: number, hostToBlock: string }) => Promise<void>
|
|
||||||
unblockServer: (options: { byAccountId: number, hostToUnblock: string }) => Promise<void>
|
|
||||||
blockAccount: (options: { byAccountId: number, handleToBlock: string }) => Promise<void>
|
|
||||||
unblockAccount: (options: { byAccountId: number, handleToUnblock: string }) => Promise<void>
|
|
||||||
blacklistVideo: (
|
|
||||||
options: { videoIdOrUUID: number | string, createOptions: VideoBlacklistCreate }
|
|
||||||
) => Promise<void>
|
|
||||||
unblacklistVideo: (options: { videoIdOrUUID: number | string }) => Promise<void>
|
|
||||||
}
|
|
||||||
server: {
|
|
||||||
getServerActor: () => Promise<ActorModel>
|
|
||||||
}
|
|
||||||
user: {
|
|
||||||
getAuthUser: (res: express.Response) => Promise<MUserDefault | undefined>
|
|
||||||
}
|
|
||||||
plugin: {
|
|
||||||
getBaseStaticRoute: () => string
|
|
||||||
getBaseRouterRoute: () => string
|
|
||||||
getDataDirectoryPath: () => string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface RegisterServerOptions {
|
|
||||||
registerHook: (options: RegisterServerHookOptions) => void
|
|
||||||
registerSetting: (options: RegisterServerSettingOptions) => void
|
|
||||||
settingsManager: PluginSettingsManager
|
|
||||||
storageManager: PluginStorageManager
|
|
||||||
videoCategoryManager: PluginVideoCategoryManager
|
|
||||||
videoLicenceManager: PluginVideoLicenceManager
|
|
||||||
videoLanguageManager: PluginVideoLanguageManager
|
|
||||||
getRouter: () => Router
|
|
||||||
peertubeHelpers: PeerTubeHelpers
|
|
||||||
}
|
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
/*
|
/*
|
||||||
For internal API, we will generate an api Key that must be provided as
|
For internal API, we will generate an api Key that must be provided as
|
||||||
GET parameter for every API call.
|
GET parameter for every API call.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions, MVideoThumbnail } from '@peertube/peertube-types'
|
||||||
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
async function initCustomFields (options: RegisterServerOptions): Promise<void> {
|
||||||
const registerHook = options.registerHook
|
const registerHook = options.registerHook
|
||||||
const storageManager = options.storageManager
|
const storageManager = options.storageManager
|
||||||
@ -17,11 +18,11 @@ async function initCustomFields (options: RegisterServerOptions): Promise<void>
|
|||||||
const value = body.pluginData['livechat-active']
|
const value = body.pluginData['livechat-active']
|
||||||
// NB: on Peertube 3.2.1, value is "true", "false", or "null", as strings.
|
// NB: on Peertube 3.2.1, value is "true", "false", or "null", as strings.
|
||||||
if (value === true || value === 'true') {
|
if (value === true || value === 'true') {
|
||||||
logger.info(`Saving livechat-active=true for video ${video.id}`)
|
logger.info(`Saving livechat-active=true for video ${video.id as string}`)
|
||||||
await storageManager.storeData(`livechat-active-${video.id}`, true)
|
await storageManager.storeData(`livechat-active-${video.id as string}`, true)
|
||||||
} else if (value === false || value === 'false' || value === 'null') {
|
} else if (value === false || value === 'false' || value === 'null') {
|
||||||
logger.info(`Saving livechat-active=false for video ${video.id}`)
|
logger.info(`Saving livechat-active=false for video ${video.id as string}`)
|
||||||
await storageManager.storeData(`livechat-active-${video.id}`, false)
|
await storageManager.storeData(`livechat-active-${video.id as string}`, false)
|
||||||
} else {
|
} else {
|
||||||
logger.error('Unknown value ' + JSON.stringify(value) + ' for livechat-active field.')
|
logger.error('Unknown value ' + JSON.stringify(value) + ' for livechat-active field.')
|
||||||
}
|
}
|
||||||
@ -38,7 +39,14 @@ async function initCustomFields (options: RegisterServerOptions): Promise<void>
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fillVideoCustomFields (options: RegisterServerOptions, video: MVideoThumbnail): Promise<void> {
|
// FIXME: @peertube/peertube-types@4.0.0-beta.3 is pluginData missing?
|
||||||
|
interface MVideoThumbnailLiveChat extends MVideoThumbnail {
|
||||||
|
pluginData?: {
|
||||||
|
'livechat-active'?: boolean
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function fillVideoCustomFields (options: RegisterServerOptions, video: MVideoThumbnailLiveChat): Promise<void> {
|
||||||
if (!video) return video
|
if (!video) return video
|
||||||
if (!video.pluginData) video.pluginData = {}
|
if (!video.pluginData) video.pluginData = {}
|
||||||
if (!video.id) return
|
if (!video.id) return
|
||||||
@ -46,8 +54,8 @@ async function fillVideoCustomFields (options: RegisterServerOptions, video: MVi
|
|||||||
const logger = options.peertubeHelpers.logger
|
const logger = options.peertubeHelpers.logger
|
||||||
|
|
||||||
if (video.isLive) {
|
if (video.isLive) {
|
||||||
const result: any = await storageManager.getData(`livechat-active-${video.id}`)
|
const result: any = await storageManager.getData(`livechat-active-${video.id as string}`)
|
||||||
logger.debug(`Video ${video.id} has livechat-active=` + JSON.stringify(result))
|
logger.debug(`Video ${video.id as string} has livechat-active=` + JSON.stringify(result))
|
||||||
// NB: I got weird stuff here. Maybe Peertube 3.2.1 bug?
|
// NB: I got weird stuff here. Maybe Peertube 3.2.1 bug?
|
||||||
if (result === true || result === 'true') {
|
if (result === true || result === 'true') {
|
||||||
video.pluginData['livechat-active'] = true
|
video.pluginData['livechat-active'] = true
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
|
|
||||||
async function getChannelNameById (options: RegisterServerOptions, channelId: number): Promise<string | null> {
|
async function getChannelNameById (options: RegisterServerOptions, channelId: number): Promise<string | null> {
|
||||||
if (!channelId) {
|
if (!channelId) {
|
||||||
throw new Error('Missing channelId')
|
throw new Error('Missing channelId')
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
|
|
||||||
export async function diagBackend (test: string, _options: RegisterServerOptions): Promise<TestResult> {
|
export async function diagBackend (test: string, _options: RegisterServerOptions): Promise<TestResult> {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
import type { ChatType } from '../../../shared/lib/types'
|
import type { ChatType } from '../../../shared/lib/types'
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
|
|
||||||
export async function diagConverse (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
export async function diagConverse (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { diagBackend } from './backend'
|
import { diagBackend } from './backend'
|
||||||
import { diagConverse } from './converse'
|
import { diagConverse } from './converse'
|
||||||
import { diagChatType } from './chat-type'
|
import { diagChatType } from './chat-type'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { getProsodyConfig, getProsodyConfigContentForDiagnostic, getWorkingDir } from '../prosody/config'
|
import { getProsodyConfig, getProsodyConfigContentForDiagnostic, getWorkingDir } from '../prosody/config'
|
||||||
import { getProsodyAbout, testProsodyCorrectlyRunning } from '../prosody/ctl'
|
import { getProsodyAbout, testProsodyCorrectlyRunning } from '../prosody/ctl'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
|
|
||||||
export async function diagUri (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
export async function diagUri (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { newResult, TestResult } from './utils'
|
import { newResult, TestResult } from './utils'
|
||||||
|
|
||||||
export async function diagVideo (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
export async function diagVideo (test: string, { settingsManager }: RegisterServerOptions): Promise<TestResult> {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions, PeerTubeHelpers } from '@peertube/peertube-types'
|
||||||
import { Response } from 'express'
|
import { Response } from 'express'
|
||||||
|
|
||||||
const packagejson: any = require('../../../package.json')
|
const packagejson: any = require('../../../package.json')
|
||||||
@ -39,7 +40,16 @@ async function isUserAdmin (options: RegisterServerOptions, res: Response): Prom
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getUserNickname (options: RegisterServerOptions, user: MUserDefault): Promise<string | undefined> {
|
// FIXME: @peertube/peertube-types@4.0.0-beta.3 is missing user.Account.name definition.
|
||||||
|
type Unpack<T> = T extends Promise<infer U | undefined> ? U : T
|
||||||
|
type AuthUser = Unpack<ReturnType<PeerTubeHelpers['user']['getAuthUser']>>
|
||||||
|
interface AuthUserFixed extends AuthUser {
|
||||||
|
Account?: {
|
||||||
|
name: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getUserNickname (options: RegisterServerOptions, user: AuthUserFixed): Promise<string | undefined> {
|
||||||
const peertubeHelpers = options.peertubeHelpers
|
const peertubeHelpers = options.peertubeHelpers
|
||||||
const logger = peertubeHelpers.logger
|
const logger = peertubeHelpers.logger
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { Request, Response, NextFunction } from 'express'
|
import type { Request, Response, NextFunction } from 'express'
|
||||||
import { getAPIKey } from '../apikey'
|
import { getAPIKey } from '../apikey'
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { pluginShortName } from '../helpers'
|
import { pluginShortName } from '../helpers'
|
||||||
import type { ChatType } from '../../../shared/lib/types'
|
import type { ChatType } from '../../../shared/lib/types'
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { ProsodyLogLevel } from './config/content'
|
import type { ProsodyLogLevel } from './config/content'
|
||||||
import * as fs from 'fs'
|
import * as fs from 'fs'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions, MVideoThumbnail } from '@peertube/peertube-types'
|
||||||
import { getProsodyDomain } from './domain'
|
import { getProsodyDomain } from './domain'
|
||||||
import { getUserNameByChannelId } from '../../database/channel'
|
import { getUserNameByChannelId } from '../../database/channel'
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
|
|
||||||
async function getProsodyDomain (options: RegisterServerOptions): Promise<string> {
|
async function getProsodyDomain (options: RegisterServerOptions): Promise<string> {
|
||||||
const url = options.peertubeHelpers.config.getWebserverUrl()
|
const url = options.peertubeHelpers.config.getWebserverUrl()
|
||||||
const matches = url.match(/^https?:\/\/([^:/]*)(:\d+)?(\/|$)/)
|
const matches = url.match(/^https?:\/\/([^:/]*)(:\d+)?(\/|$)/)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { getProsodyConfig, getProsodyFilePaths, writeProsodyConfig } from './config'
|
import { getProsodyConfig, getProsodyFilePaths, writeProsodyConfig } from './config'
|
||||||
import { startProsodyLogRotate, stopProsodyLogRotate } from './logrotate'
|
import { startProsodyLogRotate, stopProsodyLogRotate } from './logrotate'
|
||||||
import { changeHttpBindRoute } from '../routers/webchat'
|
import { changeHttpBindRoute } from '../routers/webchat'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { ProsodyFilePaths } from './config/paths'
|
import type { ProsodyFilePaths } from './config/paths'
|
||||||
|
|
||||||
type Rotate = (file: string, options: {
|
type Rotate = (file: string, options: {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { Router, Request, Response, NextFunction } from 'express'
|
import type { Router, Request, Response, NextFunction } from 'express'
|
||||||
import { videoHasWebchat } from '../../../shared/lib/video'
|
import { videoHasWebchat } from '../../../shared/lib/video'
|
||||||
import { asyncMiddleware } from '../middlewares/async'
|
import { asyncMiddleware } from '../middlewares/async'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { NextFunction, Request, Response } from 'express'
|
import type { NextFunction, Request, Response } from 'express'
|
||||||
import { initWebchatRouter } from './webchat'
|
import { initWebchatRouter } from './webchat'
|
||||||
import { initSettingsRouter } from './settings'
|
import { initSettingsRouter } from './settings'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import type { Router, Request, Response, NextFunction } from 'express'
|
import type { Router, Request, Response, NextFunction } from 'express'
|
||||||
import { diag } from '../diagnostic'
|
import { diag } from '../diagnostic'
|
||||||
import { getBaseStaticRoute, isUserAdmin } from '../helpers'
|
import { getBaseStaticRoute, isUserAdmin } from '../helpers'
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions, MVideoThumbnail } from '@peertube/peertube-types'
|
||||||
import type { Router, RequestHandler, Request, Response, NextFunction } from 'express'
|
import type { Router, RequestHandler, Request, Response, NextFunction } from 'express'
|
||||||
import type { ProxyOptions } from 'express-http-proxy'
|
import type { ProxyOptions } from 'express-http-proxy'
|
||||||
import type {
|
import type {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { ensureProsodyRunning, ensureProsodyNotRunning } from './prosody/ctl'
|
import { ensureProsodyRunning, ensureProsodyNotRunning } from './prosody/ctl'
|
||||||
import type { ChatType, ConverseJSTheme } from '../../shared/lib/types'
|
import type { ChatType, ConverseJSTheme } from '../../shared/lib/types'
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import type { RegisterServerOptions } from '@peertube/peertube-types'
|
||||||
import { migrateSettings } from './lib/migration/settings'
|
import { migrateSettings } from './lib/migration/settings'
|
||||||
import { initSettings } from './lib/settings'
|
import { initSettings } from './lib/settings'
|
||||||
import { initCustomFields } from './lib/custom-fields'
|
import { initCustomFields } from './lib/custom-fields'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user