mirror of
https://github.com/hotomoe/hotomoe
synced 2024-12-12 05:38:12 +09:00
spec(backend/NoteCreateService): ローカルユーザーがまだ誰もフォローしていないリモートユーザーによる通知を引き起こす可能性のある投稿を拒否できるように (MisskeyIO#462)
Cherry-picked from 738b4d69701a9d4b232f6a44b340782d096b182b, 1b3adcc2bbc695a0f28f5865a6705e0e59830962, 33cb50761ec12fc0df0e6f99ba97e0d5d4e580fc, a27af00e23a5283e357de1e6bf2a47ebefaa77c2, 5c6236bb0f1fde9140e331c9e1390bb5fccd4f9a Co-authored-by: Ebise Lutica <7106976+EbiseLutica@users.noreply.github.com>
This commit is contained in:
parent
a813be9e06
commit
82cc3987c1
@ -366,6 +366,16 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||
mentionedUsers = data.apMentions ?? await this.extractMentionedUsers(user, combinedTokens);
|
||||
}
|
||||
|
||||
const willCauseNotification = mentionedUsers.filter(u => u.host === null).length > 0 || data.reply?.userHost === null || data.renote?.userHost === null;
|
||||
|
||||
if (process.env.MISSKEY_BLOCK_MENTIONS_FROM_UNFAMILIAR_REMOTE_USERS === 'true' && user.host !== null && willCauseNotification) {
|
||||
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.');
|
||||
}
|
||||
}
|
||||
|
||||
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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user