fix mimetypes

This commit is contained in:
SrGooglo 2025-02-05 02:40:17 +00:00
parent 426951128a
commit 7c055e8024

View File

@ -18,7 +18,15 @@ import "./index.less"
const DEFAULT_POST_POLICY = { const DEFAULT_POST_POLICY = {
maxMessageLength: 512, maxMessageLength: 512,
acceptedMimeTypes: ["image/gif", "image/png", "image/jpeg", "image/bmp", "video/*"], acceptedMimeTypes: [
"image/gif",
"image/png",
"image/jpeg",
"image/bmp",
"video/mp4",
"video/webm",
"video/quicktime"
],
maximunFilesPerRequest: 10 maximunFilesPerRequest: 10
} }
@ -278,7 +286,7 @@ export default class PostCreator extends React.Component {
return false return false
} }
return await this.debounceSubmit() return await this.submit()
} }
} }
@ -318,6 +326,12 @@ export default class PostCreator extends React.Component {
} }
if (!isValidFormat(file.type)) { if (!isValidFormat(file.type)) {
app.cores.notifications.new({
type: "error",
title: `Invalid format (${file.type})`,
message: "Only the following file formats are allowed: " + this.state.postingPolicy.acceptedMimeTypes.join(", ")
})
return null
throw new Error(`Invalid file format`) throw new Error(`Invalid file format`)
} }
@ -606,7 +620,7 @@ export default class PostCreator extends React.Component {
<antd.Button <antd.Button
type="primary" type="primary"
disabled={loading || !this.canSubmit()} disabled={loading || !this.canSubmit()}
onClick={this.debounceSubmit} onClick={this.submit}
icon={loading ? <Icons.LoadingOutlined spin /> : (editMode ? <Icons.MdEdit /> : <Icons.FiSend />)} icon={loading ? <Icons.LoadingOutlined spin /> : (editMode ? <Icons.MdEdit /> : <Icons.FiSend />)}
/> />
</div> </div>