diff --git a/packages/backend/src/server/api/endpoints/notes.ts b/packages/backend/src/server/api/endpoints/notes.ts index 9938322a2a..583cce2ad3 100644 --- a/packages/backend/src/server/api/endpoints/notes.ts +++ b/packages/backend/src/server/api/endpoints/notes.ts @@ -9,6 +9,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import { DI } from '@/di-symbols.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -45,10 +46,19 @@ export default class extends Endpoint { // eslint- @Inject(DI.notesRepository) private notesRepository: NotesRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private queryService: QueryService, ) { super(meta, paramDef, async (ps, me) => { + + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified || this.config.stripeAgeCheck.required && !me) { + // return no notes until we can figure out a way to simulate notes + return []; + } + const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) .andWhere('note.visibility = \'public\'') .andWhere('note.localOnly = FALSE') diff --git a/packages/backend/src/server/api/endpoints/notes/bubble-timeline.ts b/packages/backend/src/server/api/endpoints/notes/bubble-timeline.ts index c5e3a5a5f7..4b596f0a06 100644 --- a/packages/backend/src/server/api/endpoints/notes/bubble-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/bubble-timeline.ts @@ -10,6 +10,7 @@ import { RoleService } from '@/core/RoleService.js'; import { ApiError } from '../../error.js'; import { CacheService } from '@/core/CacheService.js'; import { MetaService } from '@/core/MetaService.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -54,6 +55,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.notesRepository) private notesRepository: NotesRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private queryService: QueryService, private roleService: RoleService, @@ -68,6 +72,11 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.btlDisabled); } + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified || this.config.stripeAgeCheck.required && !me) { + // return no notes until we can figure out a way to simulate notes + return []; + } + const [ followings, ] = me ? await Promise.all([ diff --git a/packages/backend/src/server/api/endpoints/notes/create.ts b/packages/backend/src/server/api/endpoints/notes/create.ts index 626f03b758..11ea2a2bce 100644 --- a/packages/backend/src/server/api/endpoints/notes/create.ts +++ b/packages/backend/src/server/api/endpoints/notes/create.ts @@ -139,6 +139,12 @@ export const meta = { code: 'CONTAINS_TOO_MANY_MENTIONS', id: '4de0363a-3046-481b-9b0f-feff3e211025', }, + + userIdNotVerified: { + message: 'Cannot post because your account needs to go through ID Verification.', + code: 'USER_ID_NOT_VERIFIED', + id: '4de0363a-3046-481b-9b0f-feff3e211029', + }, }, } as const; @@ -256,6 +262,10 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.maxLength); } + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified) { + throw new ApiError(meta.errors.userIdNotVerified); + } + let visibleUsers: MiUser[] = []; if (ps.visibleUserIds) { visibleUsers = await this.usersRepository.findBy({ diff --git a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts index d660f3fb69..a53ed4e975 100644 --- a/packages/backend/src/server/api/endpoints/notes/global-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/global-timeline.ts @@ -14,6 +14,7 @@ import { DI } from '@/di-symbols.js'; import { RoleService } from '@/core/RoleService.js'; import { ApiError } from '../../error.js'; import { CacheService } from '@/core/CacheService.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -58,6 +59,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.notesRepository) private notesRepository: NotesRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private queryService: QueryService, private roleService: RoleService, @@ -70,6 +74,11 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.gtlDisabled); } + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified || this.config.stripeAgeCheck.required && !me) { + // return no notes until we can figure out a way to simulate notes + return []; + } + const [ followings, ] = me ? await Promise.all([ diff --git a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts index fdc9a77956..ca7e070a08 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -20,6 +20,7 @@ import { MetaService } from '@/core/MetaService.js'; import { MiLocalUser } from '@/models/User.js'; import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js'; import { ApiError } from '../../error.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -81,6 +82,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.channelFollowingsRepository) private channelFollowingsRepository: ChannelFollowingsRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private roleService: RoleService, private activeUsersChart: ActiveUsersChart, @@ -100,6 +104,11 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.stlDisabled); } + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified || this.config.stripeAgeCheck.required && !me) { + // return no notes until we can figure out a way to simulate notes + return []; + } + if (ps.withReplies && ps.withFiles) throw new ApiError(meta.errors.bothWithRepliesAndWithFiles); const serverSettings = await this.metaService.fetch(); diff --git a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts index 5c3c7ae7d0..17216cb0e2 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -18,6 +18,7 @@ import { MetaService } from '@/core/MetaService.js'; import { MiLocalUser } from '@/models/User.js'; import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js'; import { ApiError } from '../../error.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -70,6 +71,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.notesRepository) private notesRepository: NotesRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private roleService: RoleService, private activeUsersChart: ActiveUsersChart, @@ -88,6 +92,11 @@ export default class extends Endpoint { // eslint- throw new ApiError(meta.errors.ltlDisabled); } + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified || this.config.stripeAgeCheck.required && !me) { + // return no notes until we can figure out a way to simulate notes + return []; + } + if (ps.withReplies && ps.withFiles) throw new ApiError(meta.errors.bothWithRepliesAndWithFiles); const serverSettings = await this.metaService.fetch(); diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index 1a14703e6e..350d5d081e 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -17,6 +17,7 @@ import { UserFollowingService } from '@/core/UserFollowingService.js'; import { MiLocalUser } from '@/models/User.js'; import { MetaService } from '@/core/MetaService.js'; import { FanoutTimelineEndpointService } from '@/core/FanoutTimelineEndpointService.js'; +import type { Config } from '@/config.js'; export const meta = { tags: ['notes'], @@ -63,6 +64,9 @@ export default class extends Endpoint { // eslint- @Inject(DI.channelFollowingsRepository) private channelFollowingsRepository: ChannelFollowingsRepository, + @Inject(DI.config) + private config: Config, + private noteEntityService: NoteEntityService, private activeUsersChart: ActiveUsersChart, private idService: IdService, @@ -78,6 +82,11 @@ export default class extends Endpoint { // eslint- const serverSettings = await this.metaService.fetch(); + if (this.config.stripeAgeCheck.enabled && me && me.idCheckRequired || this.config.stripeAgeCheck.required && me && !me.idVerified) { + // return no notes until we can figure out a way to simulate notes + return []; + } + if (!serverSettings.enableFanoutTimeline) { const timeline = await this.getFromDb({ untilId,