summaryrefslogtreecommitdiff
path: root/src/models/note.ts
diff options
context:
space:
mode:
authorMeiMei <30769358+mei23@users.noreply.github.com>2019-03-18 00:03:57 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2019-03-18 00:03:57 +0900
commit26845416932ecf0ce035240ce934d2afb77bf550 (patch)
tree41992508c56c9ac05c481f76af524f5a3f14ca31 /src/models/note.ts
parentChange default dark theme (diff)
downloadsharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.gz
sharkey-26845416932ecf0ce035240ce934d2afb77bf550.tar.bz2
sharkey-26845416932ecf0ce035240ce934d2afb77bf550.zip
Custom reaction (#4517)
* Custom reaction * increase limit of reactions/delete * リアクションの場合は OS標準の絵文字を使用 を迂回する * カスタムリアクションを無効にする設定 * fix * disableCustomReaction --> enableEmojiReaction * Avoid MFM rendering * :art: * :art: * Auto accept * custom emoji reaction * Improve usability * Extract emojiRegex * Fix * Clean up * :art: * :art: * toDbReaction で reaction は必須に あとフォールバックは like に * Clean up * Make required * https://github.com/syuilo/misskey/pull/4517/commits/3eb08748feeaab9ee5c5b505c870f97d7edbeb0d#r266241728 * Refactor * Allow null
Diffstat (limited to 'src/models/note.ts')
-rw-r--r--src/models/note.ts13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/models/note.ts b/src/models/note.ts
index 369a009162..af45ff966d 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -12,6 +12,7 @@ import { packMany as packFileMany, IDriveFile } from './drive-file';
import Following from './following';
import Emoji from './emoji';
import { dbLogger } from '../db/logger';
+import { unique, concat } from '../prelude/array';
const Note = db.get<INote>('notes');
Note.createIndex('uri', { sparse: true, unique: true });
@@ -242,6 +243,11 @@ export const pack = async (
const id = _note._id;
+ // Some counts
+ _note.renoteCount = _note.renoteCount || 0;
+ _note.repliesCount = _note.repliesCount || 0;
+ _note.reactionCounts = _note.reactionCounts || {};
+
// _note._userを消す前か、_note.userを解決した後でないとホストがわからない
if (_note._user) {
const host = _note._user.host;
@@ -253,6 +259,8 @@ export const pack = async (
fields: { _id: false }
});
} else {
+ _note.emojis = unique(concat([_note.emojis, Object.keys(_note.reactionCounts)]));
+
_note.emojis = Emoji.find({
name: { $in: _note.emojis },
host: host
@@ -290,11 +298,6 @@ export const pack = async (
// Populate files
_note.files = packFileMany(_note.fileIds || []);
- // Some counts
- _note.renoteCount = _note.renoteCount || 0;
- _note.repliesCount = _note.repliesCount || 0;
- _note.reactionCounts = _note.reactionCounts || {};
-
// 後方互換性のため
_note.mediaIds = _note.fileIds;
_note.media = _note.files;