summaryrefslogtreecommitdiff
path: root/packages/backend/src/core/NoteEditService.ts
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2024-04-25 11:37:38 +0100
committerdakkar <dakkar@thenautilus.net>2024-04-25 11:44:24 +0100
commit7606bce3622c27a35b850b672a45babee03ecb75 (patch)
treee8cc3d0554e5103d85bc4f0219a2c0d1033afcea /packages/backend/src/core/NoteEditService.ts
parentsync NoteCreateService.create with .import (diff)
downloadsharkey-7606bce3622c27a35b850b672a45babee03ecb75.tar.gz
sharkey-7606bce3622c27a35b850b672a45babee03ecb75.tar.bz2
sharkey-7606bce3622c27a35b850b672a45babee03ecb75.zip
sync NoteEditService from NoteCreateService
Diffstat (limited to 'packages/backend/src/core/NoteEditService.ts')
-rw-r--r--packages/backend/src/core/NoteEditService.ts27
1 files changed, 19 insertions, 8 deletions
diff --git a/packages/backend/src/core/NoteEditService.ts b/packages/backend/src/core/NoteEditService.ts
index 72fc01ae3b..dbd5db21a8 100644
--- a/packages/backend/src/core/NoteEditService.ts
+++ b/packages/backend/src/core/NoteEditService.ts
@@ -298,7 +298,7 @@ export class NoteEditService implements OnApplicationShutdown {
data.visibility = 'home';
}
- if (data.renote) {
+ if (this.isRenote(data)) {
switch (data.renote.visibility) {
case 'public':
// public noteは無条件にrenote可能
@@ -325,7 +325,7 @@ export class NoteEditService implements OnApplicationShutdown {
}
// Check blocking
- if (data.renote && !this.isQuote(data)) {
+ if (this.isRenote(data) && !this.isQuote(data)) {
if (data.renote.userHost === null) {
if (data.renote.userId !== user.id) {
const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id);
@@ -342,7 +342,7 @@ export class NoteEditService implements OnApplicationShutdown {
}
// ローカルのみをRenoteしたらローカルのみにする
- if (data.renote && data.renote.localOnly && data.channel == null) {
+ if (this.isRenote(data) && data.renote.localOnly && data.channel == null) {
data.localOnly = true;
}
@@ -684,7 +684,7 @@ export class NoteEditService implements OnApplicationShutdown {
}
// 投稿がRenoteかつ投稿者がローカルユーザーかつRenote元の投稿の投稿者がリモートユーザーなら配送
- if (data.renote && data.renote.userHost !== null) {
+ if (this.isRenote(data) && data.renote.userHost !== null) {
const u = await this.usersRepository.findOneBy({ id: data.renote.userId });
if (u && this.userEntityService.isRemoteUser(u)) dm.addDirectRecipe(u);
}
@@ -727,9 +727,20 @@ export class NoteEditService implements OnApplicationShutdown {
}
@bindThis
- private isQuote(note: Option): note is Option & { renote: MiNote } {
- // sync with misc/is-quote.ts
- return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll);
+ private isRenote(note: Option): note is Option & { renote: MiNote } {
+ return note.renote != null;
+ }
+
+ @bindThis
+ private isQuote(note: Option & { renote: MiNote }): note is Option & { renote: MiNote } & (
+ { text: string } | { cw: string } | { reply: MiNote } | { poll: IPoll } | { files: MiDriveFile[] }
+ ) {
+ // NOTE: SYNC WITH misc/is-quote.ts
+ return note.text != null ||
+ note.reply != null ||
+ note.cw != null ||
+ note.poll != null ||
+ (note.files != null && note.files.length > 0);
}
@bindThis
@@ -778,7 +789,7 @@ export class NoteEditService implements OnApplicationShutdown {
const user = await this.usersRepository.findOneBy({ id: note.userId });
if (user == null) throw new Error('user not found');
- const content = data.renote && !this.isQuote(data)
+ const content = this.isRenote(data) && !this.isQuote(data)
? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note)
: this.apRendererService.renderUpdate(await this.apRendererService.renderUpNote(note, false), user);