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
yarn.lock -diff -text
package-lock.json -diff -text
*.json5 linguist-language=JavaScript

View File

@ -2,7 +2,6 @@
* Gulp tasks
*/
import * as fs from 'fs';
import * as gulp from 'gulp';
import * as gutil from 'gulp-util';
import * as ts from 'gulp-typescript';
@ -166,9 +165,7 @@ gulp.task('build:client:pug', [
.pipe(pug({
locals: {
themeColor: constants.themeColor,
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')
facss: fa.dom.css()
}
}))
.pipe(htmlmin({

View File

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

View File

@ -34,9 +34,6 @@ html
//- FontAwesome style
style #{facss}
//- highlight.js style
style #{hljscss}
body
noscript: p
| 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.');
}
// 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
if (!navigator.cookieEnabled) {
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)',
noteHeaderAdminFg: '#f15f71',
noteHeaderAdminBg: '#5d282e',
noteHeaderAcct: '#606984',
noteHeaderInfo: '#606984',
noteHeaderAcct: ':alpha<0.65<$text',
noteHeaderInfo: ':alpha<0.5<$text',
noteActions: '#606984',
noteActionsHover: '#a1a8bf',
noteActions: ':alpha<0.45<$text',
noteActionsHover: ':alpha<0.6<$text',
noteActionsReplyHover: '#0af',
noteActionsRenoteHover: '#8d0',
noteActionsReactionHover: '#fa0',
noteActionsHighlighted: '#707b97',
noteActionsHighlighted: ':alpha<0.7<$text',
noteAttachedFile: 'rgba(255, 255, 255, 0.1)',

View File

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

View File

@ -1,7 +1,7 @@
{
id: 'e9c8c01d-9c15-48d0-9b5c-3d00843b5b36',
name: 'Pink',
name: 'Strawberry Milk',
author: 'syuilo',
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
*/
@ -155,7 +164,11 @@ export const pack = (
_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
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
*/
@ -70,5 +77,11 @@ export const pack = (
// Populate note
_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);
});

View File

@ -7,7 +7,7 @@ import { IUser, pack as packUser } from './user';
import { pack as packApp } from './app';
import PollVote, { deletePollVote } from './poll-vote';
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 NoteReaction from './note-reaction';
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
*
@ -271,7 +282,11 @@ export const pack = async (
_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;
@ -294,9 +309,7 @@ export const pack = async (
}
// Populate files
_note.files = Promise.all(_note.fileIds.map((fileId: mongo.ObjectID) =>
packFile(fileId)
));
_note.files = packFileMany(_note.fileIds || []);
// 後方互換性のため
_note.mediaIds = _note.fileIds;
@ -365,6 +378,12 @@ export const pack = async (
// resolve promises in _note object
_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) {
_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
*/
@ -123,6 +129,12 @@ export const pack = (notification: any) => new Promise<any>(async (resolve, reje
case 'poll_vote':
// Populate note
_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;
default:
console.error(`Unknown type: ${_notification.type}`);

View File

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

View File

@ -1,5 +1,5 @@
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';
export const meta = {
@ -73,6 +73,5 @@ export default async (params: any, user: ILocalUser) => {
});
// Serialize
const _files = await Promise.all(files.map(file => pack(file)));
return _files;
return await packMany(files);
};

View File

@ -1,5 +1,5 @@
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';
export const meta = {
@ -63,5 +63,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
});
// 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 Favorite, { pack } from '../../../../models/favorite';
import Favorite, { packMany } from '../../../../models/favorite';
import { ILocalUser } from '../../../../models/user';
export const meta = {
@ -55,5 +55,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
.find(query, { limit, sort });
// 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 Notification from '../../../../models/notification';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/notification';
import { packMany } from '../../../../models/notification';
import { getFriendIds } from '../../common/get-friends';
import read from '../../common/read-notification';
import { ILocalUser } from '../../../../models/user';
@ -83,7 +83,7 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
});
// Serialize
res(await Promise.all(notifications.map(notification => pack(notification))));
res(await packMany(notifications));
// Mark all as read
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,
swPublickey: config.sw ? config.sw.public_key : null,
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 Note, { pack } from '../../../models/note';
import Note, { packMany } from '../../../models/note';
import getParams from '../get-params';
export const meta = {
@ -116,5 +116,5 @@ export default (params: any) => new Promise(async (res, rej) => {
});
// 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 Note, { pack, INote } from '../../../../models/note';
import Note, { packMany, INote } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
@ -52,5 +52,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
}
// 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 Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array';
@ -113,5 +113,5 @@ export default async (params: any, user: ILocalUser) => {
});
// 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 Mute from '../../../../models/mute';
import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array';
@ -240,5 +240,5 @@ export default async (params: any, user: ILocalUser) => {
});
// 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 Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array';
@ -141,5 +141,5 @@ export default async (params: any, user: ILocalUser) => {
});
// 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 Note from '../../../../models/note';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
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));
// 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 Note, { pack } from '../../../../models/note';
import Note, { packMany } from '../../../../models/note';
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);
// 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 Note, { pack } from '../../../../models/note';
import Note, { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
/**
@ -62,6 +62,5 @@ export default (params: any, user: ILocalUser) => new Promise(async (res, rej) =
});
// Serialize
res(await Promise.all(renotes.map(async note =>
await pack(note, user))));
res(await packMany(renotes, user));
});

View File

@ -2,7 +2,7 @@ import $ from 'cafy';
import * as mongo from 'mongodb';
import Note from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import es from '../../../../db/elasticsearch';
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 Mute from '../../../../models/mute';
import { getFriendIds } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import getParams from '../../get-params';
import { erase } from '../../../../prelude/array';
@ -363,5 +363,5 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
});
// 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 Mute from '../../../../models/mute';
import { getFriends } from '../../common/get-friends';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
import { countIf } from '../../../../prelude/array';
@ -237,5 +237,5 @@ export default async (params: any, user: ILocalUser) => {
});
// 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 Note from '../../../../models/note';
import Mute from '../../../../models/mute';
import { pack } from '../../../../models/note';
import { packMany } from '../../../../models/note';
import UserList from '../../../../models/user-list';
import { ILocalUser } from '../../../../models/user';
import getParams from '../../get-params';
@ -242,5 +242,5 @@ export default async (params: any, user: ILocalUser) => {
});
// 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 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 getParams from '../../get-params';
import { countIf } from '../../../../prelude/array';
@ -181,5 +181,5 @@ export default (params: any, me: ILocalUser) => new Promise(async (res, rej) =>
});
// 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 || [];
if (pinnedNoteIds.length > 5) {
if (pinnedNoteIds.length >= 5) {
throw new Error('cannot pin more notes');
}