mirror of
https://github.com/thelounge/thelounge.git
synced 2024-06-01 05:12:24 +02:00
configuration
This commit is contained in:
parent
7bc184b252
commit
8e6920af1d
|
@ -3,7 +3,8 @@ import socket from "../socket";
|
||||||
import {cleanIrcMessage} from "../../../shared/irc";
|
import {cleanIrcMessage} from "../../../shared/irc";
|
||||||
import {store} from "../store";
|
import {store} from "../store";
|
||||||
import {switchToChannel} from "../router";
|
import {switchToChannel} from "../router";
|
||||||
import {ClientChan, ClientMention, ClientMessage, NetChan} from "../types";
|
import {ClientChan, NetChan} from "../types";
|
||||||
|
import {ClientMessage} from "../../../shared/types/msg";
|
||||||
|
|
||||||
let pop;
|
let pop;
|
||||||
|
|
||||||
|
|
|
@ -3,19 +3,13 @@
|
||||||
import {ActionContext, createStore, Store, useStore as baseUseStore} from "vuex";
|
import {ActionContext, createStore, Store, useStore as baseUseStore} from "vuex";
|
||||||
import {createSettingsStore} from "./store-settings";
|
import {createSettingsStore} from "./store-settings";
|
||||||
import storage from "./localStorage";
|
import storage from "./localStorage";
|
||||||
import type {
|
import type {ClientChan, ClientNetwork, InitClientChan, NetChan, ClientMention} from "./types";
|
||||||
ClientChan,
|
|
||||||
ClientConfiguration,
|
|
||||||
ClientNetwork,
|
|
||||||
InitClientChan,
|
|
||||||
NetChan,
|
|
||||||
ClientMessage,
|
|
||||||
ClientMention,
|
|
||||||
} from "./types";
|
|
||||||
import type {InjectionKey} from "vue";
|
import type {InjectionKey} from "vue";
|
||||||
|
|
||||||
import {SettingsState} from "./settings";
|
import {SettingsState} from "./settings";
|
||||||
import {SearchQuery} from "../../shared/types/storage";
|
import {SearchQuery} from "../../shared/types/storage";
|
||||||
|
import {ClientMessage} from "../../shared/types/msg";
|
||||||
|
import {SharedConfiguration, LockedSharedConfiguration} from "../../shared/types/config";
|
||||||
|
|
||||||
const appName = document.title;
|
const appName = document.title;
|
||||||
|
|
||||||
|
@ -59,7 +53,7 @@ export type State = {
|
||||||
mentions: ClientMention[];
|
mentions: ClientMention[];
|
||||||
hasServiceWorker: boolean;
|
hasServiceWorker: boolean;
|
||||||
pushNotificationState: string;
|
pushNotificationState: string;
|
||||||
serverConfiguration: ClientConfiguration | null;
|
serverConfiguration: SharedConfiguration | LockedSharedConfiguration | null;
|
||||||
sessions: ClientSession[];
|
sessions: ClientSession[];
|
||||||
sidebarOpen: boolean;
|
sidebarOpen: boolean;
|
||||||
sidebarDragging: boolean;
|
sidebarDragging: boolean;
|
||||||
|
|
3
client/js/types.d.ts
vendored
3
client/js/types.d.ts
vendored
|
@ -4,7 +4,7 @@ import {SharedChan} from "../../shared/types/chan";
|
||||||
import {SharedNetwork} from "../../shared/types/network";
|
import {SharedNetwork} from "../../shared/types/network";
|
||||||
import {SharedUser} from "../../shared/models/user";
|
import {SharedUser} from "../../shared/models/user";
|
||||||
import {SharedMention} from "../../shared/models/mention";
|
import {SharedMention} from "../../shared/models/mention";
|
||||||
import {ClientConfiguration} from "../../server/server";
|
import {SharedConfiguration, LockedSharedConfiguration} from "../../shared/types/config";
|
||||||
import {LinkPreview} from "../../server/plugins/irc-events/link";
|
import {LinkPreview} from "../../server/plugins/irc-events/link";
|
||||||
|
|
||||||
interface LoungeWindow extends Window {
|
interface LoungeWindow extends Window {
|
||||||
|
@ -51,7 +51,6 @@ type NetChan = {
|
||||||
network: ClientNetwork;
|
network: ClientNetwork;
|
||||||
};
|
};
|
||||||
|
|
||||||
type ClientConfiguration = ClientConfiguration;
|
|
||||||
type ClientMention = SharedMention & {
|
type ClientMention = SharedMention & {
|
||||||
localetime: string;
|
localetime: string;
|
||||||
channel: NetChan | null;
|
channel: NetChan | null;
|
||||||
|
|
|
@ -44,7 +44,7 @@ export type Defaults = Pick<
|
||||||
| "saslAccount"
|
| "saslAccount"
|
||||||
| "saslPassword"
|
| "saslPassword"
|
||||||
> & {
|
> & {
|
||||||
join?: string;
|
join: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type Identd = {
|
type Identd = {
|
||||||
|
|
103
server/server.ts
103
server/server.ts
|
@ -32,6 +32,12 @@ import type {
|
||||||
SocketData,
|
SocketData,
|
||||||
} from "../shared/types/socket-events";
|
} from "../shared/types/socket-events";
|
||||||
import {ChanType} from "../shared/types/chan";
|
import {ChanType} from "../shared/types/chan";
|
||||||
|
import {
|
||||||
|
LockedSharedConfiguration,
|
||||||
|
SharedConfiguration,
|
||||||
|
ConfigNetDefaults,
|
||||||
|
LockedConfigNetDefaults,
|
||||||
|
} from "../shared/types/config";
|
||||||
|
|
||||||
type ServerOptions = {
|
type ServerOptions = {
|
||||||
dev: boolean;
|
dev: boolean;
|
||||||
|
@ -45,22 +51,6 @@ type IndexTemplateConfiguration = ServerConfiguration & {
|
||||||
cacheBust: string;
|
cacheBust: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ClientConfiguration = Pick<
|
|
||||||
ConfigType,
|
|
||||||
"public" | "lockNetwork" | "useHexIp" | "prefetch" | "defaults"
|
|
||||||
> & {
|
|
||||||
fileUpload: boolean;
|
|
||||||
ldapEnabled: boolean;
|
|
||||||
isUpdateAvailable: boolean;
|
|
||||||
applicationServerKey: string;
|
|
||||||
version: string;
|
|
||||||
gitCommit: string | null;
|
|
||||||
defaultTheme: string;
|
|
||||||
themes: ThemeForClient[];
|
|
||||||
defaults: Defaults;
|
|
||||||
fileUploadMaxFileSize?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
// A random number that will force clients to reload the page if it differs
|
// A random number that will force clients to reload the page if it differs
|
||||||
const serverHash = Math.floor(Date.now() * Math.random());
|
const serverHash = Math.floor(Date.now() * Math.random());
|
||||||
|
|
||||||
|
@ -857,47 +847,58 @@ function initializeClient(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClientConfiguration(): ClientConfiguration {
|
function getClientConfiguration(): SharedConfiguration | LockedSharedConfiguration {
|
||||||
const config = _.pick(Config.values, [
|
const common = {
|
||||||
"public",
|
fileUpload: Config.values.fileUpload.enable,
|
||||||
"lockNetwork",
|
ldapEnabled: Config.values.ldap.enable,
|
||||||
"useHexIp",
|
isUpdateAvailable: changelog.isUpdateAvailable,
|
||||||
"prefetch",
|
applicationServerKey: manager!.webPush.vapidKeys!.publicKey,
|
||||||
]) as ClientConfiguration;
|
version: Helper.getVersionNumber(),
|
||||||
|
gitCommit: Helper.getGitCommit(),
|
||||||
|
themes: themes.getAll(),
|
||||||
|
defaultTheme: Config.values.theme,
|
||||||
|
public: Config.values.public,
|
||||||
|
useHexIp: Config.values.useHexIp,
|
||||||
|
prefetch: Config.values.prefetch,
|
||||||
|
fileUploadMaxFileSize: Uploader ? Uploader.getMaxFileSize() : undefined, // TODO can't be undefined?
|
||||||
|
};
|
||||||
|
|
||||||
config.fileUpload = Config.values.fileUpload.enable;
|
const defaultsOverride = {
|
||||||
config.ldapEnabled = Config.values.ldap.enable;
|
nick: Config.getDefaultNick(), // expand the number part
|
||||||
|
|
||||||
if (!config.lockNetwork) {
|
// TODO: this doesn't seem right, if the client needs this as a buffer
|
||||||
config.defaults = _.clone(Config.values.defaults);
|
// the client ought to add it on its own
|
||||||
} else {
|
sasl: "",
|
||||||
// Only send defaults that are visible on the client
|
saslAccount: "",
|
||||||
config.defaults = _.pick(Config.values.defaults, [
|
saslPassword: "",
|
||||||
"name",
|
};
|
||||||
"nick",
|
|
||||||
"username",
|
if (!Config.values.lockNetwork) {
|
||||||
"password",
|
const defaults: ConfigNetDefaults = {
|
||||||
"realname",
|
..._.clone(Config.values.defaults),
|
||||||
"join",
|
...defaultsOverride,
|
||||||
]) as Defaults;
|
};
|
||||||
|
const result: SharedConfiguration = {
|
||||||
|
...common,
|
||||||
|
defaults: defaults,
|
||||||
|
lockNetwork: Config.values.lockNetwork,
|
||||||
|
};
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
config.isUpdateAvailable = changelog.isUpdateAvailable;
|
// Only send defaults that are visible on the client
|
||||||
config.applicationServerKey = manager!.webPush.vapidKeys!.publicKey;
|
const defaults: LockedConfigNetDefaults = {
|
||||||
config.version = Helper.getVersionNumber();
|
..._.pick(Config.values.defaults, ["name", "username", "password", "realname", "join"]),
|
||||||
config.gitCommit = Helper.getGitCommit();
|
...defaultsOverride,
|
||||||
config.themes = themes.getAll();
|
};
|
||||||
config.defaultTheme = Config.values.theme;
|
|
||||||
config.defaults.nick = Config.getDefaultNick();
|
|
||||||
config.defaults.sasl = "";
|
|
||||||
config.defaults.saslAccount = "";
|
|
||||||
config.defaults.saslPassword = "";
|
|
||||||
|
|
||||||
if (Uploader) {
|
const result: LockedSharedConfiguration = {
|
||||||
config.fileUploadMaxFileSize = Uploader.getMaxFileSize();
|
...common,
|
||||||
}
|
lockNetwork: Config.values.lockNetwork,
|
||||||
|
defaults: defaults,
|
||||||
|
};
|
||||||
|
|
||||||
return config;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServerConfiguration(): ServerConfiguration {
|
function getServerConfiguration(): ServerConfiguration {
|
||||||
|
|
|
@ -1,53 +1,50 @@
|
||||||
const config_example = {
|
export type ConfigTheme = {
|
||||||
public: false,
|
displayName: string;
|
||||||
lockNetwork: false,
|
name: string;
|
||||||
useHexIp: false,
|
themeColor: string | null;
|
||||||
prefetch: true,
|
};
|
||||||
fileUpload: true,
|
type SharedConfigurationBase = {
|
||||||
ldapEnabled: false,
|
public: boolean;
|
||||||
defaults: {
|
useHexIp: boolean;
|
||||||
name: "test",
|
prefetch: boolean;
|
||||||
host: "irc.libera.chat",
|
fileUpload: boolean;
|
||||||
port: 6697,
|
ldapEnabled: boolean;
|
||||||
password: "",
|
isUpdateAvailable: boolean;
|
||||||
tls: true,
|
applicationServerKey: string;
|
||||||
rejectUnauthorized: true,
|
version: string;
|
||||||
nick: "butler",
|
gitCommit: string | null;
|
||||||
username: "",
|
themes: ConfigTheme[];
|
||||||
realname: "",
|
defaultTheme: string;
|
||||||
join: "#thelounge-test",
|
fileUploadMaxFileSize?: number;
|
||||||
leaveMessage: "",
|
};
|
||||||
sasl: "",
|
|
||||||
saslAccount: "",
|
export type ConfigNetDefaults = {
|
||||||
saslPassword: "",
|
name: string;
|
||||||
},
|
host: string;
|
||||||
isUpdateAvailable: false,
|
port: number;
|
||||||
applicationServerKey:
|
password: string;
|
||||||
"BHcIWSuK8Yt_1nkWqKFcSdLQtuLuZyfegdugXQa_UBv02dOZtDhwEJocb1h8bxOSzLgkNRAAArw8BC126rTuc5Q",
|
tls: boolean;
|
||||||
version: "4.4.2-rc.1",
|
rejectUnauthorized: boolean;
|
||||||
gitCommit: "1f66dd2af",
|
nick: string;
|
||||||
themes: [
|
username: string;
|
||||||
{
|
realname: string;
|
||||||
displayName: "Default",
|
join: string;
|
||||||
name: "default",
|
leaveMessage: string;
|
||||||
themeColor: null,
|
sasl: string;
|
||||||
},
|
saslAccount: string;
|
||||||
{
|
saslPassword: string;
|
||||||
displayName: "Gruvbox",
|
};
|
||||||
name: "thelounge-theme-gruvbox",
|
export type LockedConfigNetDefaults = Pick<
|
||||||
themeColor: "#282828",
|
ConfigNetDefaults,
|
||||||
},
|
"name" | "nick" | "username" | "password" | "realname" | "join"
|
||||||
{
|
>;
|
||||||
displayName: "Morning",
|
|
||||||
name: "morning",
|
export type LockedSharedConfiguration = SharedConfigurationBase & {
|
||||||
themeColor: null,
|
lockNetwork: true;
|
||||||
},
|
defaults: LockedConfigNetDefaults;
|
||||||
{
|
};
|
||||||
displayName: "Solarized",
|
|
||||||
name: "thelounge-theme-solarized",
|
export type SharedConfiguration = SharedConfigurationBase & {
|
||||||
themeColor: "#002b36",
|
lockNetwork: false;
|
||||||
},
|
defaults: ConfigNetDefaults;
|
||||||
],
|
|
||||||
defaultTheme: "default",
|
|
||||||
fileUploadMaxFileSize: 10485760,
|
|
||||||
};
|
};
|
||||||
|
|
4
shared/types/socket-events.d.ts
vendored
4
shared/types/socket-events.d.ts
vendored
|
@ -5,7 +5,7 @@ import {SharedMsg, ClientMessage} from "../../shared/types/msg";
|
||||||
import {SharedUser} from "../../shared/types/user";
|
import {SharedUser} from "../../shared/types/user";
|
||||||
import {SharedChangelogData} from "../../shared/types/changelog";
|
import {SharedChangelogData} from "../../shared/types/changelog";
|
||||||
import {LinkPreview} from "../plugins/irc-events/link";
|
import {LinkPreview} from "../plugins/irc-events/link";
|
||||||
import {ClientConfiguration} from "../server";
|
import {SharedConfiguration, LockedSharedConfiguration} from "../../shared/types/config";
|
||||||
|
|
||||||
type Session = {
|
type Session = {
|
||||||
current: boolean;
|
current: boolean;
|
||||||
|
@ -32,7 +32,7 @@ interface ServerToClientEvents {
|
||||||
|
|
||||||
commands: (data: string[]) => void;
|
commands: (data: string[]) => void;
|
||||||
|
|
||||||
configuration: (config: ClientConfiguration) => void;
|
configuration: (config: SharedConfiguration | LockedSharedConfiguration) => void;
|
||||||
|
|
||||||
"push:issubscribed": (isSubscribed: boolean) => void;
|
"push:issubscribed": (isSubscribed: boolean) => void;
|
||||||
"push:unregister": () => void;
|
"push:unregister": () => void;
|
||||||
|
|
Loading…
Reference in a new issue