diff --git a/.github/workflows/get-api-diff.yml b/.github/workflows/get-api-diff.yml index ae63cca851..d5646e3250 100644 --- a/.github/workflows/get-api-diff.yml +++ b/.github/workflows/get-api-diff.yml @@ -1,4 +1,5 @@ -name: Report API Diff +# this name is used in report-api-diff.yml so be careful when change name +name: Get api.json from CherryPick on: pull_request: @@ -171,55 +172,15 @@ jobs: - name: Kill CherryPick Job run: screen -S cherrypick -X quit - compare-diff: + save-pr-number: runs-on: ubuntu-latest - if: success() - needs: [get-base, get-head] - permissions: - pull-requests: write - steps: - - name: Download Artifact - uses: actions/download-artifact@v3 + - name: Save PR number + env: + PR_NUMBER: ${{ github.event.number }} + run: | + echo "$PR_NUMBER" > ./pr_number + - uses: actions/upload-artifact@v3 with: name: api-artifact - path: ./artifacts - - name: Output base - run: cat ./artifacts/api-base.json - - name: Output head - run: cat ./artifacts/api-head.json - - name: Arrange json files - run: | - jq '.' ./artifacts/api-base.json > ./api-base.json - jq '.' ./artifacts/api-head.json > ./api-head.json - - name: Get diff of 2 files - run: diff -u --label=base --label=head ./api-base.json ./api-head.json | cat > api.json.diff - - name: Get full diff - run: diff --label=base --label=head --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' ./api-base.json ./api-head.json | cat > api-full.json.diff - - name: Echo full diff - run: cat ./api-full.json.diff - - name: Upload full diff to Artifact - uses: actions/upload-artifact@v3 - with: - name: api-artifact - path: api-full.json.diff - - id: out-diff - name: Build diff Comment - run: | - cat <<- EOF > ./output.md - このPRによるapi.jsonの差分 -
- 差分はこちら - - \`\`\`diff - $(cat ./api.json.diff) - \`\`\` -
- - [Get diff files from Workflow Page](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}) - EOF - - name: Write diff comment - uses: thollander/actions-comment-pull-request@v2 - with: - comment_tag: show_diff - filePath: ./output.md + path: pr_number diff --git a/.github/workflows/report-api-diff.yml b/.github/workflows/report-api-diff.yml new file mode 100644 index 0000000000..ca400ec0df --- /dev/null +++ b/.github/workflows/report-api-diff.yml @@ -0,0 +1,85 @@ +name: Report API Diff + +on: + workflow_run: + types: [completed] + workflows: + - Get api.json from CherryPick # get-api-diff.yml + +jobs: + compare-diff: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + permissions: + pull-requests: write + +# api-artifact + steps: + - name: Download artifact + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "api-artifact" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/api-artifact.zip`, Buffer.from(download.data)); + - name: Extract artifact + run: unzip api-artifact.zip -d artifacts + - name: Load PR Number + id: load-pr-num + run: echo "pr-number=$(cat artifacts/pr_number)" >> "$GITHUB_OUTPUT" + + - name: Output base + run: cat ./artifacts/api-base.json + - name: Output head + run: cat ./artifacts/api-head.json + - name: Arrange json files + run: | + jq '.' ./artifacts/api-base.json > ./api-base.json + jq '.' ./artifacts/api-head.json > ./api-head.json + - name: Get diff of 2 files + run: diff -u --label=base --label=head ./api-base.json ./api-head.json | cat > api.json.diff + - name: Get full diff + run: diff --label=base --label=head --new-line-format='+%L' --old-line-format='-%L' --unchanged-line-format=' %L' ./api-base.json ./api-head.json | cat > api-full.json.diff + - name: Echo full diff + run: cat ./api-full.json.diff + - name: Upload full diff to Artifact + uses: actions/upload-artifact@v3 + with: + name: api-artifact + path: | + api-full.json.diff + api-base.json + api-head.json + - id: out-diff + name: Build diff Comment + run: | + cat <<- EOF > ./output.md + 이 PR에 의한 api.json 차이 +
+ 차이점은 여기에서 볼 수 있음 + + \`\`\`diff + $(cat ./api.json.diff) + \`\`\` +
+ + [Get diff files from Workflow Page](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}) + EOF + - uses: thollander/actions-comment-pull-request@v2 + with: + pr_number: ${{ steps.load-pr-num.outputs.pr-number }} + comment_tag: show_diff + filePath: ./output.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 15a6c22867..36c9747d3d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - Fix: リストTLに自分のフォロワー限定投稿が含まれない問題を修正 - Fix: ローカルタイムラインに投稿者自身の投稿への返信が含まれない問題を修正 - Fix: 自分のフォローしているユーザーの自分のフォローしていないユーザーの visibility: followers な投稿への返信がストリーミングで流れてくる問題を修正 +- Fix: RedisへのTLキャッシュが有効の場合にHTL/LTL/STLが空になることがある問題を修正 ## 2023.10.2 diff --git a/CHANGELOG_CHERRYPICK.md b/CHANGELOG_CHERRYPICK.md index cf8f91145f..c6161f040a 100644 --- a/CHANGELOG_CHERRYPICK.md +++ b/CHANGELOG_CHERRYPICK.md @@ -40,6 +40,7 @@ Misskey의 전체 변경 사항을 확인하려면, [CHANGELOG.md#2023xx](CHANGE ### Server - Enhance: 사용자 차단 개선 (Renote Part) (misskey-dev/misskey#12089) - Fix: 마이그레이션이 매우 길게 진행될 수 있음 +- Fix: Redis 에서 TL 캐시를 반환하지 않으면 '고양이만 보기'가 작동하지 않을 수 있음 --- diff --git a/packages/backend/src/server/api/endpoints/get-avatar-decorations.ts b/packages/backend/src/server/api/endpoints/get-avatar-decorations.ts index 2449278748..be7dec03d4 100644 --- a/packages/backend/src/server/api/endpoints/get-avatar-decorations.ts +++ b/packages/backend/src/server/api/endpoints/get-avatar-decorations.ts @@ -8,6 +8,7 @@ import { Inject, Injectable } from '@nestjs/common'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { DI } from '@/di-symbols.js'; import { AvatarDecorationService } from '@/core/AvatarDecorationService.js'; +import { RoleService } from '@/core/RoleService.js'; export const meta = { tags: ['users'], @@ -63,16 +64,18 @@ export const paramDef = { export default class extends Endpoint { // eslint-disable-line import/no-default-export constructor( private avatarDecorationService: AvatarDecorationService, + private roleService: RoleService, ) { super(meta, paramDef, async (ps, me) => { const decorations = await this.avatarDecorationService.getAll(true); + const allRoles = await this.roleService.getRoles(); return decorations.map(decoration => ({ id: decoration.id, name: decoration.name, description: decoration.description, url: decoration.url, - roleIdsThatCanBeUsedThisDecoration: decoration.roleIdsThatCanBeUsedThisDecoration, + roleIdsThatCanBeUsedThisDecoration: decoration.roleIdsThatCanBeUsedThisDecoration.filter(roleId => allRoles.some(role => role.id === roleId)), })); }); } 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 4e6024f3e9..ebd6211e99 100644 --- a/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/hybrid-timeline.ts @@ -132,6 +132,8 @@ export default class extends Endpoint { // eslint- shouldFallbackToDb = shouldFallbackToDb || (noteIds.length === 0); + let redisTimeline: MiNote[] = []; + if (!shouldFallbackToDb) { const query = this.notesRepository.createQueryBuilder('note') .where('note.id IN (:...noteIds)', { noteIds: noteIds }) @@ -142,13 +144,13 @@ export default class extends Endpoint { // eslint- .leftJoinAndSelect('renote.user', 'renoteUser') .leftJoinAndSelect('note.channel', 'channel'); - if (ps.withCats) { - query.andWhere('(select "isCat" from "user" where id = note."userId")'); - } + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } - let timeline = await query.getMany(); + redisTimeline = await query.getMany(); - timeline = timeline.filter(note => { + redisTimeline = redisTimeline.filter(note => { if (note.userId === me.id) { return true; } @@ -164,15 +166,15 @@ export default class extends Endpoint { // eslint- return true; }); - // TODO: フィルタした結果件数が足りなかった場合の対応 - - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + redisTimeline.sort((a, b) => a.id > b.id ? -1 : 1); + } + if (redisTimeline.length > 0) { process.nextTick(() => { this.activeUsersChart.read(me); }); - return await this.noteEntityService.packMany(timeline, me); + return await this.noteEntityService.packMany(redisTimeline, me); } else { // fallback to db return await this.getFromDb({ untilId, @@ -183,6 +185,7 @@ export default class extends Endpoint { // eslint- includeLocalRenotes: ps.includeLocalRenotes, withFiles: ps.withFiles, withReplies: ps.withReplies, + withCats: ps.withCats, }, me); } } else { @@ -195,6 +198,7 @@ export default class extends Endpoint { // eslint- includeLocalRenotes: ps.includeLocalRenotes, withFiles: ps.withFiles, withReplies: ps.withReplies, + withCats: ps.withCats, }, me); } }); @@ -209,6 +213,7 @@ export default class extends Endpoint { // eslint- includeLocalRenotes: boolean, withFiles: boolean, withReplies: boolean, + withCats: boolean, }, me: MiLocalUser) { const followees = await this.userFollowingService.getFollowees(me.id); @@ -279,6 +284,10 @@ export default class extends Endpoint { // eslint- if (ps.withFiles) { query.andWhere('note.fileIds != \'{}\''); } + + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } //#endregion const timeline = await query.limit(ps.limit).getMany(); 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 4209b03e5a..0d9bad4b11 100644 --- a/packages/backend/src/server/api/endpoints/notes/local-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/local-timeline.ts @@ -111,6 +111,8 @@ export default class extends Endpoint { // eslint- noteIds = noteIds.slice(0, ps.limit); + let redisTimeline: MiNote[] = []; + if (noteIds.length > 0) { const query = this.notesRepository.createQueryBuilder('note') .where('note.id IN (:...noteIds)', { noteIds: noteIds }) @@ -125,9 +127,9 @@ export default class extends Endpoint { // eslint- query.andWhere('(select "isCat" from "user" where id = note."userId")'); } - let timeline = await query.getMany(); + redisTimeline = await query.getMany(); - timeline = timeline.filter(note => { + redisTimeline = redisTimeline.filter(note => { if (me && (note.userId === me.id)) { return true; } @@ -144,17 +146,17 @@ export default class extends Endpoint { // eslint- return true; }); - // TODO: フィルタした結果件数が足りなかった場合の対応 - - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + redisTimeline.sort((a, b) => a.id > b.id ? -1 : 1); + } + if (redisTimeline.length > 0) { process.nextTick(() => { if (me) { this.activeUsersChart.read(me); } }); - return await this.noteEntityService.packMany(timeline, me); + return await this.noteEntityService.packMany(redisTimeline, me); } else { // fallback to db return await this.getFromDb({ untilId, @@ -162,6 +164,7 @@ export default class extends Endpoint { // eslint- limit: ps.limit, withFiles: ps.withFiles, withReplies: ps.withReplies, + withCats: ps.withCats, }, me); } } else { @@ -171,6 +174,7 @@ export default class extends Endpoint { // eslint- limit: ps.limit, withFiles: ps.withFiles, withReplies: ps.withReplies, + withCats: ps.withCats, }, me); } }); @@ -182,6 +186,7 @@ export default class extends Endpoint { // eslint- limit: number, withFiles: boolean, withReplies: boolean, + withCats: boolean, }, me: MiLocalUser | null) { const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) @@ -213,6 +218,10 @@ export default class extends Endpoint { // eslint- })); } + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } + const timeline = await query.limit(ps.limit).getMany(); process.nextTick(() => { diff --git a/packages/backend/src/server/api/endpoints/notes/timeline.ts b/packages/backend/src/server/api/endpoints/notes/timeline.ts index d1202ec850..9a7bad1536 100644 --- a/packages/backend/src/server/api/endpoints/notes/timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/timeline.ts @@ -5,7 +5,7 @@ import { Brackets } from 'typeorm'; import { Inject, Injectable } from '@nestjs/common'; -import type { NotesRepository } from '@/models/_.js'; +import type { MiNote, NotesRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { QueryService } from '@/core/QueryService.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; @@ -90,6 +90,8 @@ export default class extends Endpoint { // eslint- let noteIds = await this.funoutTimelineService.get(ps.withFiles ? `homeTimelineWithFiles:${me.id}` : `homeTimeline:${me.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); + let redisTimeline: MiNote[] = []; + if (noteIds.length > 0) { const query = this.notesRepository.createQueryBuilder('note') .where('note.id IN (:...noteIds)', { noteIds: noteIds }) @@ -104,9 +106,9 @@ export default class extends Endpoint { // eslint- query.andWhere('(select "isCat" from "user" where id = note."userId")'); } - let timeline = await query.getMany(); + redisTimeline = await query.getMany(); - timeline = timeline.filter(note => { + redisTimeline = redisTimeline.filter(note => { if (note.userId === me.id) { return true; } @@ -125,15 +127,15 @@ export default class extends Endpoint { // eslint- return true; }); - // TODO: フィルタした結果件数が足りなかった場合の対応 - - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + redisTimeline.sort((a, b) => a.id > b.id ? -1 : 1); + } + if (redisTimeline.length > 0) { process.nextTick(() => { this.activeUsersChart.read(me); }); - return await this.noteEntityService.packMany(timeline, me); + return await this.noteEntityService.packMany(redisTimeline, me); } else { // fallback to db return await this.getFromDb({ untilId, @@ -143,6 +145,8 @@ export default class extends Endpoint { // eslint- includeRenotedMyNotes: ps.includeRenotedMyNotes, includeLocalRenotes: ps.includeLocalRenotes, withFiles: ps.withFiles, + withRenotes: ps.withRenotes, + withCats: ps.withCats, }, me); } } else { @@ -154,12 +158,14 @@ export default class extends Endpoint { // eslint- includeRenotedMyNotes: ps.includeRenotedMyNotes, includeLocalRenotes: ps.includeLocalRenotes, withFiles: ps.withFiles, + withRenotes: ps.withRenotes, + withCats: ps.withCats, }, me); } }); } - private async getFromDb(ps: { untilId: string | null; sinceId: string | null; limit: number; includeMyRenotes: boolean; includeRenotedMyNotes: boolean; includeLocalRenotes: boolean; withFiles: boolean; }, me: MiLocalUser) { + private async getFromDb(ps: { untilId: string | null; sinceId: string | null; limit: number; includeMyRenotes: boolean; includeRenotedMyNotes: boolean; includeLocalRenotes: boolean; withFiles: boolean; withRenotes: boolean; withCats: boolean; }, me: MiLocalUser) { const followees = await this.userFollowingService.getFollowees(me.id); //#region Construct query @@ -227,6 +233,14 @@ export default class extends Endpoint { // eslint- if (ps.withFiles) { query.andWhere('note.fileIds != \'{}\''); } + + if (ps.withRenotes === false) { + query.andWhere('note.renoteId IS NULL'); + } + + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } //#endregion const timeline = await query.limit(ps.limit).getMany(); diff --git a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts index 082871929e..a74b184f06 100644 --- a/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts +++ b/packages/backend/src/server/api/endpoints/notes/user-list-timeline.ts @@ -4,7 +4,7 @@ */ import { Inject, Injectable } from '@nestjs/common'; -import type { NotesRepository, UserListsRepository } from '@/models/_.js'; +import type { MiNote, NotesRepository, UserListMembershipsRepository, UserListsRepository } from '@/models/_.js'; import { Endpoint } from '@/server/api/endpoint-base.js'; import { NoteEntityService } from '@/core/entities/NoteEntityService.js'; import ActiveUsersChart from '@/core/chart/charts/active-users.js'; @@ -13,7 +13,9 @@ import { CacheService } from '@/core/CacheService.js'; import { IdService } from '@/core/IdService.js'; import { isUserRelated } from '@/misc/is-user-related.js'; import { FunoutTimelineService } from '@/core/FunoutTimelineService.js'; +import { QueryService } from '@/core/QueryService.js'; import { ApiError } from '../../error.js'; +import { Brackets } from 'typeorm'; export const meta = { tags: ['notes', 'lists'], @@ -71,11 +73,16 @@ export default class extends Endpoint { // eslint- @Inject(DI.userListsRepository) private userListsRepository: UserListsRepository, + @Inject(DI.userListMembershipsRepository) + private userListMembershipsRepository: UserListMembershipsRepository, + private noteEntityService: NoteEntityService, private activeUsersChart: ActiveUsersChart, private cacheService: CacheService, private idService: IdService, private funoutTimelineService: FunoutTimelineService, + private queryService: QueryService, + ) { super(meta, paramDef, async (ps, me) => { const untilId = ps.untilId ?? (ps.untilDate ? this.idService.gen(ps.untilDate!) : null); @@ -103,48 +110,133 @@ export default class extends Endpoint { // eslint- let noteIds = await this.funoutTimelineService.get(ps.withFiles ? `userListTimelineWithFiles:${list.id}` : `userListTimeline:${list.id}`, untilId, sinceId); noteIds = noteIds.slice(0, ps.limit); - if (noteIds.length === 0) { - return []; - } + let redisTimeline: MiNote[] = []; - const query = this.notesRepository.createQueryBuilder('note') - .where('note.id IN (:...noteIds)', { noteIds: noteIds }) - .innerJoinAndSelect('note.user', 'user') - .leftJoinAndSelect('note.reply', 'reply') - .leftJoinAndSelect('note.renote', 'renote') - .leftJoinAndSelect('reply.user', 'replyUser') - .leftJoinAndSelect('renote.user', 'renoteUser') - .leftJoinAndSelect('note.channel', 'channel'); + if (noteIds.length > 0) { + const query = this.notesRepository.createQueryBuilder('note') + .where('note.id IN (:...noteIds)', { noteIds: noteIds }) + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser') + .leftJoinAndSelect('note.channel', 'channel'); - if (ps.withCats) { - query.andWhere('(select "isCat" from "user" where id = note."userId")'); - } + redisTimeline = await query.getMany(); - let timeline = await query.getMany(); - - timeline = timeline.filter(note => { - if (note.userId === me.id) { - return true; - } - if (isUserRelated(note, userIdsWhoBlockingMe)) return false; - if (isUserRelated(note, userIdsWhoMeMuting)) return false; - if (note.renoteId) { - if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { - if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; - if (ps.withRenotes === false) return false; + redisTimeline = redisTimeline.filter(note => { + if (note.userId === me.id) { + return true; } + if (isUserRelated(note, userIdsWhoBlockingMe)) return false; + if (isUserRelated(note, userIdsWhoMeMuting)) return false; + if (note.renoteId) { + if (note.text == null && note.fileIds.length === 0 && !note.hasPoll) { + if (isUserRelated(note, userIdsWhoMeMutingRenotes)) return false; + if (ps.withRenotes === false) return false; + } + } + + return true; + }); + + redisTimeline.sort((a, b) => a.id > b.id ? -1 : 1); + } + + if (redisTimeline.length > 0) { + this.activeUsersChart.read(me); + return await this.noteEntityService.packMany(redisTimeline, me); + } else { // fallback to db + //#region Construct query + const query = this.queryService.makePaginationQuery(this.notesRepository.createQueryBuilder('note'), ps.sinceId, ps.untilId) + .innerJoin(this.userListMembershipsRepository.metadata.targetName, 'userListMemberships', 'userListMemberships.userId = note.userId') + .innerJoinAndSelect('note.user', 'user') + .leftJoinAndSelect('note.reply', 'reply') + .leftJoinAndSelect('note.renote', 'renote') + .leftJoinAndSelect('reply.user', 'replyUser') + .leftJoinAndSelect('renote.user', 'renoteUser') + .andWhere('userListMemberships.userListId = :userListId', { userListId: list.id }) + .andWhere('note.channelId IS NULL') // チャンネルノートではない + .andWhere(new Brackets(qb => { + qb + .where('note.replyId IS NULL') // 返信ではない + .orWhere(new Brackets(qb => { + qb // 返信だけど投稿者自身への返信 + .where('note.replyId IS NOT NULL') + .andWhere('note.replyUserId = note.userId'); + })) + .orWhere(new Brackets(qb => { + qb // 返信だけど自分宛ての返信 + .where('note.replyId IS NOT NULL') + .andWhere('note.replyUserId = :meId', { meId: me.id }); + })) + .orWhere(new Brackets(qb => { + qb // 返信だけどwithRepliesがtrueの場合 + .where('note.replyId IS NOT NULL') + .andWhere('userListMemberships.withReplies = true'); + })); + })); + + this.queryService.generateVisibilityQuery(query, me); + this.queryService.generateMutedUserQuery(query, me); + this.queryService.generateBlockedUserQuery(query, me); + this.queryService.generateMutedUserRenotesQueryForNotes(query, me); + + if (ps.includeMyRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.userId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); } - return true; - }); + if (ps.includeRenotedMyNotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserId != :meId', { meId: me.id }); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); + } - // TODO: フィルタした結果件数が足りなかった場合の対応 + if (ps.includeLocalRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteUserHost IS NOT NULL'); + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + qb.orWhere('0 < (SELECT COUNT(*) FROM poll WHERE poll."noteId" = note.id)'); + })); + } - timeline.sort((a, b) => a.id > b.id ? -1 : 1); + if (ps.withRenotes === false) { + query.andWhere(new Brackets(qb => { + qb.orWhere('note.renoteId IS NULL'); + qb.orWhere(new Brackets(qb => { + qb.orWhere('note.text IS NOT NULL'); + qb.orWhere('note.fileIds != \'{}\''); + })); + })); + } - this.activeUsersChart.read(me); + if (ps.withFiles) { + query.andWhere('note.fileIds != \'{}\''); + } - return await this.noteEntityService.packMany(timeline, me); + if (ps.withCats) { + query.andWhere('(select "isCat" from "user" where id = note."userId")'); + } + //#endregion + + const timeline = await query.limit(ps.limit).getMany(); + + this.activeUsersChart.read(me); + + return await this.noteEntityService.packMany(timeline, me); + } }); } } diff --git a/packages/frontend/src/pages/settings/profile.vue b/packages/frontend/src/pages/settings/profile.vue index 92d95c69a0..ee183c0e1d 100644 --- a/packages/frontend/src/pages/settings/profile.vue +++ b/packages/frontend/src/pages/settings/profile.vue @@ -96,6 +96,7 @@ SPDX-License-Identifier: AGPL-3.0-only >
{{ avatarDecoration.name }}
+ @@ -389,4 +390,10 @@ definePageMetadata({ font-weight: bold; margin-bottom: 20px; } + +.avatarDecorationLock { + position: absolute; + bottom: 12px; + right: 12px; +}