feat: add support for files and math for messages (#5)

This commit is contained in:
Divlo
2022-01-07 21:21:38 +01:00
committed by GitHub
parent fdc2a2d1de
commit 5c03a9b944
57 changed files with 3403 additions and 2992 deletions

View File

@ -1,5 +1,4 @@
import { Handler } from '../../handler'
import { channelExample } from '../channel'
export const getChannelWithChannelIdHandler: Handler = {

View File

@ -1,7 +1,14 @@
import { Handler } from '../../../handler'
import {
messageExampleComplete,
messageExampleComplete2
messageExampleComplete2,
messageExampleComplete3,
messageExampleComplete4,
messageExampleComplete5,
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
} from '../../../messages/message'
import { channelExample } from '../../channel'
@ -10,6 +17,16 @@ export const getMessagesWithChannelIdHandler: Handler = {
url: `/channels/${channelExample.id}/messages`,
response: {
statusCode: 200,
body: [messageExampleComplete, messageExampleComplete2]
body: [
messageExampleComplete,
messageExampleComplete2,
messageExampleComplete3,
messageExampleComplete4,
messageExampleComplete5,
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
]
}
}

View File

@ -1,5 +1,4 @@
import { Handler } from '../../handler'
import { guildExample } from '../guild'
import { memberExampleComplete } from '../../members/member'

View File

@ -1,5 +1,4 @@
import { Handler } from '../handler'
import { guildExample, guildExample2 } from './guild'
export const getGuildsHandler: Handler = {

View File

@ -1,5 +1,4 @@
import { Handler } from '../handler'
import { guildExample } from './guild'
import { channelExample } from '../channels/channel'
import { memberExampleComplete } from '../members/member'

View File

@ -1,5 +1,4 @@
import { Handler } from '../../handler'
import { guildExample, guildExample2 } from '../guild'
export const getGuildsPublicEmptyHandler: Handler = {

View File

@ -5,6 +5,7 @@ export interface Handler {
method: 'GET' | 'POST' | 'PUT' | 'DELETE'
url: `/${string}`
response: {
isFile?: boolean
body: any
statusCode: number
}

View File

@ -18,8 +18,63 @@ export const messageExampleComplete = {
}
export const messageExampleComplete2 = {
...messageExample,
...messageExampleComplete,
id: 2,
value: 'Second message',
member: memberExampleComplete
value: 'Message with bad html: <script>alert("xss")</script>'
}
export const messageExampleComplete3 = {
...messageExampleComplete,
id: 3,
value:
'Message with **bold text** and *italic text*.\nNewlines and some emoji: :smile:'
}
export const messageExampleComplete4 = {
...messageExampleComplete,
id: 4,
value: `The Quadratic Formula:
**Theorem 1**: $(a, b, c) \\in \\mathbb{R}^3$, the solutions of $ax^2 + bx + c = 0$ are:
$x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$
`
}
export const messageExampleComplete5 = {
...messageExampleComplete,
id: 5,
value: ':wave:'
}
export const messageExampleComplete6 = {
...messageExampleComplete,
id: 6,
value: '/uploads/messages/image.png',
type: 'file',
mimetype: 'image/png'
}
export const messageExampleComplete7 = {
...messageExampleComplete,
id: 7,
value: '/uploads/messages/audio.mp3',
type: 'file',
mimetype: 'audio/mp3'
}
export const messageExampleComplete8 = {
...messageExampleComplete,
id: 8,
value: '/uploads/messages/video.mp4',
type: 'file',
mimetype: 'video/mp4'
}
export const messageExampleComplete9 = {
...messageExampleComplete,
id: 9,
value: '/uploads/messages/download.zip',
type: 'file',
mimetype: 'application/zip'
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 KiB

View File

@ -0,0 +1,47 @@
import { Handler } from '../../handler'
import {
messageExampleComplete6,
messageExampleComplete7,
messageExampleComplete8,
messageExampleComplete9
} from '../../messages/message'
export const getMessagesUploadsImageHandler: Handler = {
method: 'GET',
url: messageExampleComplete6.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['image.png']
}
}
export const getMessagesUploadsAudioHandler: Handler = {
method: 'GET',
url: messageExampleComplete7.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['audio.mp3']
}
}
export const getMessagesUploadsVideoHandler: Handler = {
method: 'GET',
url: messageExampleComplete8.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['video.mp4']
}
}
export const getMessagesUploadsDownloadHandler: Handler = {
method: 'GET',
url: messageExampleComplete9.value as `/${string}`,
response: {
statusCode: 200,
isFile: true,
body: ['download.zip']
}
}

Binary file not shown.

View File

@ -1,5 +1,4 @@
import { Handler } from '../../handler'
import { userExample, userSettingsExample } from '../user'
export const getUsersCurrentHandler: Handler = {

View File

@ -1,5 +1,4 @@
import { Handler } from '../../handler'
import { userExample, userSettingsExample } from '../user'
export const postUsersSignupHandler: Handler = {