wip
This commit is contained in:
parent
f5c55d46b7
commit
06347cd71e
|
@ -6,14 +6,18 @@ import * as tmp from 'tmp';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as request from 'request';
|
import * as request from 'request';
|
||||||
|
|
||||||
const log = debug('misskey:common:drive:upload_from_url');
|
const log = debug('misskey:drive:upload-from-url');
|
||||||
|
|
||||||
export default async (url, user, folderId = null, uri = null): Promise<IDriveFile> => {
|
export default async (url, user, folderId = null, uri = null): Promise<IDriveFile> => {
|
||||||
|
log(`REQUESTED: ${url}`);
|
||||||
|
|
||||||
let name = URL.parse(url).pathname.split('/').pop();
|
let name = URL.parse(url).pathname.split('/').pop();
|
||||||
if (!validateFileName(name)) {
|
if (!validateFileName(name)) {
|
||||||
name = null;
|
name = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log(`name: ${name}`);
|
||||||
|
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const path = await new Promise((res: (string) => void, rej) => {
|
const path = await new Promise((res: (string) => void, rej) => {
|
||||||
tmp.file((e, path) => {
|
tmp.file((e, path) => {
|
||||||
|
@ -37,6 +41,8 @@ export default async (url, user, folderId = null, uri = null): Promise<IDriveFil
|
||||||
|
|
||||||
const driveFile = await create(user, path, name, null, folderId, false, uri);
|
const driveFile = await create(user, path, name, null, folderId, false, uri);
|
||||||
|
|
||||||
|
log(`created: ${driveFile._id}`);
|
||||||
|
|
||||||
// clean-up
|
// clean-up
|
||||||
fs.unlink(path, (e) => {
|
fs.unlink(path, (e) => {
|
||||||
if (e) log(e.stack);
|
if (e) log(e.stack);
|
||||||
|
|
|
@ -30,6 +30,10 @@ const ev = new Xev();
|
||||||
|
|
||||||
process.title = 'Misskey';
|
process.title = 'Misskey';
|
||||||
|
|
||||||
|
if (process.env.NODE_ENV != 'production') {
|
||||||
|
process.env.DEBUG = 'misskey:*';
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/Automattic/kue/issues/822
|
// https://github.com/Automattic/kue/issues/822
|
||||||
require('events').EventEmitter.prototype._maxListeners = 256;
|
require('events').EventEmitter.prototype._maxListeners = 256;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ export default async (value, verifier?: string) => {
|
||||||
const user = await User.insert({
|
const user = await User.insert({
|
||||||
avatarId: null,
|
avatarId: null,
|
||||||
bannerId: null,
|
bannerId: null,
|
||||||
createdAt: Date.parse(object.published),
|
createdAt: Date.parse(object.published) || null,
|
||||||
description: summaryDOM.textContent,
|
description: summaryDOM.textContent,
|
||||||
followersCount: 0,
|
followersCount: 0,
|
||||||
followingCount: 0,
|
followingCount: 0,
|
||||||
|
@ -55,14 +55,14 @@ export default async (value, verifier?: string) => {
|
||||||
const [avatarId, bannerId] = await Promise.all([
|
const [avatarId, bannerId] = await Promise.all([
|
||||||
object.icon,
|
object.icon,
|
||||||
object.image
|
object.image
|
||||||
].map(async url => {
|
].map(async img => {
|
||||||
if (url === undefined) {
|
if (img === undefined) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const img = await uploadFromUrl(url, user);
|
const file = await uploadFromUrl(img.url, user);
|
||||||
|
|
||||||
return img._id;
|
return file._id;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
User.update({ _id: user._id }, { $set: { avatarId, bannerId } });
|
User.update({ _id: user._id }, { $set: { avatarId, bannerId } });
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { IObject } from "./type";
|
import * as request from 'request-promise-native';
|
||||||
|
import * as debug from 'debug';
|
||||||
|
import { IObject } from './type';
|
||||||
|
|
||||||
const request = require('request-promise-native');
|
const log = debug('misskey:activitypub:resolver');
|
||||||
|
|
||||||
export default class Resolver {
|
export default class Resolver {
|
||||||
private history: Set<string>;
|
private history: Set<string>;
|
||||||
|
@ -57,6 +59,8 @@ export default class Resolver {
|
||||||
throw new Error('invalid response');
|
throw new Error('invalid response');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log(`resolved: ${JSON.stringify(object)}`);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue