Compare commits

..

6 Commits
2.1.2 ... 2.2.0

Author SHA1 Message Date
syuilo
d9cdc1f079 2.2.0 2018-05-04 18:32:13 +09:00
syuilo
414c600356 ファイルのURLを保存するように 2018-05-04 18:32:03 +09:00
syuilo
e37c19fdcd 2.1.4 2018-05-04 18:02:17 +09:00
syuilo
d69b919961 oops 2018-05-04 18:02:09 +09:00
syuilo
1311db8060 2.1.3 2018-05-04 18:00:02 +09:00
syuilo
ed9e7520f1 Fix bug 2018-05-04 17:59:51 +09:00
7 changed files with 24 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "2.1.2", "version": "2.2.0",
"clientVersion": "1.0.5193", "clientVersion": "1.0.5193",
"codename": "nighthike", "codename": "nighthike",
"main": "./built/index.js", "main": "./built/index.js",

View File

@@ -28,7 +28,8 @@ export type IMetadata = {
_user: any; _user: any;
folderId: mongo.ObjectID; folderId: mongo.ObjectID;
comment: string; comment: string;
uri: string; uri?: string;
url?: string;
deletedAt?: Date; deletedAt?: Date;
isExpired?: boolean; isExpired?: boolean;
}; };

View File

@@ -24,7 +24,7 @@ export async function createImage(actor: IRemoteUser, value): Promise<IDriveFile
log(`Creating the Image: ${image.url}`); log(`Creating the Image: ${image.url}`);
return await uploadFromUrl(image.url, actor); return await uploadFromUrl(image.url, actor, null, image.url);
} }
/** /**

View File

@@ -6,6 +6,8 @@ import * as mongodb from 'mongodb';
import DriveFile, { getDriveFileBucket } from '../../models/drive-file'; import DriveFile, { getDriveFileBucket } from '../../models/drive-file';
import DriveFileThumbnail, { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail'; import DriveFileThumbnail, { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
const assets = `${__dirname}/../../server/file/assets/`;
const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => { const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => {
console.error(e); console.error(e);
ctx.status = 500; ctx.status = 500;
@@ -25,16 +27,16 @@ export default async function(ctx: Koa.Context) {
if (file == null) { if (file == null) {
ctx.status = 404; ctx.status = 404;
await send(ctx, `${__dirname}/assets/dummy.png`); await send(ctx, '/dummy.png', { root: assets });
return; return;
} }
if (file.metadata.deletedAt) { if (file.metadata.deletedAt) {
ctx.status = 410; ctx.status = 410;
if (file.metadata.isExpired) { if (file.metadata.isExpired) {
await send(ctx, `${__dirname}/assets/cache-expired.png`); await send(ctx, '/cache-expired.png', { root: assets });
} else { } else {
await send(ctx, `${__dirname}/assets/tombstone.png`); await send(ctx, '/tombstone.png', { root: assets });
} }
return; return;
} }

View File

@@ -42,17 +42,21 @@ router.get('/assets/*', async ctx => {
// Apple touch icon // Apple touch icon
router.get('/apple-touch-icon.png', async ctx => { router.get('/apple-touch-icon.png', async ctx => {
await send(ctx, `${client}/assets/apple-touch-icon.png`); await send(ctx, '/assets/apple-touch-icon.png', {
root: client
});
}); });
// ServiceWroker // ServiceWroker
router.get(/^\/sw\.(.+?)\.js$/, async ctx => { //router.get(/^\/sw\.(.+?)\.js$/, async ctx => {
await send(ctx, `${client}/assets/sw.${ctx.params[0]}.js`); // await send(ctx, `${client}/assets/sw.${ctx.params[0]}.js`);
}); //});
// Manifest // Manifest
router.get('/manifest.json', async ctx => { router.get('/manifest.json', async ctx => {
await send(ctx, `${client}/assets/manifest.json`); await send(ctx, '/assets/manifest.json', {
root: client
});
}); });
//#endregion //#endregion

View File

@@ -62,6 +62,7 @@ const addFile = async (
comment: string = null, comment: string = null,
folderId: mongodb.ObjectID = null, folderId: mongodb.ObjectID = null,
force: boolean = false, force: boolean = false,
url: string = null,
uri: string = null uri: string = null
): Promise<IDriveFile> => { ): Promise<IDriveFile> => {
log(`registering ${name} (user: ${getAcct(user)}, path: ${path})`); log(`registering ${name} (user: ${getAcct(user)}, path: ${path})`);
@@ -296,6 +297,10 @@ const addFile = async (
properties: properties properties: properties
} as IMetadata; } as IMetadata;
if (url !== null) {
metadata.url = url;
}
if (uri !== null) { if (uri !== null) {
metadata.uri = uri; metadata.uri = uri;
} }

View File

@@ -43,7 +43,7 @@ export default async (url, user, folderId = null, uri = null): Promise<IDriveFil
let error; let error;
try { try {
driveFile = await create(user, path, name, null, folderId, false, uri); driveFile = await create(user, path, name, null, folderId, false, url, uri);
log(`created: ${driveFile._id}`); log(`created: ${driveFile._id}`);
} catch (e) { } catch (e) {
error = e; error = e;