Skip to content

Commit

Permalink
Merge branch 'develop' into fix-user-show-multiple
Browse files Browse the repository at this point in the history
  • Loading branch information
anatawa12 authored May 20, 2024
2 parents af6cc7f + ed74f7b commit a35dc9f
Show file tree
Hide file tree
Showing 25 changed files with 166 additions and 107 deletions.
6 changes: 2 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
"service": "app",
"workspaceFolder": "/workspace",
"features": {
"ghcr.io/devcontainers-contrib/features/pnpm:2": {
"version": "8.9.2"
},
"ghcr.io/devcontainers/features/node:1": {
"version": "20.12.2"
}
},
"ghcr.io/devcontainers-contrib/features/corepack:1": {}
},
"forwardPorts": [3000],
"postCreateCommand": "sudo chmod 755 .devcontainer/init.sh && .devcontainer/init.sh",
Expand Down
2 changes: 2 additions & 0 deletions .devcontainer/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ set -xe

sudo chown -R node /workspace
git submodule update --init
corepack install
corepack enable
pnpm config set store-dir /home/node/.local/share/pnpm/store
pnpm install --frozen-lockfile
cp .devcontainer/devcontainer.yml .config/default.yml
Expand Down
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# These are supported funding model platforms

github: [misskey-dev]
patreon: syuilo
4 changes: 1 addition & 3 deletions .github/workflows/check-misskey-js-autogen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ jobs:
ref: refs/pull/${{ github.event.pull_request.number }}/merge

- name: setup pnpm
uses: pnpm/action-setup@v3
with:
version: 9
uses: pnpm/action-setup@v4

- name: setup node
id: setup-node
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/get-api-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ jobs:
ref: ${{ matrix.ref }}
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
15 changes: 3 additions & 12 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- uses: pnpm/action-setup@v4
- uses: actions/[email protected]
with:
node-version-file: '.node-version'
Expand All @@ -54,10 +51,7 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- uses: pnpm/action-setup@v4
- uses: actions/[email protected]
with:
node-version-file: '.node-version'
Expand All @@ -80,10 +74,7 @@ jobs:
with:
fetch-depth: 0
submodules: true
- uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
- uses: pnpm/action-setup@v4
- uses: actions/[email protected]
with:
node-version-file: '.node-version'
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/on-release-created.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ jobs:
echo "base=$(git rev-list --parents -n1 HEAD | cut -d" " -f2)" >> $GITHUB_OUTPUT
git checkout $(git rev-list --parents -n1 HEAD | cut -d" " -f3)
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js 20.x
uses: actions/[email protected]
with:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Install FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v3
- name: Use Node.js ${{ matrix.node-version }}
Expand Down Expand Up @@ -93,10 +90,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
10 changes: 2 additions & 8 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down Expand Up @@ -91,10 +88,7 @@ jobs:
#- uses: browser-actions/setup-firefox@latest
# if: ${{ matrix.browser == 'firefox' }}
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/test-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/validate-api-json.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ jobs:
with:
submodules: true
- name: Install pnpm
uses: pnpm/action-setup@v3
with:
version: 9
run_install: false
uses: pnpm/action-setup@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
with:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- 「アカウントを見つけやすくする」が有効なユーザーか
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
- Fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正
- Fix: みつけるのアンケート欄にてチャンネルのアンケートが含まれてしまう問題を修正

### Client
- Feat: アップロードするファイルの名前をランダム文字列にできるように
Expand Down Expand Up @@ -80,6 +81,8 @@
- Fix: グローバルタイムラインで返信が表示されないことがある問題を修正
- Fix: リノートをミュートしたユーザの投稿のリノートがミュートされる問題を修正
- Fix: AP Link等は添付ファイル扱いしないようになど (#13754)
- Fix: FTTが有効かつsinceIdのみを指定した場合に帰って来るレスポンスが逆順である問題を修正
- Fix: `/i/notifications``includeTypes``excludeTypes`を指定しているとき、通知が存在するのに空配列を返すことがある問題を修正
- Fix: 複数idを指定する`users/show`が関係ないユーザを返すことがある問題を修正

## 2024.3.1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/

export class ChannelIdDenormalizedForMiPoll1716129964060 {
name = 'ChannelIdDenormalizedForMiPoll1716129964060'

async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "poll" ADD "channelId" character varying(32)`);
await queryRunner.query(`COMMENT ON COLUMN "poll"."channelId" IS '[Denormalized]'`);
await queryRunner.query(`CREATE INDEX "IDX_c1240fcc9675946ea5d6c2860e" ON "poll" ("channelId") `);
await queryRunner.query(`UPDATE "poll" SET "channelId" = "note"."channelId" FROM "note" WHERE "poll"."noteId" = "note"."id"`);
}

async down(queryRunner) {
await queryRunner.query(`DROP INDEX "public"."IDX_c1240fcc9675946ea5d6c2860e"`);
await queryRunner.query(`COMMENT ON COLUMN "poll"."channelId" IS '[Denormalized]'`);
await queryRunner.query(`ALTER TABLE "poll" DROP COLUMN "channelId"`);
}
}
13 changes: 5 additions & 8 deletions packages/backend/src/core/FanoutTimelineEndpointService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ export class FanoutTimelineEndpointService {
// 呼び出し元と以下の処理をシンプルにするためにdbFallbackを置き換える
if (!ps.useDbFallback) ps.dbFallback = () => Promise.resolve([]);

const shouldPrepend = ps.sinceId && !ps.untilId;
const idCompare: (a: string, b: string) => number = shouldPrepend ? (a, b) => a < b ? -1 : 1 : (a, b) => a > b ? -1 : 1;
const ascending = ps.sinceId && !ps.untilId;
const idCompare: (a: string, b: string) => number = ascending ? (a, b) => a < b ? -1 : 1 : (a, b) => a > b ? -1 : 1;

const redisResult = await this.fanoutTimelineService.getMulti(ps.redisTimelines, ps.untilId, ps.sinceId);

Expand Down Expand Up @@ -142,26 +142,23 @@ export class FanoutTimelineEndpointService {

if (ps.allowPartial ? redisTimeline.length !== 0 : redisTimeline.length >= ps.limit) {
// 十分Redisからとれた
const result = redisTimeline.slice(0, ps.limit);
if (shouldPrepend) result.reverse();
return result;
return redisTimeline.slice(0, ps.limit);
}
}

// まだ足りない分はDBにフォールバック
const remainingToRead = ps.limit - redisTimeline.length;
let dbUntil: string | null;
let dbSince: string | null;
if (shouldPrepend) {
redisTimeline.reverse();
if (ascending) {
dbUntil = ps.untilId;
dbSince = noteIds[noteIds.length - 1];
} else {
dbUntil = noteIds[noteIds.length - 1];
dbSince = ps.sinceId;
}
const gotFromDb = await ps.dbFallback(dbUntil, dbSince, remainingToRead);
return shouldPrepend ? [...gotFromDb, ...redisTimeline] : [...redisTimeline, ...gotFromDb];
return [...redisTimeline, ...gotFromDb];
}

return await ps.dbFallback(ps.untilId, ps.sinceId, ps.limit);
Expand Down
1 change: 1 addition & 0 deletions packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ export class NoteCreateService implements OnApplicationShutdown {
noteVisibility: insert.visibility,
userId: user.id,
userHost: user.host,
channelId: insert.channelId,
});

await transactionalEntityManager.insert(MiPoll, poll);
Expand Down
58 changes: 39 additions & 19 deletions packages/backend/src/core/entities/UserEntityService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,41 @@ export class UserEntityService implements OnModuleInit {
] = await Promise.all([
this.followingsRepository.findBy({ followerId: me })
.then(f => new Map(f.map(it => [it.followeeId, it]))),
this.followingsRepository.findBy({ followeeId: me })
.then(it => it.map(it => it.followerId)),
this.followRequestsRepository.findBy({ followerId: me })
.then(it => it.map(it => it.followeeId)),
this.followRequestsRepository.findBy({ followeeId: me })
.then(it => it.map(it => it.followerId)),
this.blockingsRepository.findBy({ blockerId: me })
.then(it => it.map(it => it.blockeeId)),
this.blockingsRepository.findBy({ blockeeId: me })
.then(it => it.map(it => it.blockerId)),
this.mutingsRepository.findBy({ muterId: me })
.then(it => it.map(it => it.muteeId)),
this.renoteMutingsRepository.findBy({ muterId: me })
.then(it => it.map(it => it.muteeId)),
this.followingsRepository.createQueryBuilder('f')
.select('f.followerId')
.where('f.followeeId = :me', { me })
.getRawMany<{ f_followerId: string }>()
.then(it => it.map(it => it.f_followerId)),
this.followRequestsRepository.createQueryBuilder('f')
.select('f.followeeId')
.where('f.followerId = :me', { me })
.getRawMany<{ f_followeeId: string }>()
.then(it => it.map(it => it.f_followeeId)),
this.followRequestsRepository.createQueryBuilder('f')
.select('f.followerId')
.where('f.followeeId = :me', { me })
.getRawMany<{ f_followerId: string }>()
.then(it => it.map(it => it.f_followerId)),
this.blockingsRepository.createQueryBuilder('b')
.select('b.blockeeId')
.where('b.blockerId = :me', { me })
.getRawMany<{ b_blockeeId: string }>()
.then(it => it.map(it => it.b_blockeeId)),
this.blockingsRepository.createQueryBuilder('b')
.select('b.blockerId')
.where('b.blockeeId = :me', { me })
.getRawMany<{ b_blockerId: string }>()
.then(it => it.map(it => it.b_blockerId)),
this.mutingsRepository.createQueryBuilder('m')
.select('m.muteeId')
.where('m.muterId = :me', { me })
.getRawMany<{ m_muteeId: string }>()
.then(it => it.map(it => it.m_muteeId)),
this.renoteMutingsRepository.createQueryBuilder('m')
.select('m.muteeId')
.where('m.muterId = :me', { me })
.getRawMany<{ m_muteeId: string }>()
.then(it => it.map(it => it.m_muteeId)),
]);

return new Map(
Expand Down Expand Up @@ -637,18 +658,17 @@ export class UserEntityService implements OnModuleInit {
}
const _userIds = _users.map(u => u.id);

// -- 特に前提条件のない値群を取得

const profilesMap = await this.userProfilesRepository.findBy({ userId: In(_userIds) })
.then(profiles => new Map(profiles.map(p => [p.userId, p])));

// -- 実行者の有無や指定スキーマの種別によって要否が異なる値群を取得

let profilesMap: Map<MiUser['id'], MiUserProfile> = new Map();
let userRelations: Map<MiUser['id'], UserRelation> = new Map();
let userMemos: Map<MiUser['id'], string | null> = new Map();
let pinNotes: Map<MiUser['id'], MiUserNotePining[]> = new Map();

if (options?.schema !== 'UserLite') {
profilesMap = await this.userProfilesRepository.findBy({ userId: In(_userIds) })
.then(profiles => new Map(profiles.map(p => [p.userId, p])));

const meId = me ? me.id : null;
if (meId) {
userMemos = await this.userMemosRepository.findBy({ userId: meId })
Expand Down
9 changes: 9 additions & 0 deletions packages/backend/src/models/Poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { noteVisibilities } from '@/types.js';
import { id } from './util/id.js';
import { MiNote } from './Note.js';
import type { MiUser } from './User.js';
import type { MiChannel } from "@/models/Channel.js";

@Entity('poll')
export class MiPoll {
Expand Down Expand Up @@ -58,6 +59,14 @@ export class MiPoll {
comment: '[Denormalized]',
})
public userHost: string | null;

@Index()
@Column({
...id(),
nullable: true,
comment: '[Denormalized]',
})
public channelId: MiChannel['id'] | null;
//#endregion

constructor(data: Partial<MiPoll>) {
Expand Down
Loading

0 comments on commit a35dc9f

Please sign in to comment.