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
|
||||
const filePath = getServerDataPath('membership-applications', `${id}.json`)
|
||||
|
||||
|
||||
@@ -46,27 +46,26 @@ async function withIdentityLock(hash, operation) {
|
||||
}
|
||||
|
||||
async function findMatchingApplication(data) {
|
||||
let files = []
|
||||
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) {
|
||||
if (error?.code !== 'ENOENT') throw error
|
||||
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) {
|
||||
|
||||
@@ -102,7 +102,7 @@ export function upsertPushToken(user, { token, platform = 'android', appVersion
|
||||
return user
|
||||
}
|
||||
|
||||
async function sendFcmMessage({ serviceAccount, accessToken, token, title, body, data = {} }) {
|
||||
async function sendFcmMessage({ serviceAccount, accessToken, token, data = {} }) {
|
||||
const projectId = projectIdFromServiceAccount(serviceAccount)
|
||||
if (!projectId) throw new Error('FCM project_id fehlt.')
|
||||
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 = []
|
||||
for (const entry of tokens) {
|
||||
try {
|
||||
await sendFcmMessage({ serviceAccount, accessToken, token: entry.token, title, body: userBody, data: payload })
|
||||
await sendFcmMessage({ serviceAccount, accessToken, token: entry.token, data: payload })
|
||||
sent += 1
|
||||
validTokens.push(entry)
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user