diff --git a/components/ui/report/ReportView.vue b/components/ui/report/ReportView.vue index a3d2195bcf..3c6ec16c9d 100644 --- a/components/ui/report/ReportView.vue +++ b/components/ui/report/ReportView.vue @@ -74,7 +74,7 @@ async function fetchReport() { let users = [] if (userIds.length > 0) { const { data: usersVal } = await useAsyncData(`users?ids=${JSON.stringify(userIds)}`, () => - useBaseFetch(`users?ids=${JSON.stringify(userIds)}`) + useBaseFetch(`users?ids=${encodeURIComponent(JSON.stringify(userIds))}`) ) users = usersVal.value } diff --git a/components/ui/report/ReportsList.vue b/components/ui/report/ReportsList.vue index 483adfa513..4d672a7760 100644 --- a/components/ui/report/ReportsList.vue +++ b/components/ui/report/ReportsList.vue @@ -54,13 +54,13 @@ const threadIds = [ const [{ data: users }, { data: versions }, { data: threads }] = await Promise.all([ await useAsyncData(`users?ids=${JSON.stringify(userIds)}`, () => - useBaseFetch(`users?ids=${JSON.stringify(userIds)}`) + useBaseFetch(`users?ids=${encodeURIComponent(JSON.stringify(userIds))}`) ), await useAsyncData(`versions?ids=${JSON.stringify(versionIds)}`, () => - useBaseFetch(`versions?ids=${JSON.stringify(versionIds)}`) + useBaseFetch(`versions?ids=${encodeURIComponent(JSON.stringify(versionIds))}`) ), await useAsyncData(`threads?ids=${JSON.stringify(threadIds)}`, () => - useBaseFetch(`threads?ids=${JSON.stringify(threadIds)}`) + useBaseFetch(`threads?ids=${encodeURIComponent(JSON.stringify(threadIds))}`) ), ]) @@ -71,7 +71,7 @@ const versionProjects = versions.value.map((version) => version.project_id) const projectIds = [...new Set(reportedProjects.concat(versionProjects))] const { data: projects } = await useAsyncData(`projects?ids=${JSON.stringify(projectIds)}`, () => - useBaseFetch(`projects?ids=${JSON.stringify(projectIds)}`) + useBaseFetch(`projects?ids=${encodeURIComponent(JSON.stringify(projectIds))}`) ) reports.value = rawReports.map((report) => { diff --git a/composables/fetch.js b/composables/fetch.js index b296e529aa..45f984e009 100644 --- a/composables/fetch.js +++ b/composables/fetch.js @@ -16,5 +16,6 @@ export const useBaseFetch = async (url, options = {}, skipAuth = false) => { options.headers.Authorization = auth.value.token } + console.log(`${base}${url}`) return await $fetch(`${base}${url}`, options) } diff --git a/helpers/notifications.js b/helpers/notifications.js index f8228616e7..66f2168080 100644 --- a/helpers/notifications.js +++ b/helpers/notifications.js @@ -6,7 +6,7 @@ async function getBulk(type, ids) { return [] } - const url = `${type}?ids=${JSON.stringify([...new Set(ids)])}` + const url = `${type}?ids=${encodeURIComponent(JSON.stringify([...new Set(ids)]))}` const { data: bulkFetch } = await useAsyncData(url, () => useBaseFetch(url)) return bulkFetch.value } diff --git a/pages/moderation/review.vue b/pages/moderation/review.vue index 36fd804a62..974a85369b 100644 --- a/pages/moderation/review.vue +++ b/pages/moderation/review.vue @@ -145,37 +145,30 @@ const projectTypes = computed(() => { if (projects.value) { const teamIds = projects.value.map((x) => x.team) - await useAsyncData( - 'teams?ids=' + JSON.stringify(teamIds), - () => useBaseFetch('teams?ids=' + JSON.stringify(teamIds)), - { - transform: (result) => { - if (result) { - members.value = result - - projects.value = projects.value.map((project) => { - project.owner = members.value - .flat() - .find((x) => x.team_id === project.team && x.role === 'Owner').user - project.age = project.queued ? now - app.$dayjs(project.queued) : Number.MAX_VALUE - project.age_warning = '' - if (project.age > TIME_24H * 2) { - project.age_warning = 'danger' - } else if (project.age > TIME_24H) { - project.age_warning = 'warning' - } - project.inferred_project_type = app.$getProjectTypeForUrl( - project.project_type, - project.loaders - ) - return project - }) - } - - return result - }, - } - ) + const url = `teams?ids=${encodeURIComponent(JSON.stringify(teamIds))}` + const { data: result } = await useAsyncData(url, () => useBaseFetch(url)) + + if (result.value) { + members.value = result.value + + projects.value = projects.value.map((project) => { + project.owner = members.value + .flat() + .find((x) => x.team_id === project.team && x.role === 'Owner').user + project.age = project.queued ? now - app.$dayjs(project.queued) : Number.MAX_VALUE + project.age_warning = '' + if (project.age > TIME_24H * 2) { + project.age_warning = 'danger' + } else if (project.age > TIME_24H) { + project.age_warning = 'warning' + } + project.inferred_project_type = app.$getProjectTypeForUrl( + project.project_type, + project.loaders + ) + return project + }) + } }