Compare commits

...

29 Commits
9.2.0 ... 9.6.0

Author SHA1 Message Date
baf9b65801 Improve error handling of packaging functions 2018-10-05 01:43:47 +09:00
401d0b1298 9.5.0 2018-10-04 13:55:25 +09:00
fce7dc0f4e Improve error handling of pack function of notification 2018-10-04 13:53:48 +09:00
35489ef5b7 Improve default theme definition (dark) 2018-10-04 13:48:26 +09:00
546d494587 Improve default theme definition (light) 2018-10-04 13:40:13 +09:00
e8afa2c940 Improve pack function of favorite 2018-10-04 13:33:59 +09:00
c1ef1bf605 fix(package): update typescript-eslint-parser to version 19.0.2 (#2819)
Closes #2772
2018-10-04 12:53:50 +09:00
4ab0dbe7e3 fix(package): update @types/webpack to version 4.4.14 (#2818)
Closes #2778
2018-10-04 12:53:17 +09:00
44f86a94f4 fix(package): update @types/node to version 10.11.4 (#2817)
Closes #2765
2018-10-04 12:52:57 +09:00
a0278154a3 fix(package): update webpack-cli to version 3.1.2 (#2816)
Closes #2757
2018-10-04 12:52:27 +09:00
8b7e6b200e fix(package): update jsdom to version 12.1.0 (#2788) 2018-10-04 12:51:19 +09:00
d6f6c26725 fix(package): update @types/qrcode to version 1.3.0 (#2813) 2018-10-04 12:50:32 +09:00
cf66343b31 fix(package): update qrcode to version 1.3.0 (#2799) 2018-10-04 12:50:25 +09:00
d53689332f fix(package): update diskusage to version 0.2.5 (#2767) 2018-10-04 12:49:56 +09:00
4105237027 fix(package): update koa-mount to version 4.0.0 (#2776) 2018-10-04 12:49:38 +09:00
436962e4b8 fix(package): update nan to version 2.11.1 (#2784) 2018-10-04 12:49:05 +09:00
a85efa1392 fix(package): update gulp-htmlmin to version 5.0.1 (#2815)
Closes #2669
2018-10-04 12:48:52 +09:00
f0115a5e21 fix(package): update webpack to version 4.20.2 (#2814)
Closes #2768
2018-10-04 12:45:47 +09:00
80105239dc 9.4.0 2018-10-04 00:39:48 +09:00
baad11288a ドキュメントが見つからなくてもエラーにせずnullを返すように 2018-10-04 00:39:11 +09:00
7e50646ede 9.3.1 2018-10-03 23:01:58 +09:00
d4b8e47bcb Fix 2018-10-03 23:01:47 +09:00
0eefd2922c 9.3.0 2018-10-03 22:55:08 +09:00
30c0f98691 Fix bug 2018-10-03 22:54:10 +09:00
06a7c2e138 Revert "Enable JSON5 syntax"
This reverts commit 6e04549a9b.
2018-10-03 22:14:05 +09:00
3537b3de8e Clean up 2018-10-03 22:05:17 +09:00
ed6450244d Feature flags feature (#2803) 2018-10-03 12:39:03 +09:00
e813880392 6個ピン留めできてしまうの修正 (#2804) 2018-10-03 12:37:23 +09:00
9a57efa6d9 ✌️ 2018-10-03 03:13:10 +09:00
33 changed files with 147 additions and 191 deletions

1
.gitattributes vendored
View File

@ -3,4 +3,3 @@
*.ai -diff -text *.ai -diff -text
yarn.lock -diff -text yarn.lock -diff -text
package-lock.json -diff -text package-lock.json -diff -text
*.json5 linguist-language=JavaScript

View File

@ -2,7 +2,6 @@
* Gulp tasks * Gulp tasks
*/ */
import * as fs from 'fs';
import * as gulp from 'gulp'; import * as gulp from 'gulp';
import * as gutil from 'gulp-util'; import * as gutil from 'gulp-util';
import * as ts from 'gulp-typescript'; import * as ts from 'gulp-typescript';
@ -166,9 +165,7 @@ gulp.task('build:client:pug', [
.pipe(pug({ .pipe(pug({
locals: { locals: {
themeColor: constants.themeColor, themeColor: constants.themeColor,
facss: fa.dom.css(), facss: fa.dom.css()
//hljscss: fs.readFileSync('./node_modules/highlight.js/styles/default.css', 'utf8')
hljscss: fs.readFileSync('./src/client/assets/code-highlight.css', 'utf8')
} }
})) }))
.pipe(htmlmin({ .pipe(htmlmin({

View File

@ -1,8 +1,8 @@
{ {
"name": "misskey", "name": "misskey",
"author": "syuilo <i@syuilo.com>", "author": "syuilo <i@syuilo.com>",
"version": "9.2.0", "version": "9.6.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

@ -34,9 +34,6 @@ html
//- FontAwesome style //- FontAwesome style
style #{facss} style #{facss}
//- highlight.js style
style #{hljscss}
body body
noscript: p noscript: p
| JavaScriptを有効にしてください | JavaScriptを有効にしてください

View File

@ -12,16 +12,6 @@ if (!('fetch' in window)) {
'To run Misskey, please update your browser to latest version or try other browsers.'); 'To run Misskey, please update your browser to latest version or try other browsers.');
} }
// Detect Edge
if (navigator.userAgent.toLowerCase().indexOf('edge') != -1) {
alert(
'現在、お使いのブラウザ(Microsoft Edge)ではMisskeyは正しく動作しません。' +
'サポートしているブラウザ: Google Chrome, Mozilla Firefox, Apple Safari など' +
'\n\n' +
'Currently, Misskey cannot run correctly on your browser (Microsoft Edge). ' +
'Supported browsers: Google Chrome, Mozilla Firefox, Apple Safari, etc');
}
// Check whether cookie enabled // Check whether cookie enabled
if (!navigator.cookieEnabled) { if (!navigator.cookieEnabled) {
alert( alert(

View File

@ -1,93 +0,0 @@
.hljs {
font-family: Consolas, 'Courier New', Courier, Monaco, monospace;
}
.hljs,
.hljs-subst {
color: #444;
}
.hljs-comment {
color: #888888;
}
.hljs-keyword {
color: #2973b7;
}
.hljs-number {
color: #ae81ff;
}
.hljs-string {
color: #e96900;
}
.hljs-regexp {
color: #e9003f;
}
.hljs-attribute,
.hljs-selector-tag,
.hljs-meta-keyword,
.hljs-doctag,
.hljs-name {
font-weight: bold;
}
.hljs-type,
.hljs-selector-id,
.hljs-selector-class,
.hljs-quote,
.hljs-template-tag,
.hljs-deletion {
color: #880000;
}
.hljs-title,
.hljs-section {
color: #880000;
font-weight: bold;
}
.hljs-symbol,
.hljs-variable,
.hljs-template-variable,
.hljs-link,
.hljs-selector-attr,
.hljs-selector-pseudo {
color: #BC6060;
}
/* Language color: hue: 90; */
.hljs-literal {
color: #78A960;
}
.hljs-built_in,
.hljs-bullet,
.hljs-code,
.hljs-addition {
color: #397300;
}
/* Meta color: hue: 200 */
.hljs-meta {
color: #1f7199;
}
.hljs-meta-string {
color: #4d99bf;
}
/* Misc effects */
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

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

@ -1,7 +1,7 @@
{ {
id: 'e9c8c01d-9c15-48d0-9b5c-3d00843b5b36', id: 'e9c8c01d-9c15-48d0-9b5c-3d00843b5b36',
name: 'Pink', name: 'Strawberry Milk',
author: 'syuilo', author: 'syuilo',
base: 'light', base: 'light',

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

@ -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

@ -39,6 +39,15 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null, recaptchaSitekey: config.recaptcha ? config.recaptcha.site_key : null,
swPublickey: config.sw ? config.sw.public_key : null, swPublickey: config.sw ? config.sw.public_key : null,
hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined, hidedTags: (me && me.isAdmin) ? meta.hidedTags : undefined,
bannerUrl: meta.bannerUrl bannerUrl: meta.bannerUrl,
features: {
registration: !meta.disableRegistration,
localTimeLine: !meta.disableLocalTimeline,
elasticsearch: config.elasticsearch ? true : false,
recaptcha: config.recaptcha ? true : false,
objectStorage: config.drive && config.drive.storage === 'minio',
twitter: config.twitter ? true : false,
serviceWorker: config.sw ? true : false
}
}); });
}); });

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));
}); });

View File

@ -26,7 +26,7 @@ export async function addPinned(user: IUser, noteId: mongo.ObjectID) {
const pinnedNoteIds = user.pinnedNoteIds || []; const pinnedNoteIds = user.pinnedNoteIds || [];
if (pinnedNoteIds.length > 5) { if (pinnedNoteIds.length >= 5) {
throw new Error('cannot pin more notes'); throw new Error('cannot pin more notes');
} }