From 1d782a9b98a4655d1eaeef3305e71a13bf1eefa4 Mon Sep 17 00:00:00 2001 From: Evert Date: Fri, 1 Sep 2017 15:02:20 +0300 Subject: [PATCH] some inconsistencies --- server/api/admin.js | 2 +- server/api/external.js | 1 - server/api/image.js | 6 +++--- server/api/index.js | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/server/api/admin.js b/server/api/admin.js index 9c36766..47c2b00 100644 --- a/server/api/admin.js +++ b/server/api/admin.js @@ -175,7 +175,7 @@ const API = { return Models.OAuth2Client.query().insert(obj) }, removeClient: async function (id) { - if (isNaN(id)) return {error: 'Invalid number'} + if (isNaN(id)) return {error: 'Invalid ID number'} await Models.OAuth2Client.query().delete().where('id', id) await Models.OAuth2AuthorizedClient.query().delete().where('client_id', id) await Models.OAuth2AccessToken.query().delete().where('client_id', id) diff --git a/server/api/external.js b/server/api/external.js index 8e85c5b..6a21a28 100644 --- a/server/api/external.js +++ b/server/api/external.js @@ -4,7 +4,6 @@ import models from './models' import UAPI from './index' import qs from 'querystring' import oauth from 'oauth-libre' -import fs from 'fs' import path from 'path' import url from 'url' diff --git a/server/api/image.js b/server/api/image.js index e60d81c..7c8587a 100644 --- a/server/api/image.js +++ b/server/api/image.js @@ -32,7 +32,7 @@ async function bailOut (file, error) { return { error: error } } -async function uploadImage (username, fields, files) { +async function uploadImage (identifier, fields, files) { let directory = path.join(uploads, 'images') if (!files.image) return {error: 'No image file'} @@ -58,7 +58,7 @@ async function uploadImage (username, fields, files) { } if (!match) return bailOut(file, 'Invalid image type. Only PNG, JPG and JPEG files are allowed.') let extension = imageTypes[contentType] - let fileName = username + '-' + fileHash + extension + let fileName = identifier + '-' + fileHash + extension // Check for cropping if (fields.x == null || fields.y == null || fields.width == null || fields.height == null) { @@ -95,7 +95,7 @@ async function uploadImage (username, fields, files) { }) }) - await fs.unlinkAsync(file) + await fsBlue.unlinkAsync(file) } catch (e) { console.error(e) return bailOut(file, 'An error occured while cropping.') diff --git a/server/api/index.js b/server/api/index.js index 4b291e8..a8f9b32 100644 --- a/server/api/index.js +++ b/server/api/index.js @@ -71,7 +71,7 @@ async function cleanUpDonation (obj, mcOnly, timeframe) { result.name = user.display_name } - let sources = obj.source.split(';') + let sources = obj.source.split(',') for (let i in sources) { if (sources[i].indexOf('mcu:') === 0) { let mcu = sources[i].split(':')[1] @@ -483,7 +483,7 @@ const API = { let donation = { user_id: user ? user.id : null, amount: (body.mc_gross || body.payment_gross || 'Unknown') + ' ' + (body.mc_currency || 'EUR'), - source: source.join(';'), + source: source.join(','), note: body.memo || '', read: 0, created_at: new Date(body.payment_date)