Skip to content

Commit

Permalink
fix: スパムメッセージを弾いたときにinbox queueがリトライしようとするのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
hideki0403 committed Feb 18, 2024
1 parent b9f94b3 commit b2b800d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class NoteCreateService implements OnApplicationShutdown {
host: MiUser['host'];
isBot: MiUser['isBot'];
isCat: MiUser['isCat'];
}, data: Option, silent = false): Promise<MiNote> {
}, data: Option, silent = false): Promise<MiNote | null> {
// チャンネル外にリプライしたら対象のスコープに合わせる
// (クライアントサイドでやっても良い処理だと思うけどとりあえずサーバーサイドで)
if (data.reply && data.channel && data.reply.channelId !== data.channel.id) {
Expand Down Expand Up @@ -375,7 +375,7 @@ export class NoteCreateService implements OnApplicationShutdown {
const userEntity = await this.usersRepository.findOneBy({ id: user.id });
if ((userEntity?.followersCount ?? 0) === 0) {
this.logger.error('Request rejected because user has no local followers', { user: user.id, note: data });
throw new IdentifiableError('e11b3a16-f543-4885-8eb1-66cad131dbfd', 'Notes including mentions, replies, or renotes from remote users are not allowed until user has at least one local follower.');
return null;
}
}

Expand Down
10 changes: 10 additions & 0 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ export const meta = {
code: 'CONTAINS_PROHIBITED_WORDS',
id: 'aa6e01d3-a85c-669d-758a-76aab43af334',
},

unknownError: {
message: 'Unknown error.',
code: 'UNKNOWN_ERROR',
id: 'ebb7b13d-1dd0-4f0b-b7c6-496230f0046b',
},
},
} as const;

Expand Down Expand Up @@ -371,6 +377,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
apEmojis: ps.noExtractEmojis ? [] : undefined,
});

if (note == null) {
throw new ApiError(meta.errors.unknownError);
}

return {
createdNote: await this.noteEntityService.pack(note, me),
};
Expand Down

0 comments on commit b2b800d

Please sign in to comment.