Skip to content

Commit

Permalink
chore: use config instead of env variable to enable blockMentionsFrom…
Browse files Browse the repository at this point in the history
…UnfamiliarRemoteUsers
  • Loading branch information
anatawa12 committed Feb 19, 2024
1 parent b486212 commit f93be69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ type Source = {
maxWebImageSize?: number;
withRepliesInHomeTL?: boolean;
withRepliesInUserList?: boolean;
blockMentionsFromUnfamiliarRemoteUsers?: boolean;
}
};

Expand Down Expand Up @@ -185,6 +186,7 @@ export type Config = {
maxWebImageSize?: number;
withRepliesInHomeTL?: boolean,
withRepliesInUserList: boolean,
blockMentionsFromUnfamiliarRemoteUsers: boolean;
}
};

Expand Down Expand Up @@ -230,6 +232,7 @@ export function loadConfig(): Config {
// to avoid merge conflict in the future, this is at top
nirila: Object.assign({
withRepliesInUserList: true,
blockMentionsFromUnfamiliarRemoteUsers: false,
}, config.nirila ?? {}),
version,
publishTarballInsteadOfProvideRepositoryUrl: !!config.publishTarballInsteadOfProvideRepositoryUrl,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class NoteCreateService implements OnApplicationShutdown {

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) {
if (this.config.nirila.blockMentionsFromUnfamiliarRemoteUsers && 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 });
Expand Down

0 comments on commit f93be69

Please sign in to comment.