peertube-plugin-livechat/shared/lib/types.ts

164 lines
3.6 KiB
TypeScript
Raw Normal View History

2024-05-23 09:42:14 +00:00
// SPDX-FileCopyrightText: 2024 John Livingston <https://www.john-livingston.fr/>
//
// SPDX-License-Identifier: AGPL-3.0-only
// Not working for some reason
// import type { ActorImage } from '@peertube/peertube-types'
interface ActorImage {
width: number
path: string
url?: string
createdAt: Date | string
updatedAt: Date | string
}
2021-11-18 10:08:12 +00:00
type ConverseJSTheme = 'peertube' | 'default' | 'concord'
interface InitConverseJSParams {
peertubeVideoOriginalUrl?: string
peertubeVideoUUID?: string
isRemoteChat: boolean
localAnonymousJID: string | null
remoteAnonymousJID: string | null
remoteAnonymousXMPPServer: boolean
remoteAuthenticatedXMPPServer: boolean
staticBaseUrl: string
assetsPath: string
room: string
localBoshServiceUrl: string | null
localWebsocketServiceUrl: string | null
remoteBoshServiceUrl: string | null
remoteWebsocketServiceUrl: string | null
authenticationUrl: string
autoViewerMode: boolean
forceReadonly: boolean | 'noscroll'
theme: ConverseJSTheme
transparent: boolean
forceDefaultHideMucParticipants?: boolean
2024-04-02 15:40:43 +00:00
autofocus?: boolean
externalAuthOIDC?: Array<{
type: ExternalAuthOIDCType
buttonLabel: string
url: string
}>
}
interface InitConverseJSParamsError {
isError: true
code: 404 | 403 | 500
message: string
}
2021-06-11 23:16:57 +00:00
interface ProsodyListRoomsResultError {
ok: false
error: string
}
2021-08-05 16:25:27 +00:00
interface ProsodyListRoomsResultRoom {
jid: string
localpart: string
name: string
lang: string
description: string
lasttimestamp?: number
channel?: {
id: number
name: string
displayName: string
}
}
2021-06-11 23:16:57 +00:00
interface ProsodyListRoomsResultSuccess {
ok: true
2021-08-05 16:25:27 +00:00
rooms: ProsodyListRoomsResultRoom[]
2021-06-11 23:16:57 +00:00
}
type ProsodyListRoomsResult = ProsodyListRoomsResultError | ProsodyListRoomsResultSuccess
2023-08-09 14:16:02 +00:00
interface ChannelInfos {
id: number
name: string
displayName: string
}
interface ChannelLiveChatInfos extends ChannelInfos {
avatar: ActorImage
avatars: ActorImage[]
livechatConfigurationUri: string
}
interface ChannelConfigurationOptions {
2023-09-21 17:32:47 +00:00
bot: {
enabled: boolean
nickname?: string
forbiddenWords: Array<{
entries: string[]
regexp?: boolean
applyToModerators?: boolean
2024-04-05 18:46:14 +00:00
label?: string
2023-09-21 17:32:47 +00:00
reason?: string
2023-09-25 11:16:15 +00:00
comments?: string
2023-09-21 17:32:47 +00:00
}>
quotes: Array<{
messages: string[]
delay: number
}>
commands: Array<{
command: string
message: string
}>
// TODO: bannedJIDs: string[]
}
slowMode: {
duration: number
}
2023-08-08 16:26:40 +00:00
}
interface ChannelConfiguration {
2023-08-09 14:16:02 +00:00
channel: ChannelInfos
configuration: ChannelConfigurationOptions
2023-08-09 14:16:02 +00:00
}
type ChatPeertubeIncludeMode = 'peertube-fullpage' | 'peertube-video'
/**
* ChatIncludeMode:
* - chat-only: the chat is on a full page, without Peertube
* - peertube-fullpage: the chat is embedded in Peertube, in a full custom page
* - peertube-video: the chat is embedded in Peertube, beside a video
*/
type ChatIncludeMode = 'chat-only' | ChatPeertubeIncludeMode
interface ExternalAuthResultOk {
ok: true
token: string
}
interface ExternalAuthResultError {
ok: false
message?: string
}
type ExternalAuthResult = ExternalAuthResultError | ExternalAuthResultOk
type ExternalAuthOIDCType = 'custom' | 'google' | 'facebook'
export type {
2021-11-18 10:08:12 +00:00
ConverseJSTheme,
InitConverseJSParams,
InitConverseJSParamsError,
2021-08-05 16:25:27 +00:00
ProsodyListRoomsResult,
2023-08-08 16:26:40 +00:00
ProsodyListRoomsResultRoom,
2023-08-09 14:16:02 +00:00
ChannelInfos,
ChannelLiveChatInfos,
ChannelConfigurationOptions,
ChannelConfiguration,
ChatIncludeMode,
ChatPeertubeIncludeMode,
ExternalAuthResultError,
ExternalAuthResultOk,
ExternalAuthResult,
ExternalAuthOIDCType
}