some inconsistencies

This commit is contained in:
Evert Prants 2017-09-01 15:02:20 +03:00
parent 20cc71c8c1
commit 1d782a9b98
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
4 changed files with 6 additions and 7 deletions

View File

@ -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)

View File

@ -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'

View File

@ -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.')

View File

@ -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)