This commit is contained in:
Reto Brunner 2024-02-15 23:01:22 +01:00
commit 3eb19135f5
52 changed files with 185 additions and 102 deletions

View file

@ -7,9 +7,10 @@ import colors from "chalk";
import log from "./log";
import Chan, {ChanConfig, Channel, ChanType} from "./models/chan";
import Msg, {MessageType, UserInMessage} from "./models/msg";
import Msg from "./models/msg";
import Config from "./config";
import {condensedTypes} from "../shared/irc";
import {MessageType, UserInMessage} from "../shared/types/msg";
import inputs from "./plugins/inputs";
import PublicClient from "./plugins/packages/publicClient";

View file

@ -2,11 +2,12 @@ import _ from "lodash";
import log from "../log";
import Config from "../config";
import User from "./user";
import Msg, {MessageType} from "./msg";
import Msg from "./msg";
import storage from "../plugins/storage";
import Client from "../client";
import Network from "./network";
import Prefix from "./prefix";
import {MessageType} from "../../shared/types/msg";
export enum ChanType {
CHANNEL = "channel",

View file

@ -1,41 +1,5 @@
import _ from "lodash";
import {LinkPreview} from "../plugins/irc-events/link";
import User from "./user";
export type UserInMessage = Partial<User> & {
mode: string;
};
export enum MessageType {
UNHANDLED = "unhandled",
ACTION = "action",
AWAY = "away",
BACK = "back",
ERROR = "error",
INVITE = "invite",
JOIN = "join",
KICK = "kick",
LOGIN = "login",
LOGOUT = "logout",
MESSAGE = "message",
MODE = "mode",
MODE_CHANNEL = "mode_channel",
MODE_USER = "mode_user", // RPL_UMODEIS
MONOSPACE_BLOCK = "monospace_block",
NICK = "nick",
NOTICE = "notice",
PART = "part",
QUIT = "quit",
CTCP = "ctcp",
CTCP_REQUEST = "ctcp_request",
CHGHOST = "chghost",
TOPIC = "topic",
TOPIC_SET_BY = "topic_set_by",
WHOIS = "whois",
RAW = "raw",
PLUGIN = "plugin",
WALLOPS = "wallops",
}
import {MessageType, LinkPreview, UserInMessage} from "../../shared/types/msg";
class Msg {
from!: UserInMessage;

View file

@ -2,13 +2,14 @@ import _ from "lodash";
import {v4 as uuidv4} from "uuid";
import IrcFramework, {Client as IRCClient} from "irc-framework";
import Chan, {ChanConfig, Channel, ChanType} from "./chan";
import Msg, {MessageType} from "./msg";
import Msg from "./msg";
import Prefix from "./prefix";
import Helper, {Hostmask} from "../helper";
import Config, {WebIRC} from "../config";
import STSPolicies from "../plugins/sts";
import ClientCertificate, {ClientCertificateType} from "../plugins/clientCertificate";
import Client from "../client";
import {MessageType} from "../../shared/types/msg";
/**
* List of keys which should be sent to the client by default.

View file

@ -1,6 +1,7 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["slap", "me"];

View file

@ -1,6 +1,7 @@
import {ChanType} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {PluginInputHandler} from "./index";
import {MessageType} from "../../../shared/types/msg";
const commands = ["ban", "unban", "banlist", "kickban"];

View file

@ -1,5 +1,6 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {PluginInputHandler} from "./index";
import {MessageType} from "../../../shared/types/msg";
const commands = ["connect", "server"];
const allowDisconnected = true;

View file

@ -1,5 +1,6 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {PluginInputHandler} from "./index";
import {MessageType} from "../../../shared/types/msg";
const commands = ["ctcp"];

View file

@ -1,8 +1,9 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Helper from "../../helper";
import {PluginInputHandler} from "./index";
import {IgnoreListItem} from "../../models/network";
import {ChanType, SpecialChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["ignore", "unignore", "ignorelist"];

View file

@ -1,6 +1,7 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["invite", "invitelist"];

View file

@ -1,6 +1,7 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["kick"];

View file

@ -1,7 +1,8 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["mode", "umode", "op", "deop", "hop", "dehop", "voice", "devoice"];

View file

@ -1,6 +1,7 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Chan, {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["query", "msg", "say"];

View file

@ -2,9 +2,10 @@ import Chan from "../../models/chan";
import Network from "../../models/network";
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Client from "../../client";
import {MessageType} from "../../../shared/types/msg";
const commands = ["mute", "unmute"];
const allowDisconnected = true;

View file

@ -1,6 +1,7 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
const commands = ["nick"];
const allowDisconnected = true;

View file

@ -1,8 +1,9 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Config from "../../config";
import {ChanType, ChanState} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["close", "leave", "part"];
const allowDisconnected = true;

View file

@ -1,7 +1,8 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["cycle", "rejoin"];

View file

@ -1,7 +1,8 @@
import {PluginInputHandler} from "./index";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {ChanType} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
const commands = ["topic"];

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import {ChanType} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -3,10 +3,11 @@ import _ from "lodash";
import {IrcEventHandler} from "../../client";
import log from "../../log";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Helper from "../../helper";
import Config from "../../config";
import {ChanType, ChanState} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,9 +1,10 @@
import _ from "lodash";
import {IrcEventHandler} from "../../client";
import Helper from "../../helper";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import User from "../../models/user";
import pkg from "../../../package.json";
import {MessageType} from "../../../shared/types/msg";
const ctcpResponses = {
CLIENTINFO: () =>

View file

@ -1,7 +1,8 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import Config from "../../config";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,5 +1,6 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {IrcEventHandler} from "../../client";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,5 +1,6 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {IrcEventHandler} from "../../client";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,7 +1,8 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import User from "../../models/user";
import type {IrcEventHandler} from "../../client";
import {ChanState} from "../../models/chan";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,8 +1,9 @@
import {IrcEventHandler} from "../../client";
import {ChanState} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import User from "../../models/user";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -6,6 +6,7 @@ import mime from "mime-types";
import log from "../../log";
import Config from "../../config";
import {findLinksWithSchema} from "../../../shared/linkify";
import {LinkPreview} from "../../../shared/types/msg";
import storage from "../storage";
import Client from "../../client";
import Chan from "../../models/chan";
@ -20,23 +21,6 @@ const currentFetchPromises = new Map<string, Promise<FetchRequest>>();
const imageTypeRegex = /^image\/.+/;
const mediaTypeRegex = /^(audio|video)\/.+/;
export type LinkPreview = {
type: string;
head: string;
body: string;
thumb: string;
size: number;
link: string; // Send original matched link to the client
shown?: boolean | null;
error?: string;
message?: string;
media?: string;
mediaType?: string;
maxSize?: number;
thumbActualUrl?: string;
};
export default function (client: Client, chan: Chan, msg: Msg, cleanText: string) {
if (!Config.values.prefetch) {
return;

View file

@ -1,10 +1,11 @@
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import LinkPrefetch from "./link";
import {cleanIrcMessage} from "../../../shared/irc";
import Helper from "../../helper";
import {IrcEventHandler} from "../../client";
import Chan, {ChanType} from "../../models/chan";
import User from "../../models/user";
import {MessageType} from "../../../shared/types/msg";
const nickRegExp = /(?:\x03[0-9]{1,2}(?:,[0-9]{1,2})?)?([\w[\]\\`^{|}-]+)/g;

View file

@ -1,7 +1,8 @@
import _ from "lodash";
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,7 +1,8 @@
import {IrcEventHandler} from "../../client";
import {SpecialChanType, ChanType} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,6 +1,7 @@
import {IrcEventHandler} from "../../client";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -1,7 +1,8 @@
import {IrcEventHandler} from "../../client";
import {ChanType} from "../../models/chan";
import Msg, {MessageType} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType} from "../../../shared/types/msg";
export default <IrcEventHandler>function (irc, network) {
const client = this;

View file

@ -6,8 +6,9 @@ import filenamify from "filenamify";
import Config from "../../config";
import {MessageStorage} from "./types";
import Channel from "../../models/chan";
import {Message, MessageType} from "../../models/msg";
import {Message} from "../../models/msg";
import Network from "../../models/network";
import {MessageType} from "../../../shared/types/msg";
class TextFileMessageStorage implements MessageStorage {
isEnabled: boolean;

View file

@ -4,7 +4,7 @@ import {Channel} from "../../models/channel";
import {Message} from "../../models/message";
import {Network} from "../../models/network";
import Client from "../../client";
import type {MessageType} from "../../models/msg";
import type {MessageType} from "../../../shared/types/msg";
export type DeletionRequest = {
olderThanDays: number;

View file

@ -1,7 +1,8 @@
import {PackageInfo} from "./index";
import Client from "../../client";
import Chan from "../../models/chan";
import Msg, {MessageType, UserInMessage} from "../../models/msg";
import Msg from "../../models/msg";
import {MessageType, UserInMessage} from "../../../shared/types/msg";
export default class PublicClient {
private client: Client;

View file

@ -31,7 +31,7 @@ import type {
ServerToClientEvents,
InterServerEvents,
SocketData,
} from "./types/socket-events";
} from "../shared/types/socket-events";
type ServerOptions = {
dev: boolean;

View file

@ -1,8 +1,8 @@
import SqliteMessageStorage from "./plugins/messageStorage/sqlite";
import {MessageType} from "./models/msg";
import Config from "./config";
import {DeletionRequest} from "./plugins/messageStorage/types";
import log from "./log";
import {MessageType} from "../shared/types/msg";
const status_types = [
MessageType.AWAY,

View file

@ -1,7 +1,7 @@
{
"extends": "../tsconfig.base.json" /* Path to base configuration file to inherit from. Requires TypeScript version 2.1 or later. */,
"include": [
"**/*",
".",
"../shared/"
] /* Specifies a list of glob patterns that match files to be included in compilation. If no 'files' or 'include' property is present in a tsconfig.json, the compiler defaults to including all files in the containing directory and subdirectories except those specified by 'exclude'. Requires TypeScript version 2.0 or later. */,
"files": [

View file

@ -1,2 +1 @@
import "./modules";
import "./socket-events";

View file

@ -1,224 +0,0 @@
import {ClientMessage, ClientNetwork, InitClientChan} from "../../client/js/types";
import {Mention} from "../client";
import {ChanState} from "../models/chan";
import Msg from "../models/msg";
import Network from "../models/network";
import User from "../models/user";
import {ChangelogData} from "../plugins/changelog";
import {LinkPreview} from "../plugins/irc-events/link";
import {ClientConfiguration} from "../server";
type Session = {
current: boolean;
active: number;
lastUse: number;
ip: string;
agent: string;
token: string;
};
interface ServerToClientEvents {
"auth:failed": () => void;
"auth:start": (serverHash: number) => void;
"auth:success": () => void;
"upload:auth": (token: string) => void;
changelog: (data: ChangelogData) => void;
"changelog:newversion": () => void;
"channel:state": (data: {chan: number; state: ChanState}) => void;
"change-password": ({success, error}: {success: boolean; error?: any}) => void;
commands: (data: string[]) => void;
configuration: (config: ClientConfiguration) => void;
"push:issubscribed": (isSubscribed: boolean) => void;
"push:unregister": () => void;
"sessions:list": (data: Session[]) => void;
"mentions:list": (data: Mention[]) => void;
"setting:new": ({name: string, value: any}) => void;
"setting:all": (settings: {[key: string]: any}) => void;
"history:clear": ({target}: {target: number}) => void;
"mute:changed": (response: {target: number; status: boolean}) => void;
names: (data: {id: number; users: User[]}) => void;
network: (data: {networks: ClientNetwork[]}) => void;
"network:options": (data: {network: string; serverOptions: {[key: string]: any}}) => void;
"network:status": (data: {network: string; connected: boolean; secure: boolean}) => void;
"network:info": (data: {uuid: string}) => void;
"network:name": (data: {uuid: string; name: string}) => void;
nick: (data: {network: string; nick: string}) => void;
open: (id: number) => void;
part: (data: {chan: number}) => void;
"sign-out": () => void;
sync_sort: (
data:
| {
type: "networks";
order: string[];
target: string;
}
| {
type: "channels";
order: number[];
target: string;
}
) => void;
topic: (data: {chan: number; topic: string}) => void;
users: (data: {chan: number}) => void;
more: ({
chan,
messages,
totalMessages,
}: {
chan: number;
messages: Msg[];
totalMessages: number;
}) => void;
"msg:preview": ({id, chan, preview}: {id: number; chan: number; preview: LinkPreview}) => void;
"msg:special": (data: {chan: number; data?: Record<string, any>}) => void;
msg: (data: {msg: ClientMessage; chan: number; highlight?: number; unread?: number}) => void;
init: ({
active,
networks,
token,
}: {
active: number;
networks: ClientNetwork[];
token: string;
}) => void;
"search:results": (response: SearchResponse) => void;
quit: (args: {network: string}) => void;
error: (error: any) => void;
connecting: () => void;
join: (args: {
shouldOpen: boolean;
index: number;
network: string;
chan: InitClientChan;
}) => void;
}
interface ClientToServerEvents {
"auth:perform":
| (({user, password}: {user: string; password: string}) => void)
| (({
user,
token,
lastMessage,
openChannel,
hasConfig,
}: {
user: string;
token: string;
lastMessage: number;
openChannel: number | null;
hasConfig: boolean;
}) => void);
changelog: () => void;
"change-password": ({
old_password: string,
new_password: string,
verify_password: string,
}) => void;
open: (channelId: number) => void;
names: ({target: number}) => void;
input: ({target, text}: {target: number; text: string}) => void;
"upload:auth": () => void;
"upload:ping": (token: string) => void;
"mute:change": (response: {target: number; setMutedTo: boolean}) => void;
"push:register": (subscriptionJson: PushSubscriptionJSON) => void;
"push:unregister": () => void;
"setting:get": () => void;
"setting:set": ({name: string, value: any}) => void;
"sessions:get": () => void;
sort: ({type, order}: {type: string; order: any; target?: string}) => void;
"mentions:dismiss": (msgId: number) => void;
"mentions:dismiss_all": () => void;
"mentions:get": () => void;
more: ({
target,
lastId,
condensed,
}: {
target: number;
lastId: number;
condensed: boolean;
}) => void;
"msg:preview:toggle": ({
target,
messageIds,
msgId,
shown,
link,
}: {
target: number;
messageIds?: number[];
msgId?: number;
shown?: boolean | null;
link?: string;
}) => void;
"network:get": (uuid: string) => void;
"network:edit": (data: Record<string, any>) => void;
"network:new": (data: Record<string, any>) => void;
"sign-out": (token?: string) => void;
"history:clear": ({target}: {target: number}) => void;
search: ({
networkUuid,
channelName,
searchTerm,
offset,
}: {
networkUuid?: string;
channelName?: string;
searchTerm?: string;
offset: number;
}) => void;
}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface InterServerEvents {}
// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface SocketData {}