Skip to content

Commit

Permalink
feat: 自分のサーバーで誰もフォローしていない、リモートユーザーからのメンションを拒否するように
Browse files Browse the repository at this point in the history
  • Loading branch information
EbiseLutica committed Feb 17, 2024
1 parent 2c3689e commit 738b4d6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ export class NoteCreateService implements OnApplicationShutdown {
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
}

// #region Shrimpia
if (user.host != null && mentionedUsers.some(u => u.host !== null)) {
const userEntity = await this.usersRepository.findOneByOrFail({ id: user.id });
if (userEntity.followersCount === 0) {
throw new Error('Temporarily, notes including mentions from remote users which no followers are not allowed');
}
}
// #endregion

tags = tags.filter(tag => Array.from(tag).length <= 128).splice(0, 32);

if (data.reply && (user.id !== data.reply.userId) && !mentionedUsers.some(u => u.id === data.reply!.userId)) {
Expand Down

0 comments on commit 738b4d6

Please sign in to comment.