Compare commits

..

22 Commits
9.3.1 ... 9.7.0

Author SHA1 Message Date
syuilo
11b84a04b3 9.7.0 2018-10-05 01:59:26 +09:00
MeiMei
f243ce66e7 ActivityPubのHTTPリクエストの強化 (#2820)
* Fix error handling in AP deliver

* Set timeout to resolver

* Tune looks
2018-10-05 01:58:41 +09:00
syuilo
baf9b65801 Improve error handling of packaging functions 2018-10-05 01:43:47 +09:00
syuilo
401d0b1298 9.5.0 2018-10-04 13:55:25 +09:00
syuilo
fce7dc0f4e Improve error handling of pack function of notification 2018-10-04 13:53:48 +09:00
syuilo
35489ef5b7 Improve default theme definition (dark) 2018-10-04 13:48:26 +09:00
syuilo
546d494587 Improve default theme definition (light) 2018-10-04 13:40:13 +09:00
syuilo
e8afa2c940 Improve pack function of favorite 2018-10-04 13:33:59 +09:00
syuilo
c1ef1bf605 fix(package): update typescript-eslint-parser to version 19.0.2 (#2819)
Closes #2772
2018-10-04 12:53:50 +09:00
syuilo
4ab0dbe7e3 fix(package): update @types/webpack to version 4.4.14 (#2818)
Closes #2778
2018-10-04 12:53:17 +09:00
syuilo
44f86a94f4 fix(package): update @types/node to version 10.11.4 (#2817)
Closes #2765
2018-10-04 12:52:57 +09:00
syuilo
a0278154a3 fix(package): update webpack-cli to version 3.1.2 (#2816)
Closes #2757
2018-10-04 12:52:27 +09:00
greenkeeper[bot]
8b7e6b200e fix(package): update jsdom to version 12.1.0 (#2788) 2018-10-04 12:51:19 +09:00
greenkeeper[bot]
d6f6c26725 fix(package): update @types/qrcode to version 1.3.0 (#2813) 2018-10-04 12:50:32 +09:00
greenkeeper[bot]
cf66343b31 fix(package): update qrcode to version 1.3.0 (#2799) 2018-10-04 12:50:25 +09:00
greenkeeper[bot]
d53689332f fix(package): update diskusage to version 0.2.5 (#2767) 2018-10-04 12:49:56 +09:00
greenkeeper[bot]
4105237027 fix(package): update koa-mount to version 4.0.0 (#2776) 2018-10-04 12:49:38 +09:00
greenkeeper[bot]
436962e4b8 fix(package): update nan to version 2.11.1 (#2784) 2018-10-04 12:49:05 +09:00
syuilo
a85efa1392 fix(package): update gulp-htmlmin to version 5.0.1 (#2815)
Closes #2669
2018-10-04 12:48:52 +09:00
syuilo
f0115a5e21 fix(package): update webpack to version 4.20.2 (#2814)
Closes #2768
2018-10-04 12:45:47 +09:00
syuilo
80105239dc 9.4.0 2018-10-04 00:39:48 +09:00
syuilo
baad11288a ドキュメントが見つからなくてもエラーにせずnullを返すように 2018-10-04 00:39:11 +09:00
28 changed files with 158 additions and 90 deletions

View File

@@ -1,8 +1,8 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "9.3.1", "version": "9.7.0",
"clientVersion": "1.0.10062", "clientVersion": "1.0.10090",
"codename": "nighthike", "codename": "nighthike",
"main": "./built/index.js", "main": "./built/index.js",
"private": true, "private": true,
@@ -60,10 +60,10 @@
"@types/mocha": "5.2.3", "@types/mocha": "5.2.3",
"@types/mongodb": "3.1.7", "@types/mongodb": "3.1.7",
"@types/ms": "0.7.30", "@types/ms": "0.7.30",
"@types/node": "10.10.3", "@types/node": "10.11.4",
"@types/portscanner": "2.1.0", "@types/portscanner": "2.1.0",
"@types/pug": "2.0.4", "@types/pug": "2.0.4",
"@types/qrcode": "1.2.0", "@types/qrcode": "1.3.0",
"@types/ratelimiter": "2.1.28", "@types/ratelimiter": "2.1.28",
"@types/redis": "2.8.6", "@types/redis": "2.8.6",
"@types/request": "2.47.1", "@types/request": "2.47.1",
@@ -78,7 +78,7 @@
"@types/tinycolor2": "1.4.1", "@types/tinycolor2": "1.4.1",
"@types/tmp": "0.0.33", "@types/tmp": "0.0.33",
"@types/uuid": "3.4.4", "@types/uuid": "3.4.4",
"@types/webpack": "4.4.12", "@types/webpack": "4.4.14",
"@types/webpack-stream": "3.2.10", "@types/webpack-stream": "3.2.10",
"@types/websocket": "0.0.40", "@types/websocket": "0.0.40",
"@types/ws": "6.0.1", "@types/ws": "6.0.1",
@@ -98,7 +98,7 @@
"debug": "4.0.1", "debug": "4.0.1",
"deep-equal": "1.0.1", "deep-equal": "1.0.1",
"deepcopy": "0.6.3", "deepcopy": "0.6.3",
"diskusage": "0.2.4", "diskusage": "0.2.5",
"dompurify": "1.0.5", "dompurify": "1.0.5",
"double-ended-queue": "2.1.0-0", "double-ended-queue": "2.1.0-0",
"elasticsearch": "15.1.1", "elasticsearch": "15.1.1",
@@ -113,7 +113,7 @@
"fuckadblock": "3.2.1", "fuckadblock": "3.2.1",
"gulp": "3.9.1", "gulp": "3.9.1",
"gulp-cssnano": "2.1.3", "gulp-cssnano": "2.1.3",
"gulp-htmlmin": "4.0.0", "gulp-htmlmin": "5.0.1",
"gulp-imagemin": "4.1.0", "gulp-imagemin": "4.1.0",
"gulp-mocha": "6.0.0", "gulp-mocha": "6.0.0",
"gulp-pug": "4.0.1", "gulp-pug": "4.0.1",
@@ -133,7 +133,7 @@
"is-root": "2.0.0", "is-root": "2.0.0",
"is-url": "1.2.4", "is-url": "1.2.4",
"js-yaml": "3.12.0", "js-yaml": "3.12.0",
"jsdom": "11.12.0", "jsdom": "12.1.0",
"json5": "2.1.0", "json5": "2.1.0",
"json5-loader": "1.0.1", "json5-loader": "1.0.1",
"koa": "2.5.1", "koa": "2.5.1",
@@ -142,7 +142,7 @@
"koa-favicon": "2.0.1", "koa-favicon": "2.0.1",
"koa-json-body": "5.3.0", "koa-json-body": "5.3.0",
"koa-logger": "3.2.0", "koa-logger": "3.2.0",
"koa-mount": "3.0.0", "koa-mount": "4.0.0",
"koa-multer": "1.0.2", "koa-multer": "1.0.2",
"koa-router": "7.4.0", "koa-router": "7.4.0",
"koa-send": "5.0.0", "koa-send": "5.0.0",
@@ -159,7 +159,7 @@
"mongodb": "3.1.1", "mongodb": "3.1.1",
"monk": "6.0.6", "monk": "6.0.6",
"ms": "2.1.1", "ms": "2.1.1",
"nan": "2.11.0", "nan": "2.11.1",
"nested-property": "0.0.7", "nested-property": "0.0.7",
"nprogress": "0.2.0", "nprogress": "0.2.0",
"object-assign-deep": "0.4.0", "object-assign-deep": "0.4.0",
@@ -171,7 +171,7 @@
"promise-sequential": "1.1.1", "promise-sequential": "1.1.1",
"pug": "2.0.3", "pug": "2.0.3",
"punycode": "2.1.1", "punycode": "2.1.1",
"qrcode": "1.2.2", "qrcode": "1.3.0",
"ratelimiter": "3.2.0", "ratelimiter": "3.2.0",
"recaptcha-promise": "0.1.3", "recaptcha-promise": "0.1.3",
"reconnecting-websocket": "3.2.2", "reconnecting-websocket": "3.2.2",
@@ -203,7 +203,7 @@
"ts-node": "7.0.1", "ts-node": "7.0.1",
"tslint": "5.10.0", "tslint": "5.10.0",
"typescript": "2.9.2", "typescript": "2.9.2",
"typescript-eslint-parser": "18.0.0", "typescript-eslint-parser": "19.0.2",
"uglify-es": "3.3.9", "uglify-es": "3.3.9",
"url-loader": "1.1.1", "url-loader": "1.1.1",
"uuid": "3.3.2", "uuid": "3.3.2",
@@ -225,8 +225,8 @@
"vuex-persistedstate": "2.5.4", "vuex-persistedstate": "2.5.4",
"web-push": "3.3.3", "web-push": "3.3.3",
"webfinger.js": "2.6.6", "webfinger.js": "2.6.6",
"webpack": "4.19.1", "webpack-cli": "3.1.2",
"webpack-cli": "3.1.0", "webpack": "4.20.2",
"websocket": "1.0.28", "websocket": "1.0.28",
"ws": "6.0.0", "ws": "6.0.0",
"xev": "2.0.1" "xev": "2.0.1"

View File

@@ -46,15 +46,15 @@
noteHeaderBadgeBg: 'rgba(0, 0, 0, 0.25)', noteHeaderBadgeBg: 'rgba(0, 0, 0, 0.25)',
noteHeaderAdminFg: '#f15f71', noteHeaderAdminFg: '#f15f71',
noteHeaderAdminBg: '#5d282e', noteHeaderAdminBg: '#5d282e',
noteHeaderAcct: '#606984', noteHeaderAcct: ':alpha<0.65<$text',
noteHeaderInfo: '#606984', noteHeaderInfo: ':alpha<0.5<$text',
noteActions: '#606984', noteActions: ':alpha<0.45<$text',
noteActionsHover: '#a1a8bf', noteActionsHover: ':alpha<0.6<$text',
noteActionsReplyHover: '#0af', noteActionsReplyHover: '#0af',
noteActionsRenoteHover: '#8d0', noteActionsRenoteHover: '#8d0',
noteActionsReactionHover: '#fa0', noteActionsReactionHover: '#fa0',
noteActionsHighlighted: '#707b97', noteActionsHighlighted: ':alpha<0.7<$text',
noteAttachedFile: 'rgba(255, 255, 255, 0.1)', noteAttachedFile: 'rgba(255, 255, 255, 0.1)',

View File

@@ -23,13 +23,13 @@
scrollbarHandleHover: '#00000066', scrollbarHandleHover: '#00000066',
face: '$secondary', face: '$secondary',
faceText: '#444', faceText: '$text',
faceHeader: ':lighten<5<$secondary', faceHeader: ':lighten<5<$secondary',
faceHeaderText: '#888', faceHeaderText: '$text',
faceDivider: 'rgba(0, 0, 0, 0.082)', faceDivider: 'rgba(0, 0, 0, 0.082)',
faceTextButton: '#ccc', faceTextButton: ':alpha<0.7<$text',
faceTextButtonHover: '#aaa', faceTextButtonHover: ':alpha<0.7<:darken<7<$text',
faceTextButtonActive: '#999', faceTextButtonActive: ':alpha<0.7<:darken<10<$text',
faceClearButtonHover: 'rgba(0, 0, 0, 0.025)', faceClearButtonHover: 'rgba(0, 0, 0, 0.025)',
faceClearButtonActive: 'rgba(0, 0, 0, 0.05)', faceClearButtonActive: 'rgba(0, 0, 0, 0.05)',
popupBg: ':lighten<5<$secondary', popupBg: ':lighten<5<$secondary',
@@ -40,7 +40,7 @@
renoteGradient: '#edfde2', renoteGradient: '#edfde2',
renoteText: '#9dbb00', renoteText: '#9dbb00',
quoteBorder: '#c0dac6', quoteBorder: '#c0dac6',
noteText: '#717171', noteText: '$text',
noteHeaderName: ':darken<2<$text', noteHeaderName: ':darken<2<$text',
noteHeaderBadgeFg: '#aaa', noteHeaderBadgeFg: '#aaa',
noteHeaderBadgeBg: 'rgba(0, 0, 0, 0.05)', noteHeaderBadgeBg: 'rgba(0, 0, 0, 0.05)',
@@ -141,7 +141,7 @@
desktopHeaderBg: ':lighten<5<$secondary', desktopHeaderBg: ':lighten<5<$secondary',
desktopHeaderFg: '$text', desktopHeaderFg: '$text',
desktopHeaderHoverFg: '#7b8c88', desktopHeaderHoverFg: ':darken<7<$text',
desktopHeaderSearchBg: 'rgba(0, 0, 0, 0.05)', desktopHeaderSearchBg: 'rgba(0, 0, 0, 0.05)',
desktopHeaderSearchHoverBg: 'rgba(0, 0, 0, 0.08)', desktopHeaderSearchHoverBg: 'rgba(0, 0, 0, 0.08)',
desktopHeaderSearchFg: '#000', desktopHeaderSearchFg: '#000',
@@ -156,9 +156,9 @@
desktopPostFormTransparentButtonActiveGradientEnd: ':lighten<33<$primary', desktopPostFormTransparentButtonActiveGradientEnd: ':lighten<33<$primary',
desktopRenoteFormFooter: ':lighten<33<$primary', desktopRenoteFormFooter: ':lighten<33<$primary',
desktopTimelineHeaderShadow: 'rgba(0, 0, 0, 0.08)', desktopTimelineHeaderShadow: 'rgba(0, 0, 0, 0.08)',
desktopTimelineSrc: '#6f7477', desktopTimelineSrc: '$text',
desktopTimelineSrcHover: '#525a5f', desktopTimelineSrcHover: ':darken<7<$text',
desktopWindowTitle: '#666', desktopWindowTitle: '$text',
desktopWindowShadow: 'rgba(0, 0, 0, 0.2)', desktopWindowShadow: 'rgba(0, 0, 0, 0.2)',
desktopDriveBg: '#fff', desktopDriveBg: '#fff',
desktopDriveFolderBg: ':lighten<31<$primary', desktopDriveFolderBg: ':lighten<31<$primary',

View File

@@ -127,6 +127,15 @@ export async function deleteDriveFile(driveFile: string | mongo.ObjectID | IDriv
}); });
} }
export const packMany = async (
files: any[],
options?: {
detail: boolean
}
) => {
return (await Promise.all(files.map(f => pack(f, options)))).filter(x => x != null);
};
/** /**
* Pack a drive file for API response * Pack a drive file for API response
*/ */
@@ -155,7 +164,11 @@ export const pack = (
_file = deepcopy(file); _file = deepcopy(file);
} }
if (!_file) return reject('invalid file arg.'); // (データベースの欠損などで)ファイルがデータベース上に見つからなかったとき
if (_file == null) {
console.warn(`in packaging driveFile: driveFile not found on database: ${_file}`);
return null;
}
// rendered target // rendered target
let _target: any = {}; let _target: any = {};

View File

@@ -41,6 +41,13 @@ export async function deleteFavorite(favorite: string | mongo.ObjectID | IFavori
}); });
} }
export const packMany = async (
favorites: any[],
me: any
) => {
return (await Promise.all(favorites.map(f => pack(f, me)))).filter(x => x != null);
};
/** /**
* Pack a favorite for API response * Pack a favorite for API response
*/ */
@@ -70,5 +77,11 @@ export const pack = (
// Populate note // Populate note
_favorite.note = await packNote(_favorite.noteId, me); _favorite.note = await packNote(_favorite.noteId, me);
// (データベースの不具合などで)投稿が見つからなかったら
if (_favorite.note == null) {
console.warn(`in packaging favorite: note not found on database: ${_favorite.noteId}`);
return resolve(null);
}
resolve(_favorite); resolve(_favorite);
}); });

View File

@@ -7,7 +7,7 @@ import { IUser, pack as packUser } from './user';
import { pack as packApp } from './app'; import { pack as packApp } from './app';
import PollVote, { deletePollVote } from './poll-vote'; import PollVote, { deletePollVote } from './poll-vote';
import Reaction, { deleteNoteReaction } from './note-reaction'; import Reaction, { deleteNoteReaction } from './note-reaction';
import { pack as packFile, IDriveFile } from './drive-file'; import { packMany as packFileMany, IDriveFile } from './drive-file';
import NoteWatching, { deleteNoteWatching } from './note-watching'; import NoteWatching, { deleteNoteWatching } from './note-watching';
import NoteReaction from './note-reaction'; import NoteReaction from './note-reaction';
import Favorite, { deleteFavorite } from './favorite'; import Favorite, { deleteFavorite } from './favorite';
@@ -226,6 +226,17 @@ export const hideNote = async (packedNote: any, meId: mongo.ObjectID) => {
} }
}; };
export const packMany = async (
notes: (string | mongo.ObjectID | INote)[],
me?: string | mongo.ObjectID | IUser,
options?: {
detail?: boolean;
skipHide?: boolean;
}
) => {
return (await Promise.all(notes.map(n => pack(n, me, options)))).filter(x => x != null);
};
/** /**
* Pack a note for API response * Pack a note for API response
* *
@@ -271,7 +282,11 @@ export const pack = async (
_note = deepcopy(note); _note = deepcopy(note);
} }
if (!_note) throw `invalid note arg ${note}`; // 投稿がデータベース上に見つからなかったとき
if (_note == null) {
console.warn(`note not found on database: ${note}`);
return null;
}
const id = _note._id; const id = _note._id;
@@ -294,9 +309,7 @@ export const pack = async (
} }
// Populate files // Populate files
_note.files = Promise.all((_note.fileIds || []).map((fileId: mongo.ObjectID) => _note.files = packFileMany(_note.fileIds || []);
packFile(fileId)
));
// 後方互換性のため // 後方互換性のため
_note.mediaIds = _note.fileIds; _note.mediaIds = _note.fileIds;
@@ -365,6 +378,12 @@ export const pack = async (
// resolve promises in _note object // resolve promises in _note object
_note = await rap(_note); _note = await rap(_note);
// (データベースの欠損などで)ユーザーがデータベース上に見つからなかったとき
if (_note.user == null) {
console.warn(`in packaging note: note user not found on database: note(${_note.id})`);
return null;
}
if (_note.user.isCat && _note.text) { if (_note.user.isCat && _note.text) {
_note.text = _note.text.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ'); _note.text = _note.text.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ');
} }

View File

@@ -77,6 +77,12 @@ export async function deleteNotification(notification: string | mongo.ObjectID |
}); });
} }
export const packMany = async (
notifications: any[]
) => {
return (await Promise.all(notifications.map(n => pack(n)))).filter(x => x != null);
};
/** /**
* Pack a notification for API response * Pack a notification for API response
*/ */
@@ -123,6 +129,12 @@ export const pack = (notification: any) => new Promise<any>(async (resolve, reje
case 'poll_vote': case 'poll_vote':
// Populate note // Populate note
_notification.note = await packNote(_notification.noteId, me); _notification.note = await packNote(_notification.noteId, me);
// (データベースの不具合などで)投稿が見つからなかったら
if (_notification.note == null) {
console.warn(`in packaging notification: note not found on database: ${_notification.noteId}`);
return resolve(null);
}
break; break;
default: default:
console.error(`Unknown type: ${_notification.type}`); console.error(`Unknown type: ${_notification.type}`);

View File

@@ -3,7 +3,7 @@ const deepcopy = require('deepcopy');
const sequential = require('promise-sequential'); const sequential = require('promise-sequential');
import rap from '@prezzemolo/rap'; import rap from '@prezzemolo/rap';
import db from '../db/mongodb'; import db from '../db/mongodb';
import Note, { pack as packNote, deleteNote } from './note'; import Note, { packMany as packNoteMany, deleteNote } from './note';
import Following, { deleteFollowing } from './following'; import Following, { deleteFollowing } from './following';
import Mute, { deleteMute } from './mute'; import Mute, { deleteMute } from './mute';
import { getFriendIds } from '../server/api/common/get-friends'; import { getFriendIds } from '../server/api/common/get-friends';
@@ -361,9 +361,11 @@ export const pack = (
_user = deepcopy(user); _user = deepcopy(user);
} }
// TODO: ここでエラーにするのではなくダミーのユーザーデータを返す // (データベースの欠損などで)ユーザーデータベース上に見つからなかったとき
// SEE: https://github.com/syuilo/misskey/issues/1432 if (_user == null) {
if (!_user) return reject('invalid user arg.'); console.warn(`user not found on database: ${user}`);
return null;
}
// Me // Me
const meId: mongo.ObjectID = me const meId: mongo.ObjectID = me
@@ -468,9 +470,9 @@ export const pack = (
if (opts.detail) { if (opts.detail) {
if (_user.pinnedNoteIds) { if (_user.pinnedNoteIds) {
// Populate pinned notes // Populate pinned notes
_user.pinnedNotes = Promise.all(_user.pinnedNoteIds.map((id: mongo.ObjectId) => packNote(id, meId, { _user.pinnedNotes = packNoteMany(_user.pinnedNoteIds, meId, {
detail: true detail: true
}))); });
} }
if (meId && !meId.equals(_user.id)) { if (meId && !meId.equals(_user.id)) {

View File

@@ -7,19 +7,18 @@ export default async (job: bq.Job, done: any): Promise<void> => {
await request(job.data.user, job.data.to, job.data.content); await request(job.data.user, job.data.to, job.data.content);
done(); done();
} catch (res) { } catch (res) {
if (res == null || !res.hasOwnProperty('statusCode')) { if (res != null && res.hasOwnProperty('statusCode')) {
console.warn(`deliver failed (unknown): ${res}`); if (res.statusCode >= 400 && res.statusCode < 500) {
return done(); // HTTPステータスコード4xxはクライアントエラーであり、それはつまり
} // 何回再送しても成功することはないということなのでエラーにはしないでおく
done();
if (res.statusCode == null) return done(); } else {
if (res.statusCode >= 400 && res.statusCode < 500) { console.warn(`deliver failed: ${res.statusCode} ${res.statusMessage} to=${job.data.to}`);
// HTTPステータスコード4xxはクライアントエラーであり、それはつまり done(res.statusMessage);
// 何回再送しても成功することはないということなのでエラーにはしないでおく }
done();
} else { } else {
console.warn(`deliver failed: ${res.statusMessage}`); console.warn(`deliver failed: ${res} to=${job.data.to}`);
done(res.statusMessage); done();
} }
} }
}; };

View File

@@ -12,6 +12,8 @@ const log = debug('misskey:activitypub:deliver');
export default (user: ILocalUser, url: string, object: any) => new Promise((resolve, reject) => { export default (user: ILocalUser, url: string, object: any) => new Promise((resolve, reject) => {
log(`--> ${url}`); log(`--> ${url}`);
const timeout = 10 * 1000;
const { protocol, hostname, port, pathname, search } = new URL(url); const { protocol, hostname, port, pathname, search } = new URL(url);
const data = JSON.stringify(object); const data = JSON.stringify(object);
@@ -26,6 +28,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso
port, port,
method: 'POST', method: 'POST',
path: pathname + search, path: pathname + search,
timeout,
headers: { headers: {
'User-Agent': config.user_agent, 'User-Agent': config.user_agent,
'Content-Type': 'application/activity+json', 'Content-Type': 'application/activity+json',
@@ -35,7 +38,7 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso
log(`${url} --> ${res.statusCode}`); log(`${url} --> ${res.statusCode}`);
if (res.statusCode >= 400) { if (res.statusCode >= 400) {
reject(); reject(res);
} else { } else {
resolve(); resolve();
} }
@@ -53,5 +56,12 @@ export default (user: ILocalUser, url: string, object: any) => new Promise((reso
sig = sig.replace(/^Signature /, ''); sig = sig.replace(/^Signature /, '');
req.setHeader('Signature', sig); req.setHeader('Signature', sig);
req.on('timeout', () => req.abort());
req.on('error', e => {
if (req.aborted) reject('timeout');
reject(e);
});
req.end(data); req.end(data);
}); });

View File

@@ -7,6 +7,7 @@ const log = debug('misskey:activitypub:resolver');
export default class Resolver { export default class Resolver {
private history: Set<string>; private history: Set<string>;
private timeout = 10 * 1000;
constructor() { constructor() {
this.history = new Set(); this.history = new Set();
@@ -50,6 +51,7 @@ export default class Resolver {
const object = await request({ const object = await request({
url: value, url: value,
timeout: this.timeout,
headers: { headers: {
'User-Agent': config.user_agent, 'User-Agent': config.user_agent,
Accept: 'application/activity+json, application/ld+json' Accept: 'application/activity+json, application/ld+json'

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import DriveFile, { pack } from '../../../../models/drive-file'; import DriveFile, { packMany } from '../../../../models/drive-file';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
export const meta = { export const meta = {
@@ -73,6 +73,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
const _files = await Promise.all(files.map(file => pack(file))); return await packMany(files);
return _files;
}; };

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import DriveFile, { pack } from '../../../../models/drive-file'; import DriveFile, { packMany } from '../../../../models/drive-file';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
export const meta = { export const meta = {
@@ -63,5 +63,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
}); });
// Serialize // Serialize
res(await Promise.all(files.map(file => pack(file)))); res(await packMany(files));
}); });

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Favorite, { pack } from '../../../../models/favorite'; import Favorite, { packMany } from '../../../../models/favorite';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
export const meta = { export const meta = {
@@ -55,5 +55,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
.find(query, { limit, sort }); .find(query, { limit, sort });
// Serialize // Serialize
res(await Promise.all(favorites.map(favorite => pack(favorite, user)))); res(await packMany(favorites, user));
}); });

View File

@@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Notification from '../../../../models/notification'; import Notification from '../../../../models/notification';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { pack } from '../../../../models/notification'; import { packMany } from '../../../../models/notification';
import { getFriendIds } from '../../common/get-friends'; import { getFriendIds } from '../../common/get-friends';
import read from '../../common/read-notification'; import read from '../../common/read-notification';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
@@ -83,7 +83,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
}); });
// Serialize // Serialize
res(await Promise.all(notifications.map(notification => pack(notification)))); res(await packMany(notifications));
// Mark all as read // Mark all as read
if (notifications.length > 0 && markAsRead) { if (notifications.length > 0 && markAsRead) {

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../misc/cafy-id';
import Note, { pack } from '../../../models/note'; import Note, { packMany } from '../../../models/note';
import getParams from '../get-params'; import getParams from '../get-params';
export const meta = { export const meta = {
@@ -116,5 +116,5 @@ export default (params: any) => new Promise(async (res, rej) => {
}); });
// Serialize // Serialize
res(await Promise.all(notes.map(note => pack(note)))); res(await packMany(notes));
}); });

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note, { pack, INote } from '../../../../models/note'; import Note, { packMany, INote } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
/** /**
@@ -52,5 +52,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
} }
// Serialize // Serialize
res(await Promise.all(conversation.map(note => pack(note, user)))); res(await packMany(conversation, user));
}); });

View File

@@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array'; import { countIf } from '../../../../prelude/array';
@@ -113,5 +113,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
return await Promise.all(timeline.map(note => pack(note, user))); return await packMany(timeline, user);
}; };

View File

@@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { getFriends } from '../../common/get-friends'; import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array'; import { countIf } from '../../../../prelude/array';
@@ -240,5 +240,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
return await Promise.all(timeline.map(note => pack(note, user))); return await packMany(timeline, user);
}; };

View File

@@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array'; import { countIf } from '../../../../prelude/array';
@@ -141,5 +141,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
return await Promise.all(timeline.map(note => pack(note, user))); return await packMany(timeline, user);
}; };

View File

@@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import { getFriendIds } from '../../common/get-friends'; import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import read from '../../../../services/note/read'; import read from '../../../../services/note/read';
@@ -89,5 +89,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
mentions.forEach(note => read(user._id, note._id)); mentions.forEach(note => read(user._id, note._id));
// Serialize // Serialize
res(await Promise.all(mentions.map(mention => pack(mention, user)))); res(await packMany(mentions, user));
}); });

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note, { pack } from '../../../../models/note'; import Note, { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
/** /**
@@ -30,5 +30,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
const ids = (note._replyIds || []).slice(offset, offset + limit); const ids = (note._replyIds || []).slice(offset, offset + limit);
// Serialize // Serialize
res(await Promise.all(ids.map(id => pack(id, user)))); res(await packMany(ids, user));
}); });

View File

@@ -1,5 +1,5 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note, { pack } from '../../../../models/note'; import Note, { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
/** /**
@@ -62,6 +62,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
}); });
// Serialize // Serialize
res(await Promise.all(renotes.map(async note => res(await packMany(renotes, user));
await pack(note, user))));
}); });

View File

@@ -2,7 +2,7 @@ import $ from 'cafy';
import * as mongo from 'mongodb'; import * as mongo from 'mongodb';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import es from '../../../../db/elasticsearch'; import es from '../../../../db/elasticsearch';
export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => { export default (params: any, me: ILocalUser) => new Promise(async (res, rej) => {
@@ -60,6 +60,6 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
} }
}); });
res(await Promise.all(notes.map(note => pack(note, me)))); res(await packMany(notes, me));
}); });
}); });

View File

@@ -3,7 +3,7 @@ import Note from '../../../../models/note';
import User, { ILocalUser } from '../../../../models/user'; import User, { ILocalUser } from '../../../../models/user';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { getFriendIds } from '../../common/get-friends'; import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { erase } from '../../../../prelude/array'; import { erase } from '../../../../prelude/array';
@@ -363,5 +363,5 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
}); });
// Serialize // Serialize
res(await Promise.all(notes.map(note => pack(note, me)))); res(await packMany(notes, me));
}); });

View File

@@ -2,7 +2,7 @@ import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { getFriends } from '../../common/get-friends'; import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array'; import { countIf } from '../../../../prelude/array';
@@ -237,5 +237,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
return await Promise.all(timeline.map(note => pack(note, user))); return await packMany(timeline, user);
}; };

View File

@@ -1,7 +1,7 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import Note from '../../../../models/note'; import Note from '../../../../models/note';
import Mute from '../../../../models/mute'; import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note'; import { packMany } from '../../../../models/note';
import UserList from '../../../../models/user-list'; import UserList from '../../../../models/user-list';
import { ILocalUser } from '../../../../models/user'; import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
@@ -242,5 +242,5 @@ export default async (params: any, user: ILocalUser) => {
}); });
// Serialize // Serialize
return await Promise.all(timeline.map(note => pack(note, user))); return await packMany(timeline, user);
}; };

View File

@@ -1,6 +1,6 @@
import $ from 'cafy'; import ID from '../../../../misc/cafy-id'; import $ from 'cafy'; import ID from '../../../../misc/cafy-id';
import getHostLower from '../../common/get-host-lower'; import getHostLower from '../../common/get-host-lower';
import Note, { pack } from '../../../../models/note'; import Note, { packMany } from '../../../../models/note';
import User, { ILocalUser } from '../../../../models/user'; import User, { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params'; import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array'; import { countIf } from '../../../../prelude/array';
@@ -181,5 +181,5 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
}); });
// Serialize // Serialize
res(await Promise.all(notes.map(note => pack(note, me)))); res(await packMany(notes, me));
}); });