From ea3e311528719f0e7c9173ca5c7fd0767f3ca3de Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Mon, 15 Apr 2019 03:48:54 +0900 Subject: [PATCH] =?UTF-8?q?=E7=B0=A1=E6=98=93=E7=9A=84=E3=81=AA=E3=83=91?= =?UTF-8?q?=E3=83=BC=E3=83=9F=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AE?= =?UTF-8?q?=E5=BE=8C=E6=96=B9=E4=BA=92=E6=8F=9B=20(#4687)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/server/api/endpoints/app/create.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/server/api/endpoints/app/create.ts b/src/server/api/endpoints/app/create.ts index 71f21fdf4..ba366cdeb 100644 --- a/src/server/api/endpoints/app/create.ts +++ b/src/server/api/endpoints/app/create.ts @@ -3,6 +3,7 @@ import $ from 'cafy'; import define from '../../define'; import { Apps } from '../../../../models'; import { genId } from '../../../../misc/gen-id'; +import { unique } from '../../../../prelude/array'; export const meta = { tags: ['app'], @@ -34,6 +35,9 @@ export default define(meta, async (ps, user) => { // Generate secret const secret = rndstr('a-zA-Z0-9', 32); + // for backward compatibility + const permission = unique(ps.permission.map(v => v.replace(/^(.+)(\/|-)(read|write)$/, '$3:$1'))); + // Create account const app = await Apps.save({ id: genId(), @@ -41,7 +45,7 @@ export default define(meta, async (ps, user) => { userId: user ? user.id : null, name: ps.name, description: ps.description, - permission: ps.permission, + permission, callbackUrl: ps.callbackUrl, secret: secret });