Skip to content

Commit

Permalink
Remove the frontend profanity filter (Fixes #840) (#841)
Browse files Browse the repository at this point in the history
* Remove the frontend profanity filter (Fixes #839)
  • Loading branch information
MelissaAutumn authored Feb 4, 2025
1 parent d51d098 commit 5e9e602
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 63 deletions.
10 changes: 0 additions & 10 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 1 addition & 10 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/FTUE/SetupProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ 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';
const { t } = useI18n();
const dj = inject(dayjsKey);
const call = inject(callKey);
const hasProfanity = inject(hasProfanityKey);
const ftueStore = useFTUEStore();
const { hasNextStep } = storeToRefs(ftueStore);
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 1 addition & 8 deletions frontend/src/components/FTUE/SetupSchedule.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/components/ScheduleCreation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
};
Expand Down
15 changes: 1 addition & 14 deletions frontend/src/components/SettingsAccount.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,3 @@ export const paintBackgroundKey = Symbol('paintBackground') as InjectionKey<Pain
// Provide duration data in human friendly form
type DurationHumanizedType = (minutes: number) => string;
export const durationHumanizedKey = Symbol('durationHumanized') as InjectionKey<DurationHumanizedType>;

// Profice profanity filter
type HasProfanityType = (url: string) => boolean;
export const hasProfanityKey = Symbol('hasProfanity') as InjectionKey<HasProfanityType>;
1 change: 0 additions & 1 deletion frontend/src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
1 change: 0 additions & 1 deletion frontend/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit 5e9e602

Please sign in to comment.