Merge branch 'develop' of https://github.com/syuilo/misskey into develop
This commit is contained in:
		
						commit
						fee0437493
					
				
					 7 changed files with 138 additions and 38 deletions
				
			
		| 
						 | 
				
			
			@ -25,6 +25,7 @@ export class AppRepository extends Repository<App> {
 | 
			
		|||
		return {
 | 
			
		||||
			id: app.id,
 | 
			
		||||
			name: app.name,
 | 
			
		||||
			callbackUrl: app.callbackUrl,
 | 
			
		||||
			...(opts.includeSecret ? { secret: app.secret } : {}),
 | 
			
		||||
			...(me ? {
 | 
			
		||||
				isAuthorized: await AccessTokens.count({
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,7 +19,7 @@ export class DriveFileRepository extends Repository<DriveFile> {
 | 
			
		|||
	}
 | 
			
		||||
 | 
			
		||||
	public getPublicUrl(file: DriveFile, thumbnail = false): string | null {
 | 
			
		||||
		return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.thumbnailUrl || file.url);
 | 
			
		||||
		return thumbnail ? (file.thumbnailUrl || file.webpublicUrl || null) : (file.webpublicUrl || file.url);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	public async clacDriveUsageOf(user: User['id'] | User): Promise<number> {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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
 | 
			
		||||
	});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue