Merge upstream
This commit is contained in:
commit
0df3eb7dc4
15 changed files with 180 additions and 10 deletions
|
@ -10,6 +10,7 @@ import { QueryService } from '@/core/QueryService.js';
|
|||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { ApiError } from '../../../error.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
|
||||
export const meta = {
|
||||
tags: ['drive', 'notes'],
|
||||
|
@ -61,12 +62,13 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
private noteEntityService: NoteEntityService,
|
||||
private queryService: QueryService,
|
||||
private roleService: RoleService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
// Fetch file
|
||||
const file = await this.driveFilesRepository.findOneBy({
|
||||
id: ps.fileId,
|
||||
userId: me.id,
|
||||
userId: await this.roleService.isModerator(me) ? undefined : me.id,
|
||||
});
|
||||
|
||||
if (file == null) {
|
||||
|
|
|
@ -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: {
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -66,6 +66,13 @@ export const meta = {
|
|||
id: '4362f8dc-731f-4ad8-a694-be5a88922a24',
|
||||
httpStatusCode: 404,
|
||||
},
|
||||
|
||||
userSuspended: {
|
||||
message: 'User is suspended.',
|
||||
code: 'USER_SUSPENDED',
|
||||
id: 'c1e1b0d6-2b7c-4c1d-9f1d-2d3d6e8d7e7f',
|
||||
httpStatusCode: 403,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
|
@ -147,10 +154,19 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
user = await this.usersRepository.findOneBy(q);
|
||||
}
|
||||
|
||||
if (user == null || (!isModerator && user.isSuspended)) {
|
||||
if (user == null) {
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
}
|
||||
|
||||
if (!isModerator) {
|
||||
if (user.isDeleted && user.isSuspended) {
|
||||
throw new ApiError(meta.errors.noSuchUser);
|
||||
}
|
||||
if (user.isSuspended) {
|
||||
throw new ApiError(meta.errors.userSuspended);
|
||||
}
|
||||
}
|
||||
|
||||
if (user.host == null) {
|
||||
if (me == null && ip != null) {
|
||||
this.perUserPvChart.commitByVisitor(user, ip);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue