lint fehler behoben
This commit is contained in:
@@ -42,8 +42,6 @@ export default defineEventHandler(async (event) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
|
||||||
const dataDir = getServerDataPath('membership-applications')
|
|
||||||
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
// nosemgrep: javascript.lang.security.audit.path-traversal.path-join-resolve-traversal.path-join-resolve-traversal
|
||||||
const filePath = getServerDataPath('membership-applications', `${id}.json`)
|
const filePath = getServerDataPath('membership-applications', `${id}.json`)
|
||||||
|
|
||||||
|
|||||||
@@ -46,27 +46,26 @@ async function withIdentityLock(hash, operation) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function findMatchingApplication(data) {
|
async function findMatchingApplication(data) {
|
||||||
let files = []
|
|
||||||
try {
|
try {
|
||||||
files = await fs.readdir(APPLICATIONS_DIR)
|
const files = await fs.readdir(APPLICATIONS_DIR)
|
||||||
|
const target = identityHash(data)
|
||||||
|
for (const file of files.filter(file => file.endsWith('.json'))) {
|
||||||
|
try {
|
||||||
|
const application = JSON.parse(await fs.readFile(`${APPLICATIONS_DIR}/${file}`, 'utf8'))
|
||||||
|
if (application.identityHash === target) return application
|
||||||
|
if (application.encryptedData) {
|
||||||
|
const personalData = decryptObject(application.encryptedData, encryptionKey())
|
||||||
|
if (identityHash(personalData) === target) return application
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn('Mitgliedschaftsantrag konnte bei der Duplikatprüfung nicht gelesen werden:', { file, message: error.message })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error?.code !== 'ENOENT') throw error
|
if (error?.code !== 'ENOENT') throw error
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
const target = identityHash(data)
|
|
||||||
for (const file of files.filter(file => file.endsWith('.json'))) {
|
|
||||||
try {
|
|
||||||
const application = JSON.parse(await fs.readFile(`${APPLICATIONS_DIR}/${file}`, 'utf8'))
|
|
||||||
if (application.identityHash === target) return application
|
|
||||||
if (application.encryptedData) {
|
|
||||||
const personalData = decryptObject(application.encryptedData, encryptionKey())
|
|
||||||
if (identityHash(personalData) === target) return application
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.warn('Mitgliedschaftsantrag konnte bei der Duplikatprüfung nicht gelesen werden:', { file, message: error.message })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createMembershipApplication(data) {
|
export async function createMembershipApplication(data) {
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export function upsertPushToken(user, { token, platform = 'android', appVersion
|
|||||||
return user
|
return user
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendFcmMessage({ serviceAccount, accessToken, token, title, body, data = {} }) {
|
async function sendFcmMessage({ serviceAccount, accessToken, token, data = {} }) {
|
||||||
const projectId = projectIdFromServiceAccount(serviceAccount)
|
const projectId = projectIdFromServiceAccount(serviceAccount)
|
||||||
if (!projectId) throw new Error('FCM project_id fehlt.')
|
if (!projectId) throw new Error('FCM project_id fehlt.')
|
||||||
const response = await fetch(`https://fcm.googleapis.com/v1/projects/${projectId}/messages:send`, {
|
const response = await fetch(`https://fcm.googleapis.com/v1/projects/${projectId}/messages:send`, {
|
||||||
@@ -185,7 +185,7 @@ export async function sendPushToUsers({ title, body, data = {}, predicate, bodyF
|
|||||||
const validTokens = []
|
const validTokens = []
|
||||||
for (const entry of tokens) {
|
for (const entry of tokens) {
|
||||||
try {
|
try {
|
||||||
await sendFcmMessage({ serviceAccount, accessToken, token: entry.token, title, body: userBody, data: payload })
|
await sendFcmMessage({ serviceAccount, accessToken, token: entry.token, data: payload })
|
||||||
sent += 1
|
sent += 1
|
||||||
validTokens.push(entry)
|
validTokens.push(entry)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user