mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-11 23:53:03 -04:00
feat(plugin): FixFileExtensions
This commit is contained in:
parent
2c773ec7d1
commit
0d4cfd5e3b
3 changed files with 67 additions and 20 deletions
|
@ -17,9 +17,9 @@
|
|||
*/
|
||||
|
||||
import { Upload } from "@api/MessageEvents";
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { definePluginSettings, Settings } from "@api/Settings";
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Devs, EquicordDevs } from "@utils/constants";
|
||||
import { Devs, reverseExtensionMap } from "@utils/constants";
|
||||
import definePlugin, { OptionType } from "@utils/types";
|
||||
import { findByCodeLazy, findByPropsLazy } from "@webpack";
|
||||
|
||||
|
@ -42,11 +42,6 @@ const settings = definePluginSettings({
|
|||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
},
|
||||
fixOpusExtensions: {
|
||||
description: "Whether to fix file extensions by default",
|
||||
type: OptionType.BOOLEAN,
|
||||
default: true,
|
||||
},
|
||||
method: {
|
||||
description: "Anonymising method",
|
||||
type: OptionType.SELECT,
|
||||
|
@ -72,7 +67,7 @@ const settings = definePluginSettings({
|
|||
|
||||
export default definePlugin({
|
||||
name: "AnonymiseFileNames",
|
||||
authors: [Devs.fawn, EquicordDevs.thororen],
|
||||
authors: [Devs.fawn],
|
||||
description: "Anonymise uploaded file names",
|
||||
patches: [
|
||||
{
|
||||
|
@ -125,17 +120,8 @@ export default definePlugin({
|
|||
const tarMatch = tarExtMatcher.exec(file);
|
||||
const extIdx = tarMatch?.index ?? file.lastIndexOf(".");
|
||||
let ext = extIdx !== -1 ? file.slice(extIdx) : "";
|
||||
const matchList = [
|
||||
".ogv",
|
||||
".oga",
|
||||
".ogx",
|
||||
".ogm",
|
||||
".spx",
|
||||
".opus"
|
||||
];
|
||||
|
||||
if (settings.store.fixOpusExtensions && ext !== "ogg" && matchList.includes(ext)) {
|
||||
ext = ".ogg";
|
||||
if (Settings.plugins.FixFileExtensions.enabled) {
|
||||
ext = reverseExtensionMap[ext];
|
||||
}
|
||||
|
||||
switch (settings.store.method) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue