Merge branch 'main' into 652-bug---broadcastchannel-duplicate-tab

This commit is contained in:
yassinedorbozgithub 2025-01-31 08:17:50 +01:00
commit 0a4da02591
13 changed files with 208 additions and 47 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
@ -11,6 +11,7 @@ import {
Body, Body,
Controller, Controller,
Get, Get,
Inject,
InternalServerErrorException, InternalServerErrorException,
Param, Param,
Post, Post,
@ -21,6 +22,7 @@ import {
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { CsrfCheck, CsrfGen, CsrfGenAuth } from '@tekuconcept/nestjs-csrf'; import { CsrfCheck, CsrfGen, CsrfGenAuth } from '@tekuconcept/nestjs-csrf';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { Session as ExpressSession } from 'express-session'; import { Session as ExpressSession } from 'express-session';
@ -38,6 +40,9 @@ import { UserService } from '../services/user.service';
import { ValidateAccountService } from '../services/validate-account.service'; import { ValidateAccountService } from '../services/validate-account.service';
export class BaseAuthController { export class BaseAuthController {
@Inject(EventEmitter2)
private readonly eventEmitter: EventEmitter2;
constructor(protected readonly logger: LoggerService) {} constructor(protected readonly logger: LoggerService) {}
/** /**
@ -67,6 +72,7 @@ export class BaseAuthController {
@Session() session: ExpressSession, @Session() session: ExpressSession,
@Res({ passthrough: true }) res: Response, @Res({ passthrough: true }) res: Response,
) { ) {
this.eventEmitter.emit('hook:user:logout', session);
res.clearCookie(config.session.name); res.clearCookie(config.session.name);
session.destroy((error) => { session.destroy((error) => {

View File

@ -1,12 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { EventEmitter2 } from '@nestjs/event-emitter'; import { EventEmitter2, OnEvent } from '@nestjs/event-emitter';
import { import {
ConnectedSocket, ConnectedSocket,
MessageBody, MessageBody,
@ -20,7 +20,7 @@ import {
import cookie from 'cookie'; import cookie from 'cookie';
import * as cookieParser from 'cookie-parser'; import * as cookieParser from 'cookie-parser';
import signature from 'cookie-signature'; import signature from 'cookie-signature';
import { SessionData } from 'express-session'; import { Session as ExpressSession, SessionData } from 'express-session';
import { Server, Socket } from 'socket.io'; import { Server, Socket } from 'socket.io';
import { sync as uid } from 'uid-safe'; import { sync as uid } from 'uid-safe';
@ -258,6 +258,15 @@ export class WebsocketGateway
this.eventEmitter.emit(`hook:websocket:connection`, client); this.eventEmitter.emit(`hook:websocket:connection`, client);
} }
@OnEvent('hook:user:logout')
disconnectSockets({ id }: ExpressSession) {
for (const [, socket] of this.io.sockets.sockets) {
if (socket.data['sessionID'] === id) {
socket.disconnect(true);
}
}
}
async handleDisconnect(client: Socket): Promise<void> { async handleDisconnect(client: Socket): Promise<void> {
this.logger.log(`Client id:${client.id} disconnected`); this.logger.log(`Client id:${client.id} disconnected`);
// Configurable custom afterDisconnect logic here // Configurable custom afterDisconnect logic here

View File

@ -1,11 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { type Session as ExpressSession } from 'express-session';
import type { Document, Query } from 'mongoose'; import type { Document, Query } from 'mongoose';
import { type Socket } from 'socket.io'; import { type Socket } from 'socket.io';
@ -162,7 +163,7 @@ declare module '@nestjs/event-emitter' {
model: TDefinition<Model>; model: TDefinition<Model>;
permission: TDefinition<Permission>; permission: TDefinition<Permission>;
role: TDefinition<Role>; role: TDefinition<Role>;
user: TDefinition<User, { lastvisit: Subscriber }>; user: TDefinition<User, { lastvisit: Subscriber; logout: ExpressSession }>;
} }
/* entities hooks having schemas */ /* entities hooks having schemas */

View File

@ -1,11 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import UploadIcon from "@mui/icons-material/Upload"; import UploadIcon from "@mui/icons-material/Upload";
import { Button, CircularProgress } from "@mui/material"; import { Button, CircularProgress } from "@mui/material";
import { ChangeEvent, forwardRef } from "react"; import { ChangeEvent, forwardRef } from "react";
@ -71,6 +72,7 @@ const FileUploadButton = forwardRef<HTMLLabelElement, FileUploadButtonProps>(
value="" // to trigger an automatic reset to allow the same file to be selected multiple times value="" // to trigger an automatic reset to allow the same file to be selected multiple times
sx={{ display: "none" }} sx={{ display: "none" }}
onChange={handleImportChange} onChange={handleImportChange}
inputProps={{ accept }}
/> />
</> </>
); );

View File

@ -1,18 +1,18 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { css, keyframes } from "@emotion/react"; import { css, keyframes } from "@emotion/react";
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { import {
DefaultLinkFactory, DefaultLinkFactory,
DefaultLinkWidget, DefaultLinkWidget,
} from "@projectstorm/react-diagrams"; } from "@projectstorm/react-diagrams";
import React from "react";
import { AdvancedLinkModel } from "./AdvancedLinkModel"; import { AdvancedLinkModel } from "./AdvancedLinkModel";

View File

@ -0,0 +1,62 @@
/*
* Copyright © 2025 Hexastack. All rights reserved.
*
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/
import { css } from "@emotion/react";
import styled from "@emotion/styled";
import { CanvasModel } from "@projectstorm/react-canvas-core";
import * as React from "react";
import { CSSProperties } from "react";
export interface BackgroundLayerWidgetProps {
model: CanvasModel;
}
namespace S {
const shared = css`
top: 0;
left: 0;
right: 0;
bottom: 0;
position: absolute;
pointer-events: none;
transform-origin: 0 0;
width: 200%;
height: 200%;
overflow: visible;
background-color: #f2f4f7;
background-image: radial-gradient(
circle,
rgba(0, 0, 0, 0.075) 8%,
transparent 10%
);
background-size: 16px 16px;
`;
export const DivLayer = styled.div`
${shared}
`;
}
export class BackgroundLayerWidget extends React.Component<
React.PropsWithChildren<BackgroundLayerWidgetProps>
> {
constructor(props: BackgroundLayerWidgetProps) {
super(props);
this.state = {};
}
getTransformStyle(): CSSProperties {
return {
backgroundPosition: `${this.props.model.getOffsetX()}px ${this.props.model.getOffsetY()}px`,
};
}
render() {
return <S.DivLayer style={this.getTransformStyle()} />;
}
}

View File

@ -1,11 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import styled from "@emotion/styled"; import styled from "@emotion/styled";
import { import {
CanvasEngine, CanvasEngine,
@ -14,6 +15,8 @@ import {
} from "@projectstorm/react-diagrams"; } from "@projectstorm/react-diagrams";
import * as React from "react"; import * as React from "react";
import { BackgroundLayerWidget } from "./BackgroundLayerWidget";
export interface DiagramProps { export interface DiagramProps {
engine: CanvasEngine; engine: CanvasEngine;
className?: string; className?: string;
@ -115,6 +118,7 @@ export class CustomCanvasWidget extends React.Component<DiagramProps> {
this.props.engine.getActionEventBus().fireAction({ event }); this.props.engine.getActionEventBus().fireAction({ event });
}} }}
> >
<BackgroundLayerWidget model={model} />;
{model.getLayers().map((layer) => { {model.getLayers().map((layer) => {
return ( return (
<TransformLayerWidget layer={layer} key={layer.getID()}> <TransformLayerWidget layer={layer} key={layer.getID()}>

View File

@ -1,11 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import BrokenImageOutlinedIcon from "@mui/icons-material/BrokenImageOutlined"; import BrokenImageOutlinedIcon from "@mui/icons-material/BrokenImageOutlined";
import ChatBubbleOutlineOutlinedIcon from "@mui/icons-material/ChatBubbleOutlineOutlined"; import ChatBubbleOutlineOutlinedIcon from "@mui/icons-material/ChatBubbleOutlineOutlined";
import ExtensionOutlinedIcon from "@mui/icons-material/ExtensionOutlined"; import ExtensionOutlinedIcon from "@mui/icons-material/ExtensionOutlined";
@ -76,7 +77,7 @@ class NodeAbstractWidget extends React.Component<
> >
<IconContainer <IconContainer
style={{ style={{
borderWidth: "3px", borderWidth: "1px",
borderColor: this.props.color, borderColor: this.props.color,
borderStyle: "solid", borderStyle: "solid",
}} }}
@ -117,7 +118,7 @@ class NodeAbstractWidget extends React.Component<
> >
<IconContainer <IconContainer
style={{ style={{
borderWidth: "3px", borderWidth: "1px",
borderColor: this.props.color, borderColor: this.props.color,
borderStyle: "solid", borderStyle: "solid",
}} }}
@ -263,12 +264,12 @@ class NodeWidget extends React.Component<
this.props.node.isSelected() ? "selected" : "", this.props.node.isSelected() ? "selected" : "",
)} )}
style={{ style={{
border: `6px solid ${this.config.color}`, border: `1px solid ${this.config.color}`,
}} }}
> >
{this.props.node.starts_conversation ? ( {this.props.node.starts_conversation ? (
<div className="start-point-container"> <div className="start-point-container">
<div className="start-point" /> <PlayArrowRoundedIcon className="start-point" />
</div> </div>
) : null} ) : null}
<div <div

View File

@ -18,20 +18,14 @@
.diagram-container { .diagram-container {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: #e8eff2;
background-image: linear-gradient(to right, #fff9 1px, transparent 1px),
linear-gradient(to bottom, #fff9 1px, transparent 1px);
background-size: 20px 20px;
background-position: -1px -1px;
background-attachment: fixed;
z-index: 2; z-index: 2;
} }
.start-point-container { .start-point-container {
top: -11px; top: -11px;
left: -11px; left: -11px;
width: 22px; width: 20px;
height: 22px; height: 20px;
transform: scale(140%); transform: scale(140%);
border: 1px solid #fff; border: 1px solid #fff;
position: absolute; position: absolute;
@ -40,12 +34,12 @@
} }
.start-point { .start-point {
margin: 5px 7px; color: #FFF;
width: 0; position: absolute;
height: 0; top: 50%;
border-top: 5px solid transparent; left: 50%;
border-bottom: 5px solid transparent; transform: translate(-50%, -50%);
border-left: 9px solid #fff; font-size: 18px;
} }
.node { .node {
@ -58,7 +52,7 @@
z-index: -1; z-index: -1;
} }
.node:has(.selected) { .node:has(.selected) {
outline: 6px solid #1dc7fc; outline: 2px solid #1dc7fc;
z-index: 0; z-index: 0;
cursor: grab; cursor: grab;
transform: scale(1.02); transform: scale(1.02);
@ -76,7 +70,8 @@
min-height: 130px; min-height: 130px;
background-color: #fff; background-color: #fff;
padding: 0px; padding: 0px;
border-radius: 17.5px; border-radius: 12px;
box-shadow: 0 0 8px #c4c4c4;
} }
.custom-node-header { .custom-node-header {
@ -116,7 +111,7 @@
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
gap: 15px; gap: 15px;
padding: 20px 24px 24px; padding: 16px 28px;
position: relative; position: relative;
} }
@ -127,7 +122,7 @@
justify-items: flex-start; justify-items: flex-start;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
border-radius: 10px 10px 0 0px; border-radius: 12px 12px 0 0;
width: auto; width: auto;
margin-top: -1px; margin-top: -1px;
margin-left: -1px; margin-left: -1px;
@ -186,6 +181,9 @@
.circle-porter { .circle-porter {
top: 50%; top: 50%;
margin-top: 5px; margin-top: 5px;
border-radius: 100%;
box-shadow: 0 0 8px #0003;
transition: all .4s ease 0s;
} }
.circle-out-porters { .circle-out-porters {
position: absolute; position: absolute;
@ -196,9 +194,20 @@
.circle-porter-in { .circle-porter-in {
position: absolute; position: absolute;
top: 50%; top: 50%;
transform: translateY(-50%); transform: translateY(-50%) scale(.75);
left: -12px; left: -12px;
} }
.circle-porter-out { .circle-porter-out {
right: -30px; transform: scale(.75);
right: -12px;
}
.circle-porter-out:hover {
cursor: grab;
transform: scale(1.1);
}
.circle-porter-in:hover {
cursor: grab;
transform: translateY(-50%) scale(1.1);
} }

View File

@ -6,24 +6,46 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { IAttachment } from "@/types/attachment.types"; import { IAttachment } from "@/types/attachment.types";
import { FileType, TAttachmentForeignKey } from "@/types/message.types"; import { FileType, TAttachmentForeignKey } from "@/types/message.types";
import { buildURL } from "./URL"; import { buildURL } from "./URL";
export const MIME_TYPES = { export const MIME_TYPES = {
images: ["image/jpeg", "image/png", "image/gif", "image/webp"], images: ["image/jpeg", "image/png", "image/webp", "image/bmp"],
videos: ["video/mp4", "video/webm", "video/ogg"], videos: [
audios: ["audio/mpeg", "audio/ogg", "audio/wav"], "video/mp4",
"video/webm",
"video/ogg",
"video/quicktime", // common in apple devices
"video/x-msvideo", // AVI
"video/x-matroska", // MKV
],
audios: [
"audio/mpeg", // MP3
"audio/mp3", // Explicit MP3 type
"audio/ogg",
"audio/wav",
"audio/aac", // common in apple devices
"audio/x-wav",
],
documents: [ documents: [
"application/pdf", "application/pdf",
"application/msword", "application/msword", // older ms Word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // newer ms word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-excel", "application/vnd.ms-excel", // older excel format
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // newer excel format
"application/vnd.ms-powerpoint", "application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.openxmlformats-officedocument.presentationml.presentation",
"text/plain",
"application/rtf",
"application/epub", // do we want to support epub?
"application/x-7z-compressed", // do we want to support 7z?
"application/zip", // do we want to support zip?
"application/x-rar-compressed", // do we want to support winrar?
"application/json",
"text/csv",
], ],
}; };
@ -68,4 +90,4 @@ export function extractFilenameFromUrl(url: string) {
// If the URL is invalid, return the input as-is // If the URL is invalid, return the input as-is
return url; return url;
} }
} }

View File

@ -3,5 +3,5 @@
right: 25px !important; right: 25px !important;
bottom: 25px !important; bottom: 25px !important;
z-index: 999 !important; z-index: 999 !important;
box-shadow: 0 0 8px #0003 !important; box-shadow: 0 0 8px #c4c4c4 !important;
} }

View File

@ -1,14 +1,15 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import React, { ChangeEvent } from "react"; import React, { ChangeEvent, useMemo } from "react";
import { useChat } from "../../providers/ChatProvider"; import { useChat } from "../../providers/ChatProvider";
import { MIME_TYPES } from "../../utils/attachment";
import FileInputIcon from "../icons/FileInputIcon"; import FileInputIcon from "../icons/FileInputIcon";
import "./FileButton.scss"; import "./FileButton.scss";
@ -23,12 +24,17 @@ const FileButton: React.FC = () => {
setFile && setFile(e.target.files[0]); setFile && setFile(e.target.files[0]);
} }
}; };
const acceptedMimeTypes = useMemo(
() => Object.values(MIME_TYPES).flat().join(","),
[],
);
return ( return (
<div className="sc-user-input--file-wrapper"> <div className="sc-user-input--file-wrapper">
<button className="sc-user-input--file-icon-wrapper" type="button"> <button className="sc-user-input--file-icon-wrapper" type="button">
<FileInputIcon /> <FileInputIcon />
<input <input
accept={acceptedMimeTypes}
type="file" type="file"
id="file-input" id="file-input"
onChange={handleChange} onChange={handleChange}

View File

@ -1,11 +1,12 @@
/* /*
* Copyright © 2024 Hexastack. All rights reserved. * Copyright © 2025 Hexastack. All rights reserved.
* *
* Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms: * Licensed under the GNU Affero General Public License v3.0 (AGPLv3) with the following additional terms:
* 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission. * 1. The name "Hexabot" is a trademark of Hexastack. You may not use this name in derivative works without express written permission.
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import { FileType } from "../types/message.types"; import { FileType } from "../types/message.types";
export function getFileType(mimeType: string): FileType { export function getFileType(mimeType: string): FileType {
@ -19,3 +20,41 @@ export function getFileType(mimeType: string): FileType {
return FileType.file; return FileType.file;
} }
} }
export const MIME_TYPES = {
images: ["image/jpeg", "image/png", "image/webp", "image/bmp"],
videos: [
"video/mp4",
"video/webm",
"video/ogg",
"video/quicktime", // common in apple devices
"video/x-msvideo", // AVI
"video/x-matroska", // MKV
],
audios: [
"audio/mpeg", // MP3
"audio/mp3", // Explicit MP3 type
"audio/ogg",
"audio/wav",
"audio/aac", // common in apple devices
"audio/x-wav",
],
documents: [
"application/pdf",
"application/msword", // older ms Word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document", // newer ms word format
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"application/vnd.ms-excel", // older excel format
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", // newer excel format
"application/vnd.ms-powerpoint",
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
"text/plain",
"application/rtf",
"application/epub+zip",
"application/x-7z-compressed",
"application/zip",
"application/x-rar-compressed",
"application/json",
"text/csv",
],
};