Skip to content

Commit

Permalink
enhance(moderation): Bot同士ではフォロー・リプライができないように (#678)
Browse files Browse the repository at this point in the history
  • Loading branch information
nenohi authored Aug 7, 2024
1 parent 787d00b commit 50066cd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/backend/src/server/api/endpoints/following/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export const meta = {
code: 'BLOCKED',
id: 'c4ab57cc-4e41-45e9-bfd9-584f61e35ce0',
},

followingAnotherBot: {
message: 'Following another bot account is not allowed.',
code: 'FOLLOWING_BOT_NOT_ALLOWED',
id: '9a61d572-4a95-7f6b-b595-2817d42017b0',
},
},

res: {
Expand Down Expand Up @@ -100,6 +106,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw err;
});

if ( me.isBot && followee.isBot ) {
throw new ApiError(meta.errors.followingAnotherBot);
}

try {
await this.userFollowingService.follow(follower, followee, { withReplies: ps.withReplies });
} catch (e) {
Expand Down
12 changes: 12 additions & 0 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ export const meta = {
code: 'CONTAINS_TOO_MANY_MENTIONS',
id: '4de0363a-3046-481b-9b0f-feff3e211025',
},

replyingToAnotherBot: {
message: 'Replying to another bot account is not allowed.',
code: 'REPLY_TO_BOT_NOT_ALLOWED',
id: '66819f28-9525-389d-4b0a-4974363fbbbf',
},

},
} as const;

Expand Down Expand Up @@ -375,6 +382,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.cannotReplyToInvisibleNote);
} else if (reply.visibility === 'specified' && ps.visibility !== 'specified') {
throw new ApiError(meta.errors.cannotReplyToSpecifiedVisibilityNoteWithExtendedVisibility);
} else if ( me.isBot ) {
const replayuser = await this.usersRepository.findOneBy({ id: reply.userId });
if (replayuser?.isBot) {
throw new ApiError(meta.errors.replyingToAnotherBot);
}
}

// Check blocking
Expand Down
1 change: 1 addition & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4910,6 +4910,7 @@ export type components = {
canSearchNotes: boolean;
canUseTranslator: boolean;
canUseDriveFileInSoundSettings: boolean;
canUseReaction: boolean;
canHideAds: boolean;
driveCapacityMb: number;
alwaysMarkNsfw: boolean;
Expand Down

0 comments on commit 50066cd

Please sign in to comment.