From 26845416932ecf0ce035240ce934d2afb77bf550 Mon Sep 17 00:00:00 2001 From: MeiMei <30769358+mei23@users.noreply.github.com> Date: Mon, 18 Mar 2019 00:03:57 +0900 Subject: Custom reaction (#4517) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- src/models/note.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/models/note.ts') 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('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; -- cgit v1.2.3-freya