summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/CustomEmojiService.ts
diff options
context:
space:
mode:
authorMar0xy <marie@kaifa.ch>2023-10-13 19:01:17 +0200
committerMar0xy <marie@kaifa.ch>2023-10-13 19:01:17 +0200
commitf8f128b3477e14dc224c7c454f63379ac4c828dd (patch)
tree1ac7ae77a43beb4d2830e61762eb7482e12a6019 /packages/backend/src/core/CustomEmojiService.ts
parentmerge: timeline 1 (diff)
parentenhance(frontend): TLの返信表示オプションを記憶するように (diff)
downloadsharkey-f8f128b3477e14dc224c7c454f63379ac4c828dd.tar.gz
sharkey-f8f128b3477e14dc224c7c454f63379ac4c828dd.tar.bz2
sharkey-f8f128b3477e14dc224c7c454f63379ac4c828dd.zip
merge: all upstream changes
Diffstat (limited to 'packages/backend/src/core/CustomEmojiService.ts')
-rw-r--r--packages/backend/src/core/CustomEmojiService.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts
index d1cd2e97c3..e69254f727 100644
--- a/packages/backend/src/core/CustomEmojiService.ts
+++ b/packages/backend/src/core/CustomEmojiService.ts
@@ -52,7 +52,6 @@ export class CustomEmojiService implements OnApplicationShutdown {
fetcher: () => this.emojisRepository.find({ where: { host: IsNull() } }).then(emojis => new Map(emojis.map(emoji => [emoji.name, emoji]))),
toRedisConverter: (value) => JSON.stringify(Array.from(value.values())),
fromRedisConverter: (value) => {
- if (!Array.isArray(JSON.parse(value))) return undefined; // 古いバージョンの壊れたキャッシュが残っていることがある(そのうち消す)
return new Map(JSON.parse(value).map((x: Serialized<MiEmoji>) => [x.name, {
...x,
updatedAt: x.updatedAt ? new Date(x.updatedAt) : null,
@@ -386,6 +385,20 @@ export class CustomEmojiService implements OnApplicationShutdown {
}
}
+ /**
+ * ローカル内の絵文字に重複がないかチェックします
+ * @param name 絵文字名
+ */
+ @bindThis
+ public checkDuplicate(name: string): Promise<boolean> {
+ return this.emojisRepository.exist({ where: { name, host: IsNull() } });
+ }
+
+ @bindThis
+ public getEmojiById(id: string): Promise<MiEmoji | null> {
+ return this.emojisRepository.findOneBy({ id });
+ }
+
@bindThis
public dispose(): void {
this.cache.dispose();