summaryrefslogtreecommitdiff
path: root/src/models
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-11-04 03:32:20 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-11-04 03:32:20 +0900
commit84db15694d7223d6f46bae6340542b4c24e9bcb3 (patch)
tree1c180a37dfb9433298c6f146418002c6654f48d7 /src/models
parent[Client] Improve Emoji management page of admin panel (diff)
downloadsharkey-84db15694d7223d6f46bae6340542b4c24e9bcb3.tar.gz
sharkey-84db15694d7223d6f46bae6340542b4c24e9bcb3.tar.bz2
sharkey-84db15694d7223d6f46bae6340542b4c24e9bcb3.zip
Do not send needless emojis in note
投稿作成時に含まれている絵文字を保存しておくように SEE: https://github.com/syuilo/misskey/pull/3085#issuecomment-435608434
Diffstat (limited to 'src/models')
-rw-r--r--src/models/emoji.ts11
-rw-r--r--src/models/note.ts20
2 files changed, 18 insertions, 13 deletions
diff --git a/src/models/emoji.ts b/src/models/emoji.ts
index fdedd28513..8e75868e62 100644
--- a/src/models/emoji.ts
+++ b/src/models/emoji.ts
@@ -16,14 +16,3 @@ export type IEmoji = {
aliases?: string[];
updatedAt?: Date;
};
-
-export const packEmojis = async (
- host: string,
- // MeiTODO: filter
-) => {
- return await Emoji.find({ host }, {
- fields: {
- _id: false
- }
- });
-};
diff --git a/src/models/note.ts b/src/models/note.ts
index 684e8c3b1e..6856d6d07d 100644
--- a/src/models/note.ts
+++ b/src/models/note.ts
@@ -12,7 +12,7 @@ import { packMany as packFileMany, IDriveFile } from './drive-file';
import Favorite from './favorite';
import Following from './following';
import config from '../config';
-import { packEmojis } from './emoji';
+import Emoji from './emoji';
const Note = db.get<INote>('notes');
Note.createIndex('uri', { sparse: true, unique: true });
@@ -50,6 +50,7 @@ export type INote = {
text: string;
tags: string[];
tagsLower: string[];
+ emojis: string[];
cw: string;
userId: mongo.ObjectID;
appId: mongo.ObjectID;
@@ -231,7 +232,22 @@ export const pack = async (
// _note._userを消す前か、_note.userを解決した後でないとホストがわからない
if (_note._user) {
- _note.emojis = packEmojis(_note._user.host);
+ 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 }
+ });
+ }
}
// Rename _id to id