forked from FoundKeyGang/FoundKey
* wip * wip * Update abuse-user-reports.ts * Update files.ts * Update list-remote.ts * Update list.ts * Update show-users.ts * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * wip * Update update.ts * Update search.ts * Update reactions.ts * Update search.ts * wip * wip * wip * wip * Update update.ts * Update relation.ts * Update available.ts * wip * wip * wip * Update packages/backend/src/server/api/define.ts Co-authored-by: Johann150 <johann.galle@protonmail.com> * Update define.ts * Update define.ts * typo * wip * wip * wip * wip * wip * wip * wip * wip * Update update.ts * wip * Update signup.ts * Update call.ts * minimum for limit * type * remove needless annotation * wip * Update signup.ts * wip * wip * fix * Update create.ts Co-authored-by: Johann150 <johann.galle@protonmail.com>
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import ms from 'ms';
|
|
import { uploadFromUrl } from '@/services/drive/upload-from-url';
|
|
import define from '../../../define';
|
|
import { DriveFiles } from '@/models/index';
|
|
import { publishMainStream } from '@/services/stream';
|
|
import { DB_MAX_IMAGE_COMMENT_LENGTH } from '@/misc/hard-limits';
|
|
|
|
export const meta = {
|
|
tags: ['drive'],
|
|
|
|
limit: {
|
|
duration: ms('1hour'),
|
|
max: 60,
|
|
},
|
|
|
|
requireCredential: true,
|
|
|
|
kind: 'write:drive',
|
|
} as const;
|
|
|
|
const paramDef = {
|
|
type: 'object',
|
|
properties: {
|
|
url: { type: 'string' },
|
|
folderId: { type: 'string', format: 'misskey:id', nullable: true, default: null },
|
|
isSensitive: { type: 'boolean', default: false },
|
|
comment: { type: 'string', nullable: true, maxLength: 512, default: null },
|
|
marker: { type: 'string', nullable: true, default: null },
|
|
force: { type: 'boolean', default: false },
|
|
},
|
|
required: ['url'],
|
|
} as const;
|
|
|
|
// eslint-disable-next-line import/no-default-export
|
|
export default define(meta, paramDef, async (ps, user) => {
|
|
uploadFromUrl({ url: ps.url, user, folderId: ps.folderId, sensitive: ps.isSensitive, force: ps.force, comment: ps.comment }).then(file => {
|
|
DriveFiles.pack(file, { self: true }).then(packedFile => {
|
|
publishMainStream(user.id, 'urlUploadFinished', {
|
|
marker: ps.marker,
|
|
file: packedFile,
|
|
});
|
|
});
|
|
});
|
|
});
|