mirror of
https://github.com/hexastack/hexabot
synced 2025-06-26 18:27:28 +00:00
Merge branch 'main' into 540-issue-nlp-module-strictnullchecks-issues
This commit is contained in:
commit
4f88370c69
@ -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.
|
||||||
@ -7,7 +7,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Attachment } from '@/attachment/schemas/attachment.schema';
|
import { Attachment } from '@/attachment/schemas/attachment.schema';
|
||||||
import { WithUrl } from '@/chat/schemas/types/attachment';
|
|
||||||
import { ButtonType } from '@/chat/schemas/types/button';
|
import { ButtonType } from '@/chat/schemas/types/button';
|
||||||
import {
|
import {
|
||||||
FileType,
|
FileType,
|
||||||
@ -93,7 +92,7 @@ const attachment: Attachment = {
|
|||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
};
|
};
|
||||||
|
|
||||||
const attachmentWithUrl: WithUrl<Attachment> = {
|
const attachmentWithUrl: Attachment = {
|
||||||
...attachment,
|
...attachment,
|
||||||
url: 'http://localhost:4000/attachment/download/1/attachment.jpg',
|
url: 'http://localhost:4000/attachment/download/1/attachment.jpg',
|
||||||
};
|
};
|
||||||
@ -154,9 +153,7 @@ export const contentMessage: StdOutgoingListMessage = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const attachmentMessage: StdOutgoingAttachmentMessage<
|
export const attachmentMessage: StdOutgoingAttachmentMessage<Attachment> = {
|
||||||
WithUrl<Attachment>
|
|
||||||
> = {
|
|
||||||
attachment: {
|
attachment: {
|
||||||
type: FileType.image,
|
type: FileType.image,
|
||||||
payload: attachmentWithUrl,
|
payload: attachmentWithUrl,
|
||||||
|
|||||||
@ -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.
|
||||||
@ -21,10 +21,8 @@ export type AttachmentForeignKey = {
|
|||||||
attachment_id: string;
|
attachment_id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WithUrl<A> = A & { url?: string };
|
|
||||||
|
|
||||||
export interface AttachmentPayload<
|
export interface AttachmentPayload<
|
||||||
A extends WithUrl<Attachment> | AttachmentForeignKey,
|
A extends Attachment | AttachmentForeignKey,
|
||||||
> {
|
> {
|
||||||
type: FileType;
|
type: FileType;
|
||||||
payload: A;
|
payload: A;
|
||||||
|
|||||||
@ -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.
|
||||||
@ -15,7 +15,6 @@ import {
|
|||||||
AttachmentForeignKey,
|
AttachmentForeignKey,
|
||||||
AttachmentPayload,
|
AttachmentPayload,
|
||||||
IncomingAttachmentPayload,
|
IncomingAttachmentPayload,
|
||||||
WithUrl,
|
|
||||||
} from './attachment';
|
} from './attachment';
|
||||||
import { Button } from './button';
|
import { Button } from './button';
|
||||||
import { ContentOptions } from './options';
|
import { ContentOptions } from './options';
|
||||||
@ -102,7 +101,7 @@ export type StdOutgoingListMessage = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type StdOutgoingAttachmentMessage<
|
export type StdOutgoingAttachmentMessage<
|
||||||
A extends WithUrl<Attachment> | AttachmentForeignKey,
|
A extends Attachment | AttachmentForeignKey,
|
||||||
> = {
|
> = {
|
||||||
// Stored in DB as `AttachmentPayload`, `Attachment` when populated for channels relaying
|
// Stored in DB as `AttachmentPayload`, `Attachment` when populated for channels relaying
|
||||||
attachment: AttachmentPayload<A>;
|
attachment: AttachmentPayload<A>;
|
||||||
@ -128,7 +127,7 @@ export type StdOutgoingMessage =
|
|||||||
| StdOutgoingQuickRepliesMessage
|
| StdOutgoingQuickRepliesMessage
|
||||||
| StdOutgoingButtonsMessage
|
| StdOutgoingButtonsMessage
|
||||||
| StdOutgoingListMessage
|
| StdOutgoingListMessage
|
||||||
| StdOutgoingAttachmentMessage<WithUrl<Attachment>>;
|
| StdOutgoingAttachmentMessage<Attachment>;
|
||||||
|
|
||||||
type StdIncomingTextMessage = { text: string };
|
type StdIncomingTextMessage = { text: string };
|
||||||
|
|
||||||
@ -192,7 +191,7 @@ export interface StdOutgoingListEnvelope {
|
|||||||
|
|
||||||
export interface StdOutgoingAttachmentEnvelope {
|
export interface StdOutgoingAttachmentEnvelope {
|
||||||
format: OutgoingMessageFormat.attachment;
|
format: OutgoingMessageFormat.attachment;
|
||||||
message: StdOutgoingAttachmentMessage<WithUrl<Attachment>>;
|
message: StdOutgoingAttachmentMessage<Attachment>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type StdOutgoingEnvelope =
|
export type StdOutgoingEnvelope =
|
||||||
|
|||||||
@ -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.
|
||||||
@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
import { Attachment } from '@/attachment/schemas/attachment.schema';
|
|
||||||
import { AttachmentService } from '@/attachment/services/attachment.service';
|
import { AttachmentService } from '@/attachment/services/attachment.service';
|
||||||
import EventWrapper from '@/channel/lib/EventWrapper';
|
import EventWrapper from '@/channel/lib/EventWrapper';
|
||||||
import { ContentService } from '@/cms/services/content.service';
|
import { ContentService } from '@/cms/services/content.service';
|
||||||
@ -25,7 +24,6 @@ import { getRandom } from '@/utils/helpers/safeRandom';
|
|||||||
|
|
||||||
import { BlockRepository } from '../repositories/block.repository';
|
import { BlockRepository } from '../repositories/block.repository';
|
||||||
import { Block, BlockFull, BlockPopulate } from '../schemas/block.schema';
|
import { Block, BlockFull, BlockPopulate } from '../schemas/block.schema';
|
||||||
import { WithUrl } from '../schemas/types/attachment';
|
|
||||||
import { Context } from '../schemas/types/context';
|
import { Context } from '../schemas/types/context';
|
||||||
import {
|
import {
|
||||||
BlockMessage,
|
BlockMessage,
|
||||||
@ -545,7 +543,7 @@ export class BlockService extends BaseService<Block, BlockPopulate, BlockFull> {
|
|||||||
message: {
|
message: {
|
||||||
attachment: {
|
attachment: {
|
||||||
type: blockMessage.attachment.type,
|
type: blockMessage.attachment.type,
|
||||||
payload: attachment as WithUrl<Attachment>,
|
payload: attachment,
|
||||||
},
|
},
|
||||||
quickReplies: blockMessage.quickReplies
|
quickReplies: blockMessage.quickReplies
|
||||||
? [...blockMessage.quickReplies]
|
? [...blockMessage.quickReplies]
|
||||||
|
|||||||
@ -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.
|
||||||
@ -10,7 +10,6 @@ import { Injectable } from '@nestjs/common';
|
|||||||
|
|
||||||
import { Attachment } from '@/attachment/schemas/attachment.schema';
|
import { Attachment } from '@/attachment/schemas/attachment.schema';
|
||||||
import { AttachmentService } from '@/attachment/services/attachment.service';
|
import { AttachmentService } from '@/attachment/services/attachment.service';
|
||||||
import { WithUrl } from '@/chat/schemas/types/attachment';
|
|
||||||
import {
|
import {
|
||||||
ContentElement,
|
ContentElement,
|
||||||
StdOutgoingListMessage,
|
StdOutgoingListMessage,
|
||||||
@ -108,7 +107,7 @@ export class ContentService extends BaseService<
|
|||||||
acc[curr.id] = curr;
|
acc[curr.id] = curr;
|
||||||
return acc;
|
return acc;
|
||||||
},
|
},
|
||||||
{} as { [key: string]: WithUrl<Attachment> },
|
{} as { [key: string]: Attachment },
|
||||||
);
|
);
|
||||||
const populatedContents = elements.map((content) => {
|
const populatedContents = elements.map((content) => {
|
||||||
const attachmentField = content[attachmentFieldName];
|
const attachmentField = content[attachmentFieldName];
|
||||||
|
|||||||
@ -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.
|
||||||
@ -22,7 +22,6 @@ import { MessageCreateDto } from '@/chat/dto/message.dto';
|
|||||||
import { SubscriberCreateDto } from '@/chat/dto/subscriber.dto';
|
import { SubscriberCreateDto } from '@/chat/dto/subscriber.dto';
|
||||||
import { VIEW_MORE_PAYLOAD } from '@/chat/helpers/constants';
|
import { VIEW_MORE_PAYLOAD } from '@/chat/helpers/constants';
|
||||||
import { Subscriber, SubscriberFull } from '@/chat/schemas/subscriber.schema';
|
import { Subscriber, SubscriberFull } from '@/chat/schemas/subscriber.schema';
|
||||||
import { WithUrl } from '@/chat/schemas/types/attachment';
|
|
||||||
import { Button, ButtonType } from '@/chat/schemas/types/button';
|
import { Button, ButtonType } from '@/chat/schemas/types/button';
|
||||||
import {
|
import {
|
||||||
AnyMessage,
|
AnyMessage,
|
||||||
@ -959,7 +958,7 @@ export default abstract class BaseWebChannelHandler<
|
|||||||
* @returns A ready to be sent attachment message
|
* @returns A ready to be sent attachment message
|
||||||
*/
|
*/
|
||||||
_attachmentFormat(
|
_attachmentFormat(
|
||||||
message: StdOutgoingAttachmentMessage<WithUrl<Attachment>>,
|
message: StdOutgoingAttachmentMessage<Attachment>,
|
||||||
_options?: BlockOptions,
|
_options?: BlockOptions,
|
||||||
): Web.OutgoingMessageBase {
|
): Web.OutgoingMessageBase {
|
||||||
const payload: Web.OutgoingMessageBase = {
|
const payload: Web.OutgoingMessageBase = {
|
||||||
|
|||||||
@ -137,6 +137,7 @@ describe('AuthController', () => {
|
|||||||
first_name: 'test',
|
first_name: 'test',
|
||||||
last_name: 'test',
|
last_name: 'test',
|
||||||
roles: [role!.id],
|
roles: [role!.id],
|
||||||
|
avatar: null,
|
||||||
};
|
};
|
||||||
await invitationService.create(baseUser);
|
await invitationService.create(baseUser);
|
||||||
});
|
});
|
||||||
@ -157,6 +158,7 @@ describe('AuthController', () => {
|
|||||||
email: 'test@test.test',
|
email: 'test@test.test',
|
||||||
password: 'test',
|
password: 'test',
|
||||||
roles: ['invalid role value'],
|
roles: ['invalid role value'],
|
||||||
|
avatar: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
await expect(authController.signup(userCreateDto)).rejects.toThrow(
|
await expect(authController.signup(userCreateDto)).rejects.toThrow(
|
||||||
@ -174,6 +176,7 @@ describe('AuthController', () => {
|
|||||||
email: 'test@test.test',
|
email: 'test@test.test',
|
||||||
password: 'test',
|
password: 'test',
|
||||||
roles: ['659564cb4aa383c0d0dbc688'],
|
roles: ['659564cb4aa383c0d0dbc688'],
|
||||||
|
avatar: null,
|
||||||
};
|
};
|
||||||
const result = await authController.signup(userCreateDto);
|
const result = await authController.signup(userCreateDto);
|
||||||
expect(userService.create).toHaveBeenCalledWith(userCreateDto);
|
expect(userService.create).toHaveBeenCalledWith(userCreateDto);
|
||||||
|
|||||||
@ -210,6 +210,7 @@ describe('UserController', () => {
|
|||||||
email: 'test@test.test',
|
email: 'test@test.test',
|
||||||
password: 'test',
|
password: 'test',
|
||||||
roles: [role!.id],
|
roles: [role!.id],
|
||||||
|
avatar: null,
|
||||||
};
|
};
|
||||||
const result = await userController.create(userDto);
|
const result = await userController.create(userDto);
|
||||||
expect(userService.create).toHaveBeenCalledWith(userDto);
|
expect(userService.create).toHaveBeenCalledWith(userDto);
|
||||||
|
|||||||
@ -250,7 +250,7 @@ export class ReadWriteUserController extends ReadOnlyUserController {
|
|||||||
.map((role) => role.id),
|
.map((role) => role.id),
|
||||||
avatar: user.avatar
|
avatar: user.avatar
|
||||||
? (await this.attachmentService.findOne(user.avatar))?.id
|
? (await this.attachmentService.findOne(user.avatar))?.id
|
||||||
: undefined,
|
: null,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return await this.userService.create(user);
|
return await this.userService.create(user);
|
||||||
|
|||||||
@ -60,7 +60,7 @@ export class UserCreateDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsObjectId({ message: 'Avatar must be a valid ObjectId' })
|
@IsObjectId({ message: 'Avatar must be a valid ObjectId' })
|
||||||
avatar?: string;
|
avatar: string | null = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UserEditProfileDto extends OmitType(PartialType(UserCreateDto), [
|
export class UserEditProfileDto extends OmitType(PartialType(UserCreateDto), [
|
||||||
|
|||||||
@ -35,6 +35,6 @@ export class AuthSerializer extends PassportSerializer {
|
|||||||
done: (err: Error | null, user: SessionUser | null) => void,
|
done: (err: Error | null, user: SessionUser | null) => void,
|
||||||
) {
|
) {
|
||||||
const user = payload.id ? await this.userService.findOne(payload.id) : null;
|
const user = payload.id ? await this.userService.findOne(payload.id) : null;
|
||||||
user ? done(null, user) : done(null, null);
|
done(null, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -91,7 +91,7 @@ export class UserStub extends BaseSchema {
|
|||||||
ref: 'Attachment',
|
ref: 'Attachment',
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
avatar?: unknown;
|
avatar: unknown;
|
||||||
|
|
||||||
@Prop({
|
@Prop({
|
||||||
type: String,
|
type: String,
|
||||||
@ -112,7 +112,7 @@ export class User extends UserStub {
|
|||||||
roles: string[];
|
roles: string[];
|
||||||
|
|
||||||
@Transform(({ obj }) => obj.avatar?.toString() || null)
|
@Transform(({ obj }) => obj.avatar?.toString() || null)
|
||||||
avatar?: string | null;
|
avatar: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Schema({ timestamps: true })
|
@Schema({ timestamps: true })
|
||||||
|
|||||||
@ -17,6 +17,7 @@ export const userModels = (roles: string[]): UserCreateDto[] => {
|
|||||||
email: 'admin@admin.admin',
|
email: 'admin@admin.admin',
|
||||||
password: 'adminadmin',
|
password: 'adminadmin',
|
||||||
roles,
|
roles,
|
||||||
|
avatar: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|||||||
4
api/src/utils/test/fixtures/user.ts
vendored
4
api/src/utils/test/fixtures/user.ts
vendored
@ -9,7 +9,7 @@
|
|||||||
import mongoose from 'mongoose';
|
import mongoose from 'mongoose';
|
||||||
|
|
||||||
import { UserCreateDto } from '@/user/dto/user.dto';
|
import { UserCreateDto } from '@/user/dto/user.dto';
|
||||||
import { UserModel, User } from '@/user/schemas/user.schema';
|
import { User, UserModel } from '@/user/schemas/user.schema';
|
||||||
import { hash } from '@/user/utilities/bcryptjs';
|
import { hash } from '@/user/utilities/bcryptjs';
|
||||||
|
|
||||||
import { getFixturesWithDefaultValues } from '../defaultValues';
|
import { getFixturesWithDefaultValues } from '../defaultValues';
|
||||||
@ -25,6 +25,7 @@ export const users: UserCreateDto[] = [
|
|||||||
email: 'admin@admin.admin',
|
email: 'admin@admin.admin',
|
||||||
password: 'adminadmin',
|
password: 'adminadmin',
|
||||||
roles: ['0', '1'],
|
roles: ['0', '1'],
|
||||||
|
avatar: null,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -34,7 +35,6 @@ export const userDefaultValues: TFixturesDefaultValues<User> = {
|
|||||||
timezone: 'Europe/Berlin',
|
timezone: 'Europe/Berlin',
|
||||||
sendEmail: false,
|
sendEmail: false,
|
||||||
resetCount: 0,
|
resetCount: 0,
|
||||||
avatar: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUserFixtures = (users: UserCreateDto[]) =>
|
export const getUserFixtures = (users: UserCreateDto[]) =>
|
||||||
|
|||||||
@ -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 DownloadIcon from "@mui/icons-material/Download";
|
import DownloadIcon from "@mui/icons-material/Download";
|
||||||
import { Button, Dialog, DialogContent } from "@mui/material";
|
import { Button, Dialog, DialogContent } from "@mui/material";
|
||||||
import { FC } from "react";
|
import { FC } from "react";
|
||||||
@ -18,7 +19,6 @@ import {
|
|||||||
FileType,
|
FileType,
|
||||||
StdIncomingAttachmentMessage,
|
StdIncomingAttachmentMessage,
|
||||||
StdOutgoingAttachmentMessage,
|
StdOutgoingAttachmentMessage,
|
||||||
WithUrl,
|
|
||||||
} from "@/types/message.types";
|
} from "@/types/message.types";
|
||||||
|
|
||||||
interface AttachmentInterface {
|
interface AttachmentInterface {
|
||||||
@ -95,7 +95,7 @@ const componentMap: { [key in FileType]: FC<AttachmentInterface> } = {
|
|||||||
export const AttachmentViewer = (props: {
|
export const AttachmentViewer = (props: {
|
||||||
message:
|
message:
|
||||||
| StdIncomingAttachmentMessage
|
| StdIncomingAttachmentMessage
|
||||||
| StdOutgoingAttachmentMessage<WithUrl<AttachmentAttrs>>;
|
| StdOutgoingAttachmentMessage<AttachmentAttrs>;
|
||||||
}) => {
|
}) => {
|
||||||
const message = props.message;
|
const message = props.message;
|
||||||
|
|
||||||
|
|||||||
@ -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 { EntityType } from "@/services/types";
|
import { EntityType } from "@/services/types";
|
||||||
|
|
||||||
import { IAttachment } from "./attachment.types";
|
import { IAttachment } from "./attachment.types";
|
||||||
@ -47,6 +48,7 @@ export interface AttachmentAttrs {
|
|||||||
size: number;
|
size: number;
|
||||||
location: string;
|
location: string;
|
||||||
channel?: Record<string, any>;
|
channel?: Record<string, any>;
|
||||||
|
url?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AttachmentForeignKey = {
|
export type AttachmentForeignKey = {
|
||||||
@ -54,10 +56,8 @@ export type AttachmentForeignKey = {
|
|||||||
attachment_id: string | undefined;
|
attachment_id: string | undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type WithUrl<A> = A & { url?: string };
|
|
||||||
|
|
||||||
export interface AttachmentPayload<
|
export interface AttachmentPayload<
|
||||||
A extends WithUrl<AttachmentAttrs> | AttachmentForeignKey,
|
A extends AttachmentAttrs | AttachmentForeignKey,
|
||||||
> {
|
> {
|
||||||
type: FileType;
|
type: FileType;
|
||||||
payload?: A;
|
payload?: A;
|
||||||
@ -172,7 +172,7 @@ export type StdOutgoingListMessage = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
export type StdOutgoingAttachmentMessage<
|
export type StdOutgoingAttachmentMessage<
|
||||||
A extends WithUrl<AttachmentAttrs> | AttachmentForeignKey,
|
A extends AttachmentAttrs | AttachmentForeignKey,
|
||||||
> = {
|
> = {
|
||||||
// Stored in DB as `AttachmentPayload`, `Attachment` when populated for channels relaying
|
// Stored in DB as `AttachmentPayload`, `Attachment` when populated for channels relaying
|
||||||
attachment: AttachmentPayload<A>;
|
attachment: AttachmentPayload<A>;
|
||||||
@ -217,7 +217,7 @@ export type StdOutgoingMessage =
|
|||||||
| StdOutgoingQuickRepliesMessage
|
| StdOutgoingQuickRepliesMessage
|
||||||
| StdOutgoingButtonsMessage
|
| StdOutgoingButtonsMessage
|
||||||
| StdOutgoingListMessage
|
| StdOutgoingListMessage
|
||||||
| StdOutgoingAttachmentMessage<WithUrl<AttachmentAttrs>>;
|
| StdOutgoingAttachmentMessage<AttachmentAttrs>;
|
||||||
|
|
||||||
export interface IMessageAttributes {
|
export interface IMessageAttributes {
|
||||||
mid?: string;
|
mid?: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user