Spaces:
Runtime error
Runtime error
| import { ApiParam, ApiProperty, getSchemaPath } from '@nestjs/swagger'; | |
| import { BooleanString } from '@waha/nestjs/validation/BooleanString'; | |
| import { BinaryFile, RemoteFile } from '@waha/structures/files.dto'; | |
| import { WAMessage } from '@waha/structures/responses.dto'; | |
| import { Transform, Type } from 'class-transformer'; | |
| import { | |
| ArrayMinSize, | |
| IsArray, | |
| IsBoolean, | |
| IsNotEmpty, | |
| IsNumber, | |
| IsOptional, | |
| IsString, | |
| } from 'class-validator'; | |
| export class CreateChannelRequest { | |
| ({ | |
| example: 'Channel Name', | |
| }) | |
| name: string; | |
| ({ | |
| example: 'Channel Description', | |
| }) | |
| description?: string; | |
| ({ | |
| oneOf: [ | |
| { $ref: getSchemaPath(RemoteFile) }, | |
| { $ref: getSchemaPath(BinaryFile) }, | |
| ], | |
| }) | |
| picture?: RemoteFile | BinaryFile; | |
| } | |
| export enum ChannelRole { | |
| OWNER = 'OWNER', | |
| ADMIN = 'ADMIN', | |
| SUBSCRIBER = 'SUBSCRIBER', | |
| GUEST = 'GUEST', | |
| } | |
| export enum ChannelRoleFilter { | |
| OWNER = ChannelRole.OWNER, | |
| ADMIN = ChannelRole.ADMIN, | |
| SUBSCRIBER = ChannelRole.SUBSCRIBER, | |
| } | |
| export class ListChannelsQuery { | |
| role?: ChannelRoleFilter; | |
| } | |
| class ChannelBase { | |
| ({ | |
| description: 'Newsletter id', | |
| example: '123123123123@newsletter', | |
| }) | |
| id: string; | |
| ({ | |
| description: 'Channel name', | |
| example: 'Channel Name', | |
| }) | |
| name: string; | |
| description?: string; | |
| ({ | |
| description: 'Invite link', | |
| example: 'https://www.whatsapp.com/channel/111111111111111111111111', | |
| }) | |
| invite: string; | |
| ({ | |
| description: "Preview for channel's picture", | |
| example: 'https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10', | |
| }) | |
| preview?: string; | |
| ({ | |
| description: "Channel's picture", | |
| example: 'https://mmg.whatsapp.net/m1/v/t24/An&_nc_cat=10', | |
| }) | |
| picture?: string; | |
| verified: boolean; | |
| subscribersCount: number; | |
| } | |
| export class Channel extends ChannelBase { | |
| role: ChannelRole; | |
| } | |
| export class ChannelPublicInfo extends ChannelBase {} | |
| export const NewsletterIdApiParam = ApiParam({ | |
| name: 'id', | |
| required: true, | |
| type: 'string', | |
| schema: { | |
| default: '123123123@newsletter', | |
| }, | |
| description: 'WhatsApp Channel ID', | |
| }); | |
| export const NewsletterIdOrInviteCodeApiParam = ApiParam({ | |
| name: 'id', | |
| required: true, | |
| type: 'string', | |
| schema: { | |
| default: '123123123@newsletter', | |
| }, | |
| description: | |
| 'WhatsApp Channel ID or invite code from invite link https://www.whatsapp.com/channel/11111', | |
| }); | |
| export class ChannelCountry { | |
| code: string; | |
| name: string; | |
| } | |
| export class ChannelCategory { | |
| value: string; | |
| name: string; | |
| } | |
| export class ChannelView { | |
| value: string; | |
| name: string; | |
| } | |
| export class ChannelSearch { | |
| () | |
| () | |
| limit: number = 50; | |
| () | |
| startCursor: string = ''; | |
| } | |
| export class ChannelSearchByView extends ChannelSearch { | |
| () | |
| view: string = 'RECOMMENDED'; | |
| () | |
| ({ each: true }) | |
| (1) | |
| countries: string[] = ['US']; | |
| () | |
| ({ each: true }) | |
| categories: string[] = []; | |
| } | |
| export class ChannelSearchByText extends ChannelSearch { | |
| () | |
| () | |
| text: string = 'Donald Trump'; | |
| () | |
| ({ each: true }) | |
| categories: string[] = []; | |
| } | |
| export class ChannelPagination { | |
| startCursor: string | null; | |
| endCursor: string | null; | |
| hasNextPage: boolean; | |
| hasPreviousPage: boolean; | |
| } | |
| export class ChannelListResult { | |
| page: ChannelPagination; | |
| channels: ChannelPublicInfo[]; | |
| } | |
| export class ChannelMessage { | |
| message: WAMessage; | |
| ({ | |
| example: { '👍': 10, '❤️': 5 }, | |
| type: Object, | |
| additionalProperties: { type: 'number' }, | |
| }) | |
| reactions: { [emoji: string]: number }; | |
| viewCount: number; | |
| } | |
| export class PreviewChannelMessages { | |
| (BooleanString) | |
| () | |
| downloadMedia: boolean = false; | |
| () | |
| (() => Number) | |
| limit: number = 10; | |
| } | |