Fix moderation queue, moderation status card when approved, and invalid datapack packages (#907)

* Fool behavior

* Add leading underscore to packaged datapack package if it starts with a number

* Hide mod status card for all approved statuses without mod messages

* Fix project id sanitization
This commit is contained in:
Prospector 2023-01-11 15:21:39 -08:00 committed by GitHub
parent c67bc33c23
commit 17f00e6fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -133,10 +133,10 @@ export default {
this.$defaultHeaders() this.$defaultHeaders()
) )
this.$refs.modal.hide()
if (this.onClose !== null) { if (this.onClose !== null) {
this.onClose() this.onClose()
} }
this.$refs.modal.hide()
} catch (err) { } catch (err) {
this.$notify({ this.$notify({
group: 'main', group: 'main',
@ -151,11 +151,15 @@ export default {
show() { show() {
this.$refs.modal.show() this.$refs.modal.show()
this.moderationMessage = this.moderationMessage =
this.project && this.project.moderator_message.message this.project &&
this.project.moderator_message &&
this.project.moderator_message.message
? this.project.moderator_message.message ? this.project.moderator_message.message
: '' : ''
this.moderationMessageBody = this.moderationMessageBody =
this.project && this.project.moderator_message.body this.project &&
this.project.moderator_message &&
this.project.moderator_message.body
? this.project.moderator_message.body ? this.project.moderator_message.body
: '' : ''
}, },

View File

@ -280,9 +280,7 @@
<div <div
v-if=" v-if="
currentMember && currentMember &&
((project.status !== 'approved' && ((!$tag.approvedStatuses.includes(project.status) &&
project.status !== 'unlisted' &&
project.status !== 'draft' &&
project.status !== 'processing') || project.status !== 'processing') ||
(project.moderator_message && (project.moderator_message &&
(project.moderator_message.message || (project.moderator_message.message ||

View File

@ -269,10 +269,10 @@ export default {
}, },
onModalClose() { onModalClose() {
this.projects.splice( this.projects.splice(
this.projects.findIndex((x) => this.project.id === x.id), this.projects.findIndex((x) => this.currentProject.id === x.id),
1 1
) )
this.project = null this.currentProject = null
}, },
async deleteReport(index) { async deleteReport(index) {
this.$nuxt.$loading.start() this.$nuxt.$loading.start()

View File

@ -514,12 +514,20 @@ export const createDataPackVersion = async function (
binary += String.fromCharCode(classFile[i]) binary += String.fromCharCode(classFile[i])
} }
let sanitizedId = project.id
if (project.id.match(/^(\d+)/g)) {
sanitizedId = '_' + sanitizedId
}
sanitizedId = sanitizedId.substring(0, 8)
binary = binary binary = binary
.replace( .replace(
String.fromCharCode(32) + 'needs1to1be1changed1modrinth1mod', String.fromCharCode(32) + 'needs1to1be1changed1modrinth1mod',
String.fromCharCode(newSlug.length) + newSlug String.fromCharCode(newSlug.length) + newSlug
) )
.replace('/wrappera/', `/${project.id.substring(0, 8)}/`) .replace('/wrappera/', `/${sanitizedId}/`)
const newArr = [] const newArr = []
for (let i = 0; i < binary.length; i++) { for (let i = 0; i < binary.length; i++) {
@ -527,7 +535,7 @@ export const createDataPackVersion = async function (
} }
primaryZipReader.file( primaryZipReader.file(
`com/modrinth/${project.id.substring(0, 8)}/ModrinthWrapper.class`, `com/modrinth/${sanitizedId}/ModrinthWrapper.class`,
new Uint8Array(newArr) new Uint8Array(newArr)
) )
} }