From 5e9e6029b731d00a59836821f08b03a3cfd43ccf Mon Sep 17 00:00:00 2001 From: Mel <97147377+MelissaAutumn@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:03:45 -0800 Subject: [PATCH] Remove the frontend profanity filter (Fixes #840) (#841) * Remove the frontend profanity filter (Fixes #839) --- frontend/package-lock.json | 10 ---------- frontend/package.json | 1 - frontend/src/App.vue | 11 +---------- frontend/src/components/FTUE/SetupProfile.vue | 9 +-------- frontend/src/components/FTUE/SetupSchedule.vue | 9 +-------- frontend/src/components/ScheduleCreation.vue | 7 +------ frontend/src/components/SettingsAccount.vue | 15 +-------------- frontend/src/keys.ts | 4 ---- frontend/src/locales/de.json | 1 - frontend/src/locales/en.json | 1 - 10 files changed, 5 insertions(+), 63 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2d8a50e3c..29b82dbe3 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -9,7 +9,6 @@ "version": "0.3.0", "license": "MPL-2.0", "dependencies": { - "@2toad/profanity": "^3.0.0", "@rushstack/eslint-patch": "^1.3.3", "@sentry/vite-plugin": "^2.10.2", "@sentry/vue": "^8.33.1", @@ -58,15 +57,6 @@ "node": ">=20.15.0" } }, - "node_modules/@2toad/profanity": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@2toad/profanity/-/profanity-3.0.1.tgz", - "integrity": "sha512-WqAljnXnxsdUmwJT2VDTHZ6IAMgktnobLtBSdGFQYFLB1kh7q+QqzpxY4rRAWU4lSYvGUykJ+xv5wJ3IZYBuzQ==", - "license": "MIT", - "engines": { - "node": ">=12" - } - }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@alloc/quick-lru/-/quick-lru-5.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index 263f98172..7ab06b151 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -12,7 +12,6 @@ "test": "vitest" }, "dependencies": { - "@2toad/profanity": "^3.0.0", "@rushstack/eslint-patch": "^1.3.3", "@sentry/vite-plugin": "^2.10.2", "@sentry/vue": "^8.33.1", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 9098aa2e1..e1e3e5a69 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -6,13 +6,12 @@ import { import { useRoute, useRouter } from 'vue-router'; import { storeToRefs } from 'pinia'; import { - apiUrlKey, callKey, refreshKey, isPasswordAuthKey, isFxaAuthKey, fxaEditProfileUrlKey, hasProfanityKey, + apiUrlKey, callKey, refreshKey, isPasswordAuthKey, isFxaAuthKey, fxaEditProfileUrlKey, } from '@/keys'; import { defaultLocale } from '@/utils'; import { StringResponse } from '@/models'; import { usePosthog, posthog } from '@/composables/posthog'; import UAParser from 'ua-parser-js'; -import { Profanity } from '@2toad/profanity'; import NavBar from '@/components/NavBar.vue'; import TitleBar from '@/components/TitleBar.vue'; @@ -50,14 +49,6 @@ const { lock: lockNotification, } = siteNotificationStore; -// Handle input filters -// The library will error if we supply it with an unsupported language -const supportedLanguages = ['en', 'de']; -const languageList = supportedLanguages.indexOf(lang) !== -1 && lang !== 'en' ? [lang, 'en'] : ['en']; -const profanity = new Profanity({ languages: languageList }); -const hasProfanity = (input: string) => profanity.exists(input); -provide(hasProfanityKey, hasProfanity); - // handle auth and fetch const call = createFetch({ baseUrl: apiUrl, diff --git a/frontend/src/components/FTUE/SetupProfile.vue b/frontend/src/components/FTUE/SetupProfile.vue index 1782c0ccf..59b457344 100644 --- a/frontend/src/components/FTUE/SetupProfile.vue +++ b/frontend/src/components/FTUE/SetupProfile.vue @@ -4,7 +4,7 @@ import { storeToRefs } from 'pinia'; import { useFTUEStore } from '@/stores/ftue-store'; import { useUserStore } from '@/stores/user-store'; import { useI18n } from 'vue-i18n'; -import { dayjsKey, callKey, hasProfanityKey } from '@/keys'; +import { dayjsKey, callKey } from '@/keys'; import TextInput from '@/tbpro/elements/TextInput.vue'; import SelectInput from '@/tbpro/elements/SelectInput.vue'; import PrimaryButton from '@/tbpro/elements/PrimaryButton.vue'; @@ -12,7 +12,6 @@ import PrimaryButton from '@/tbpro/elements/PrimaryButton.vue'; const { t } = useI18n(); const dj = inject(dayjsKey); const call = inject(callKey); -const hasProfanity = inject(hasProfanityKey); const ftueStore = useFTUEStore(); const { hasNextStep } = storeToRefs(ftueStore); @@ -47,12 +46,6 @@ const onSubmit = async () => { return; } - if (hasProfanity(fullName.value)) { - errorFullName.value = t('error.fieldContainsProfanity', { field: t('ftue.fullName') }); - } - if (hasProfanity(username.value)) { - errorUsername.value = t('error.fieldContainsProfanity', { field: t('label.username') }); - } if (errorFullName.value || errorUsername.value) { isLoading.value = false; return; diff --git a/frontend/src/components/FTUE/SetupSchedule.vue b/frontend/src/components/FTUE/SetupSchedule.vue index a4174bf3d..678b40385 100644 --- a/frontend/src/components/FTUE/SetupSchedule.vue +++ b/frontend/src/components/FTUE/SetupSchedule.vue @@ -10,7 +10,7 @@ import { useUserStore } from '@/stores/user-store'; import { useCalendarStore } from '@/stores/calendar-store'; import { useScheduleStore } from '@/stores/schedule-store'; import { - dayjsKey, callKey, isoWeekdaysKey, hasProfanityKey, + dayjsKey, callKey, isoWeekdaysKey, } from '@/keys'; import { Error, SelectOption } from '@/models'; import TextInput from '@/tbpro/elements/TextInput.vue'; @@ -23,7 +23,6 @@ const { t } = useI18n(); const dj = inject(dayjsKey); const call = inject(callKey); const isoWeekdays = inject(isoWeekdaysKey); -const hasProfanity = inject(hasProfanityKey); const ftueStore = useFTUEStore(); const { @@ -79,12 +78,6 @@ const onSubmit = async () => { return; } - if (hasProfanity(schedule.value.name)) { - errorScheduleName.value = t('error.fieldContainsProfanity', { field: t('ftue.scheduleName') }); - isLoading.value = false; - return; - } - const scheduleData = { ...schedules?.value[0] ?? {}, active: true, diff --git a/frontend/src/components/ScheduleCreation.vue b/frontend/src/components/ScheduleCreation.vue index 28085fadb..9f7ebe093 100644 --- a/frontend/src/components/ScheduleCreation.vue +++ b/frontend/src/components/ScheduleCreation.vue @@ -13,7 +13,7 @@ import { Dayjs } from 'dayjs'; import { useI18n } from 'vue-i18n'; import { useUserStore } from '@/stores/user-store'; import { - dayjsKey, callKey, isoWeekdaysKey, hasProfanityKey, + dayjsKey, callKey, isoWeekdaysKey, } from '@/keys'; import AppointmentCreatedModal from '@/components/AppointmentCreatedModal.vue'; @@ -48,7 +48,6 @@ const { t } = useI18n(); const dj = inject(dayjsKey); const call = inject(callKey); const isoWeekdays = inject(isoWeekdaysKey); -const hasProfanity = inject(hasProfanityKey); const dateFormat = DateFormatStrings.QalendarFullDay; const firstStep = ScheduleCreationState.Availability; @@ -261,10 +260,6 @@ const scheduleValidationError = (schedule: Schedule): string|null => { if (schedule.name === '') { return t('error.fieldIsRequired', { field: t('ftue.scheduleName') }); } - // Schedule name contains profanity - if (hasProfanity(schedule.name)) { - return t('error.fieldContainsProfanity', { field: t('ftue.scheduleName') }); - } // All good return null; }; diff --git a/frontend/src/components/SettingsAccount.vue b/frontend/src/components/SettingsAccount.vue index 57d0ada6d..52e1dd4bd 100644 --- a/frontend/src/components/SettingsAccount.vue +++ b/frontend/src/components/SettingsAccount.vue @@ -5,7 +5,7 @@ import { import { useI18n } from 'vue-i18n'; import { useRouter } from 'vue-router'; import { useUserStore } from '@/stores/user-store'; -import { callKey, hasProfanityKey } from '@/keys'; +import { callKey } from '@/keys'; import { StringListResponse, SubscriberResponse, BlobResponse, BooleanResponse, } from '@/models'; @@ -30,7 +30,6 @@ import UserInviteTable from '@/components/UserInviteTable.vue'; // component constants const { t } = useI18n({ useScope: 'global' }); const call = inject(callKey); -const hasProfanity = inject(hasProfanityKey); const router = useRouter(); const schedule = useScheduleStore(); const externalConnectionsStore = useExternalConnectionsStore(); @@ -114,18 +113,6 @@ const updateUserCheckForConfirmation = async () => { return; } - // Profanity validation - // if (activeUsername.value === '') { - // errorUsername.value = t('error.fieldIsRequired', { field: t('label.username') }); - // } - if (hasProfanity(activeUsername.value)) { - errorUsername.value = t('error.fieldContainsProfanity', { field: t('label.username') }); - } - // Validate display name - if (hasProfanity(activeDisplayName.value)) { - errorDisplayName.value = t('error.fieldContainsProfanity', { field: t('label.displayName') }); - } - if (errorUsername.value || errorDisplayName.value) { return; } diff --git a/frontend/src/keys.ts b/frontend/src/keys.ts index 7303c0c41..c6fb02d32 100644 --- a/frontend/src/keys.ts +++ b/frontend/src/keys.ts @@ -42,7 +42,3 @@ export const paintBackgroundKey = Symbol('paintBackground') as InjectionKey string; export const durationHumanizedKey = Symbol('durationHumanized') as InjectionKey; - -// Profice profanity filter -type HasProfanityType = (url: string) => boolean; -export const hasProfanityKey = Symbol('hasProfanity') as InjectionKey; diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 713c4386b..885017021 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -20,7 +20,6 @@ "credentialsIncomplete": "Bitte gib deine Zugangsdaten ein.", "dataSourceIsEmpty": "{name} konnte nicht gefunden werden.", "externalAccountHasNoCalendars": "Dein {external}-Konto enthält keine Kalender. Bitte verbinde ein anderes Konto.", - "fieldContainsProfanity": "Bitte verwende keine beleidigenden Ausdrücke (entdeckt in {field}).", "fieldIsRequired": "{field} darf nicht leer sein.", "generalBookingError": "Beim Abrufen des Zeitplans ist ein Problem aufgetreten. Bitte später nochmal versuchen.", "googleRefreshError": "Es gab ein Problem mit Google, bitte erneut verbinden.", diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index a52564ec6..d32189f72 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -20,7 +20,6 @@ "credentialsIncomplete": "Please provide login credentials.", "dataSourceIsEmpty": "No {name} could be found.", "externalAccountHasNoCalendars": "Your {external} account contains no calendars. Please connect a different account.", - "fieldContainsProfanity": "Please don't use offensive language (detected in {field}).", "fieldIsRequired": "{field} cannot be empty.", "generalBookingError": "Sorry, there was a problem retrieving the schedule details. Please try again later.", "googleRefreshError": "Error connecting with Google API, please re-connect.",