sync NoteEditService from NoteCreateService
This commit is contained in:
parent
183cf962a0
commit
7606bce362
1 changed files with 19 additions and 8 deletions
|
@ -298,7 +298,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
data.visibility = 'home';
|
data.visibility = 'home';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.renote) {
|
if (this.isRenote(data)) {
|
||||||
switch (data.renote.visibility) {
|
switch (data.renote.visibility) {
|
||||||
case 'public':
|
case 'public':
|
||||||
// public noteは無条件にrenote可能
|
// public noteは無条件にrenote可能
|
||||||
|
@ -325,7 +325,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check blocking
|
// Check blocking
|
||||||
if (data.renote && !this.isQuote(data)) {
|
if (this.isRenote(data) && !this.isQuote(data)) {
|
||||||
if (data.renote.userHost === null) {
|
if (data.renote.userHost === null) {
|
||||||
if (data.renote.userId !== user.id) {
|
if (data.renote.userId !== user.id) {
|
||||||
const blocked = await this.userBlockingService.checkBlocked(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したらローカルのみにする
|
// ローカルのみをRenoteしたらローカルのみにする
|
||||||
if (data.renote && data.renote.localOnly && data.channel == null) {
|
if (this.isRenote(data) && data.renote.localOnly && data.channel == null) {
|
||||||
data.localOnly = true;
|
data.localOnly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,7 +684,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 投稿がRenoteかつ投稿者がローカルユーザーかつRenote元の投稿の投稿者がリモートユーザーなら配送
|
// 投稿が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 });
|
const u = await this.usersRepository.findOneBy({ id: data.renote.userId });
|
||||||
if (u && this.userEntityService.isRemoteUser(u)) dm.addDirectRecipe(u);
|
if (u && this.userEntityService.isRemoteUser(u)) dm.addDirectRecipe(u);
|
||||||
}
|
}
|
||||||
|
@ -727,9 +727,20 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private isQuote(note: Option): note is Option & { renote: MiNote } {
|
private isRenote(note: Option): note is Option & { renote: MiNote } {
|
||||||
// sync with misc/is-quote.ts
|
return note.renote != null;
|
||||||
return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll);
|
}
|
||||||
|
|
||||||
|
@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
|
@bindThis
|
||||||
|
@ -778,7 +789,7 @@ export class NoteEditService implements OnApplicationShutdown {
|
||||||
const user = await this.usersRepository.findOneBy({ id: note.userId });
|
const user = await this.usersRepository.findOneBy({ id: note.userId });
|
||||||
if (user == null) throw new Error('user not found');
|
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.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);
|
: this.apRendererService.renderUpdate(await this.apRendererService.renderUpNote(note, false), user);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue