1
0
forked from mirror/misskey
misskey/src/models/note.ts

410 lines
9.3 KiB
TypeScript
Raw Normal View History

2017-09-08 04:13:01 +09:00
import * as mongo from 'mongodb';
import * as deepcopy from 'deepcopy';
2018-02-02 08:06:01 +09:00
import rap from '@prezzemolo/rap';
import db from '../db/mongodb';
2018-10-16 11:38:09 +09:00
import isObjectId from '../misc/is-objectid';
import { length } from 'stringz';
2018-02-02 08:06:01 +09:00
import { IUser, pack as packUser } from './user';
import { pack as packApp } from './app';
import PollVote from './poll-vote';
import Reaction from './note-reaction';
import { packMany as packFileMany, IDriveFile } from './drive-file';
2018-04-29 04:30:51 +09:00
import Following from './following';
import Emoji from './emoji';
import { dbLogger } from '../db/logger';
2018-02-02 08:06:01 +09:00
2018-04-08 02:30:37 +09:00
const Note = db.get<INote>('notes');
Note.createIndex('uri', { sparse: true, unique: true });
Note.createIndex('userId');
Note.createIndex('mentions');
Note.createIndex('visibleUserIds');
2018-11-23 23:12:28 +09:00
Note.createIndex('replyId');
2018-06-16 15:23:03 +09:00
Note.createIndex('tagsLower');
2018-10-25 07:04:15 +09:00
Note.createIndex('_user.host');
2018-09-25 21:09:38 +09:00
Note.createIndex('_files._id');
2018-09-05 19:32:46 +09:00
Note.createIndex('_files.contentType');
2018-10-25 07:04:15 +09:00
Note.createIndex({ createdAt: -1 });
Note.createIndex({ score: -1 }, { sparse: true });
2018-04-08 02:30:37 +09:00
export default Note;
2017-03-02 03:16:39 +09:00
2018-03-30 11:24:07 +09:00
export function isValidCw(text: string): boolean {
return length(text.trim()) <= 100;
2018-03-30 11:24:07 +09:00
}
2018-04-08 02:30:37 +09:00
export type INote = {
2017-09-08 04:13:01 +09:00
_id: mongo.ObjectID;
2018-03-29 14:48:47 +09:00
createdAt: Date;
deletedAt: Date;
updatedAt?: Date;
2018-09-05 19:32:46 +09:00
fileIds: mongo.ObjectID[];
2018-03-29 14:48:47 +09:00
replyId: mongo.ObjectID;
2018-04-08 02:30:37 +09:00
renoteId: mongo.ObjectID;
poll: IPoll;
2017-09-08 04:13:01 +09:00
text: string;
2018-04-01 18:07:29 +09:00
tags: string[];
2018-06-16 15:23:03 +09:00
tagsLower: string[];
emojis: string[];
2018-03-30 11:24:07 +09:00
cw: string;
2018-03-29 14:48:47 +09:00
userId: mongo.ObjectID;
appId: mongo.ObjectID;
viaMobile: boolean;
localOnly: boolean;
2018-04-08 02:30:37 +09:00
renoteCount: number;
2018-03-29 14:48:47 +09:00
repliesCount: number;
reactionCounts: Record<string, number>;
2018-03-29 14:48:47 +09:00
mentions: mongo.ObjectID[];
mentionedRemoteUsers: {
2018-06-13 05:11:55 +09:00
uri: string;
username: string;
host: string;
}[];
2018-04-28 17:25:56 +09:00
/**
* public ...
* home ... ()
* followers ...
2018-04-29 04:30:51 +09:00
* specified ... visibleUserIds
2018-04-28 17:25:56 +09:00
*/
2018-12-29 02:55:46 +09:00
visibility: 'public' | 'home' | 'followers' | 'specified';
2018-04-29 04:30:51 +09:00
visibleUserIds: mongo.ObjectID[];
2018-04-28 17:25:56 +09:00
2018-03-05 08:44:37 +09:00
geo: {
2018-03-29 15:23:15 +09:00
coordinates: number[];
2018-03-05 08:44:37 +09:00
altitude: number;
accuracy: number;
altitudeAccuracy: number;
heading: number;
speed: number;
};
2018-10-25 07:04:15 +09:00
2018-04-03 23:45:13 +09:00
uri: string;
2018-04-06 04:04:50 +09:00
2018-10-25 07:04:15 +09:00
/**
* 稿
*/
score: number;
2018-04-19 12:43:25 +09:00
// 非正規化
2018-04-06 04:04:50 +09:00
_reply?: {
userId: mongo.ObjectID;
};
2018-04-08 02:30:37 +09:00
_renote?: {
2018-04-06 04:04:50 +09:00
userId: mongo.ObjectID;
};
_user: {
host: string;
2018-04-19 12:43:25 +09:00
inbox?: string;
2018-04-06 04:04:50 +09:00
};
2018-09-05 19:32:46 +09:00
_files?: IDriveFile[];
2017-09-08 04:13:01 +09:00
};
2018-02-02 08:06:01 +09:00
export type IPoll = {
Enhance poll (#4409) * Start working * WIP: Enhance poll * Fix bug * Use `name` in voting note refs: https://github.com/syuilo/misskey/issues/4407#issuecomment-469057296 * Fix style * Refactor Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> * WIP: Update poll editor * Fix bug * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r * Fix typo * Better design * Beautify poll editor * Fix UI * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r262217524 * Add debug logging * Fix bug * Log deliver * fix vote * Update ap/show refs: https://github.com/syuilo/misskey/pull/4409#issuecomment-469652386 * Update poll view * Maybe done * Add tests * Fix path * Fix test * Fix test * Fix test * Fix expired check on AP * Update note.ts * Squashed commit of the following: commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Squashed commit of the following: commit ae696b1ed12568b27c27367ac5a77035c97c9a1f Author: mei23 <m@m544.net> Date: Wed Mar 6 06:11:17 2019 +0900 fix commit b735e354e7a9e64534c4f17d04ecbc65fb735c21 Author: mei23 <m@m544.net> Date: Wed Mar 6 06:08:33 2019 +0900 messge commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Fix typo * Update vote.ts * Update vote.ts * Update poll-editor.vue * Update tslint.json * Fix layout * Add note * Fix bug * Rename text key * 投票するときに投稿として扱わないように (#4425) * wip * 形式をMastodonと合わせた * Bye something * Use - instead of ~ * Redundancy * Yes! * Refactor * Use moment instead of Date * Fix indent * Refactor if (votes.length) は必要なさそう * Clean up * Bye Date * Clean * Fix timer is not displayed * Fix リモートから無期限pollにvoteできない * Fix vote actor
2019-03-06 22:55:47 +09:00
choices: IChoice[];
multiple?: boolean;
expiresAt?: Date;
};
export type IChoice = {
id: number;
text: string;
votes: number;
};
2018-09-10 02:43:16 +09:00
export const hideNote = async (packedNote: any, meId: mongo.ObjectID) => {
let hide = false;
2018-12-29 02:55:46 +09:00
// visibility が private かつ投稿者のIDが自分のIDではなかったら非表示(後方互換性のため)
2018-09-10 02:43:16 +09:00
if (packedNote.visibility == 'private' && (meId == null || !meId.equals(packedNote.userId))) {
hide = true;
}
// visibility が specified かつ自分が指定されていなかったら非表示
if (packedNote.visibility == 'specified') {
if (meId == null) {
hide = true;
} else if (meId.equals(packedNote.userId)) {
hide = false;
} else {
// 指定されているかどうか
2018-09-18 02:13:42 +09:00
const specified = packedNote.visibleUserIds.some((id: any) => meId.equals(id));
2018-09-10 02:43:16 +09:00
if (specified) {
hide = false;
} else {
hide = true;
}
}
}
// visibility が followers かつ自分が投稿者のフォロワーでなかったら非表示
if (packedNote.visibility == 'followers') {
if (meId == null) {
hide = true;
} else if (meId.equals(packedNote.userId)) {
hide = false;
} else if (packedNote.reply && meId.equals(packedNote.reply.userId)) {
// 自分の投稿に対するリプライ
hide = false;
} else if (packedNote.mentions && packedNote.mentions.some((id: any) => meId.equals(id))) {
// 自分へのメンション
hide = false;
2018-09-10 02:43:16 +09:00
} else {
// フォロワーかどうか
const following = await Following.findOne({
followeeId: packedNote.userId,
followerId: meId
});
if (following == null) {
hide = true;
} else {
hide = false;
}
}
}
if (hide) {
packedNote.fileIds = [];
packedNote.files = [];
packedNote.text = null;
packedNote.poll = null;
packedNote.cw = null;
packedNote.tags = [];
packedNote.geo = null;
packedNote.isHidden = true;
}
};
2018-10-31 11:22:49 +09:00
export const packMany = (
notes: (string | mongo.ObjectID | INote)[],
me?: string | mongo.ObjectID | IUser,
options?: {
detail?: boolean;
skipHide?: boolean;
}
) => {
2018-10-31 11:22:49 +09:00
return Promise.all(notes.map(n => pack(n, me, options)));
};
2018-02-02 08:06:01 +09:00
/**
2018-04-08 02:30:37 +09:00
* Pack a note for API response
2018-02-02 08:06:01 +09:00
*
2018-04-08 02:30:37 +09:00
* @param note target
2018-02-02 08:06:01 +09:00
* @param me? serializee
* @param options? serialize options
* @return response
*/
export const pack = async (
2018-04-08 02:30:37 +09:00
note: string | mongo.ObjectID | INote,
2018-02-02 08:06:01 +09:00
me?: string | mongo.ObjectID | IUser,
options?: {
2018-09-10 02:43:16 +09:00
detail?: boolean;
skipHide?: boolean;
2018-02-02 08:06:01 +09:00
}
) => {
2018-04-29 07:01:47 +09:00
const opts = Object.assign({
2018-09-10 02:43:16 +09:00
detail: true,
skipHide: false
2018-04-29 07:01:47 +09:00
}, options);
2018-02-02 08:06:01 +09:00
// Me
const meId: mongo.ObjectID = me
2018-10-16 11:38:09 +09:00
? isObjectId(me)
2018-02-02 08:06:01 +09:00
? me as mongo.ObjectID
: typeof me === 'string'
? new mongo.ObjectID(me)
: (me as IUser)._id
: null;
2018-04-08 02:30:37 +09:00
let _note: any;
2018-02-02 08:06:01 +09:00
2018-04-08 02:30:37 +09:00
// Populate the note if 'note' is ID
2018-10-16 11:38:09 +09:00
if (isObjectId(note)) {
2018-04-08 02:30:37 +09:00
_note = await Note.findOne({
_id: note
2018-02-02 08:06:01 +09:00
});
2018-04-08 02:30:37 +09:00
} else if (typeof note === 'string') {
_note = await Note.findOne({
_id: new mongo.ObjectID(note)
2018-02-02 08:06:01 +09:00
});
} else {
2018-04-08 02:30:37 +09:00
_note = deepcopy(note);
2018-02-02 08:06:01 +09:00
}
2018-10-11 02:19:21 +09:00
// (データベースの欠損などで)投稿がデータベース上に見つからなかったとき
if (_note == null) {
dbLogger.warn(`[DAMAGED DB] (missing) pkg: note :: ${note}`);
return null;
}
2018-02-02 08:06:01 +09:00
2018-04-08 02:30:37 +09:00
const id = _note._id;
2018-02-02 08:06:01 +09:00
// _note._userを消す前か、_note.userを解決した後でないとホストがわからない
if (_note._user) {
const host = _note._user.host;
// 互換性のため。(古いMisskeyではNoteにemojisが無い)
if (_note.emojis == null) {
_note.emojis = Emoji.find({
host: host
}, {
fields: { _id: false }
});
} else {
_note.emojis = Emoji.find({
name: { $in: _note.emojis },
host: host
}, {
fields: { _id: false }
});
}
}
2018-02-02 08:06:01 +09:00
// Rename _id to id
2018-04-08 02:30:37 +09:00
_note.id = _note._id;
delete _note._id;
2018-02-02 08:06:01 +09:00
2018-10-08 01:25:34 +09:00
delete _note.prev;
delete _note.next;
delete _note.tagsLower;
2018-10-25 07:04:15 +09:00
delete _note.score;
2018-04-29 07:01:47 +09:00
delete _note._user;
delete _note._reply;
2018-09-19 14:18:34 +09:00
delete _note._renote;
delete _note._files;
2018-11-23 23:12:28 +09:00
delete _note._replyIds;
2019-02-02 13:50:41 +09:00
delete _note.mentionedRemoteUsers;
2018-11-23 23:12:28 +09:00
2018-04-08 02:30:37 +09:00
if (_note.geo) delete _note.geo.type;
2018-02-02 08:06:01 +09:00
// Populate user
_note.user = packUser(_note.userId, meId);
2018-02-02 08:06:01 +09:00
// Populate app
2018-04-08 02:30:37 +09:00
if (_note.appId) {
_note.app = packApp(_note.appId);
2018-02-02 08:06:01 +09:00
}
2018-09-05 19:32:46 +09:00
// Populate files
_note.files = packFileMany(_note.fileIds || []);
2018-02-02 08:06:01 +09:00
2018-12-29 02:04:29 +09:00
// Some counts
_note.renoteCount = _note.renoteCount || 0;
_note.repliesCount = _note.repliesCount || 0;
_note.reactionCounts = _note.reactionCounts || {};
2018-09-05 19:32:46 +09:00
// 後方互換性のため
_note.mediaIds = _note.fileIds;
_note.media = _note.files;
2018-04-08 02:30:37 +09:00
// When requested a detailed note data
2018-02-02 08:06:01 +09:00
if (opts.detail) {
2018-04-08 02:30:37 +09:00
if (_note.replyId) {
// Populate reply to note
_note.reply = pack(_note.replyId, meId, {
2018-02-02 08:06:01 +09:00
detail: false
});
}
2018-04-08 02:30:37 +09:00
if (_note.renoteId) {
// Populate renote
_note.renote = pack(_note.renoteId, meId, {
detail: _note.text == null
2018-02-02 08:06:01 +09:00
});
}
// Poll
2018-09-10 02:43:16 +09:00
if (meId && _note.poll) {
2018-06-12 18:54:36 +09:00
_note.poll = (async poll => {
Enhance poll (#4409) * Start working * WIP: Enhance poll * Fix bug * Use `name` in voting note refs: https://github.com/syuilo/misskey/issues/4407#issuecomment-469057296 * Fix style * Refactor Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> * WIP: Update poll editor * Fix bug * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r * Fix typo * Better design * Beautify poll editor * Fix UI * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r262217524 * Add debug logging * Fix bug * Log deliver * fix vote * Update ap/show refs: https://github.com/syuilo/misskey/pull/4409#issuecomment-469652386 * Update poll view * Maybe done * Add tests * Fix path * Fix test * Fix test * Fix test * Fix expired check on AP * Update note.ts * Squashed commit of the following: commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Squashed commit of the following: commit ae696b1ed12568b27c27367ac5a77035c97c9a1f Author: mei23 <m@m544.net> Date: Wed Mar 6 06:11:17 2019 +0900 fix commit b735e354e7a9e64534c4f17d04ecbc65fb735c21 Author: mei23 <m@m544.net> Date: Wed Mar 6 06:08:33 2019 +0900 messge commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Fix typo * Update vote.ts * Update vote.ts * Update poll-editor.vue * Update tslint.json * Fix layout * Add note * Fix bug * Rename text key * 投票するときに投稿として扱わないように (#4425) * wip * 形式をMastodonと合わせた * Bye something * Use - instead of ~ * Redundancy * Yes! * Refactor * Use moment instead of Date * Fix indent * Refactor if (votes.length) は必要なさそう * Clean up * Bye Date * Clean * Fix timer is not displayed * Fix リモートから無期限pollにvoteできない * Fix vote actor
2019-03-06 22:55:47 +09:00
if (poll.multiple) {
const votes = await PollVote.find({
userId: meId,
noteId: id
});
const myChoices = (poll.choices as IChoice[]).filter(x => votes.some(y => x.id == y.choice));
for (const myChoice of myChoices) {
(myChoice as any).isVoted = true;
}
return poll;
} else {
poll.multiple = false;
}
2018-04-15 06:34:55 +09:00
const vote = await PollVote
2018-02-02 08:06:01 +09:00
.findOne({
2018-03-29 14:48:47 +09:00
userId: meId,
2018-04-08 02:30:37 +09:00
noteId: id
2018-02-02 08:06:01 +09:00
});
Enhance poll (#4409) * Start working * WIP: Enhance poll * Fix bug * Use `name` in voting note refs: https://github.com/syuilo/misskey/issues/4407#issuecomment-469057296 * Fix style * Refactor Co-authored-by: MeiMei <30769358+mei23@users.noreply.github.com> * WIP: Update poll editor * Fix bug * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r * Fix typo * Better design * Beautify poll editor * Fix UI * Fix bug refs: https://github.com/syuilo/misskey/pull/4409#discussion_r262217524 * Add debug logging * Fix bug * Log deliver * fix vote * Update ap/show refs: https://github.com/syuilo/misskey/pull/4409#issuecomment-469652386 * Update poll view * Maybe done * Add tests * Fix path * Fix test * Fix test * Fix test * Fix expired check on AP * Update note.ts * Squashed commit of the following: commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Squashed commit of the following: commit ae696b1ed12568b27c27367ac5a77035c97c9a1f Author: mei23 <m@m544.net> Date: Wed Mar 6 06:11:17 2019 +0900 fix commit b735e354e7a9e64534c4f17d04ecbc65fb735c21 Author: mei23 <m@m544.net> Date: Wed Mar 6 06:08:33 2019 +0900 messge commit d9a4beabf851893b8992a0f4568265eb9d4f0b8e Author: mei23 <m@m544.net> Date: Wed Mar 6 05:16:14 2019 +0900 tune commit 83ff421a6e978243f80ba9ec820189bc897e6e3b Author: mei23 <m@m544.net> Date: Wed Mar 6 05:01:14 2019 +0900 fallback commit 0b566af973b115ade9e75ea4b8094ee2b329dabc Author: mei23 <m@m544.net> Date: Wed Mar 6 04:40:12 2019 +0900 Note commit cc0296dd6127580ac584c40398db3f762a311f8b Author: mei23 <m@m544.net> Date: Wed Mar 6 04:33:58 2019 +0900 createで送る * Fix typo * Update vote.ts * Update vote.ts * Update poll-editor.vue * Update tslint.json * Fix layout * Add note * Fix bug * Rename text key * 投票するときに投稿として扱わないように (#4425) * wip * 形式をMastodonと合わせた * Bye something * Use - instead of ~ * Redundancy * Yes! * Refactor * Use moment instead of Date * Fix indent * Refactor if (votes.length) は必要なさそう * Clean up * Bye Date * Clean * Fix timer is not displayed * Fix リモートから無期限pollにvoteできない * Fix vote actor
2019-03-06 22:55:47 +09:00
if (vote) {
const myChoice = (poll.choices as IChoice[])
.filter(x => x.id == vote.choice)[0] as any;
2018-02-02 08:06:01 +09:00
2018-03-29 14:48:47 +09:00
myChoice.isVoted = true;
2018-02-02 08:06:01 +09:00
}
return poll;
2018-04-08 02:30:37 +09:00
})(_note.poll);
2018-02-02 08:06:01 +09:00
}
if (meId) {
// Fetch my reaction
2018-04-08 02:30:37 +09:00
_note.myReaction = (async () => {
2018-02-02 08:06:01 +09:00
const reaction = await Reaction
.findOne({
2018-03-29 14:48:47 +09:00
userId: meId,
2018-04-08 02:30:37 +09:00
noteId: id,
2018-03-29 14:48:47 +09:00
deletedAt: { $exists: false }
2018-02-02 08:06:01 +09:00
});
if (reaction) {
return reaction.reaction;
}
return null;
})();
}
}
2018-04-08 02:30:37 +09:00
// resolve promises in _note object
_note = await rap(_note);
2018-02-02 08:06:01 +09:00
2018-10-11 02:11:12 +09:00
//#region (データベースの欠損などで)参照しているデータがデータベース上に見つからなかったとき
if (_note.user == null) {
dbLogger.warn(`[DAMAGED DB] (missing) pkg: note -> user :: ${_note.id} (user ${_note.userId})`);
return null;
}
2018-10-11 17:00:22 +09:00
if (opts.detail) {
if (_note.replyId != null && _note.reply == null) {
dbLogger.warn(`[DAMAGED DB] (missing) pkg: note -> reply :: ${_note.id} (reply ${_note.replyId})`);
2018-10-11 17:00:22 +09:00
return null;
}
2018-10-11 02:11:12 +09:00
2018-10-11 17:00:22 +09:00
if (_note.renoteId != null && _note.renote == null) {
dbLogger.warn(`[DAMAGED DB] (missing) pkg: note -> renote :: ${_note.id} (renote ${_note.renoteId})`);
2018-10-11 17:00:22 +09:00
return null;
}
2018-10-11 02:11:12 +09:00
}
//#endregion
2018-05-21 11:08:08 +09:00
if (_note.user.isCat && _note.text) {
_note.text = (_note.text
// ja-JP
.replace(/な/g, 'にゃ').replace(/ナ/g, 'ニャ').replace(/ナ/g, 'ニャ')
// ko-KR
.replace(/[나-낳]/g, (match: string) => String.fromCharCode(
match.codePointAt(0) + '냐'.charCodeAt(0) - '나'.charCodeAt(0)
))
);
2018-05-21 11:08:08 +09:00
}
2018-09-10 02:43:16 +09:00
if (!opts.skipHide) {
await hideNote(_note, meId);
2018-04-29 04:51:19 +09:00
}
2018-04-08 02:30:37 +09:00
return _note;
2018-02-02 08:06:01 +09:00
};