-
Notifications
You must be signed in to change notification settings - Fork 13.3k
fix: add frontend and backend restrictions for custom sounds size/format #39159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
ccd0a6a
b0189b5
e642031
f7a2807
2f1a9d0
e23903f
8873e03
a13d61a
79a1ad6
169a1c6
201e3dc
f39262b
8530352
97be821
0940180
2cad317
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Fixes missing file size and MP3 validation for custom sounds upload |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,13 @@ | ||
| import { Field, FieldLabel, FieldRow, TextInput, Box, Margins, Button, ButtonGroup, IconButton } from '@rocket.chat/fuselage'; | ||
| import { ContextualbarScrollableContent, ContextualbarFooter } from '@rocket.chat/ui-client'; | ||
| import { useToastMessageDispatch, useMethod } from '@rocket.chat/ui-contexts'; | ||
| import fileSize from 'filesize'; | ||
| import type { ReactElement, FormEvent } from 'react'; | ||
| import { useState, useCallback } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { validate, createSoundData } from './lib'; | ||
| import { MAX_CUSTOM_SOUND_SIZE_BYTES } from '../../../../lib/constants'; | ||
| import { useSingleFileInput } from '../../../hooks/useSingleFileInput'; | ||
|
|
||
| type AddCustomSoundProps = { | ||
|
|
@@ -28,7 +30,12 @@ const AddCustomSound = ({ goToNew, close, onChange, ...props }: AddCustomSoundPr | |
| setSound(soundFile); | ||
| }, []); | ||
|
|
||
| const [clickUpload] = useSingleFileInput(handleChangeFile, 'audio/mp3'); | ||
| const [clickUpload] = useSingleFileInput(handleChangeFile, '.mp3,audio/mpeg', 'audio', MAX_CUSTOM_SOUND_SIZE_BYTES, () => { | ||
| dispatchToastMessage({ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this the only error that can be triggered by the hook?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the moment, the only explicit error condition handled by the hook is the |
||
| type: 'error', | ||
| message: t('File_exceeds_allowed_size_of_bytes', { size: fileSize(MAX_CUSTOM_SOUND_SIZE_BYTES, { base: 2, standard: 'jedec' }) }), | ||
| }); | ||
| }); | ||
|
|
||
| const saveAction = useCallback( | ||
| // FIXME | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| export const NOTIFICATION_ATTACHMENT_COLOR = '#FD745E'; | ||
| export const MAX_CUSTOM_SOUND_SIZE_BYTES = 5242880; |
Uh oh!
There was an error while loading. Please reload this page.