Skip to content

Commit

Permalink
Merge branch 'develop' into hexirp-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexirp authored Aug 18, 2023
2 parents 3415b8a + ba16abb commit 89fb8ac
Show file tree
Hide file tree
Showing 558 changed files with 2,395 additions and 2,704 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/api-misskey-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- run: corepack enable

- name: Setup Node.js
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version-file: '.node-version'
cache: 'pnpm'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
version: 8
run_install: false
- uses: actions/setup-node@v3.7.0
- uses: actions/setup-node@v3.8.0
with:
node-version-file: '.node-version'
cache: 'pnpm'
Expand All @@ -46,7 +46,7 @@ jobs:
with:
version: 7
run_install: false
- uses: actions/setup-node@v3.7.0
- uses: actions/setup-node@v3.8.0
with:
node-version-file: '.node-version'
cache: 'pnpm'
Expand All @@ -72,7 +72,7 @@ jobs:
with:
version: 7
run_install: false
- uses: actions/setup-node@v3.7.0
- uses: actions/setup-node@v3.8.0
with:
node-version-file: '.node-version'
cache: 'pnpm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
version: 8
run_install: false
- name: Use Node.js 20.x
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version-file: '.node-version'
cache: 'pnpm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
version: 8
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
version: 8
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
version: 7
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-misskey-js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- run: corepack enable

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
version: 8
run_install: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3.7.0
uses: actions/setup-node@v3.8.0
with:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
- Fix: iOSで画面を回転させるとテキストサイズが変わる問題を修正
- Fix: word mute for sub note is not applied
- Fix: タイムラインを下にスクロールしてノート画面に移動して再び戻ったら以前のスクロール位置を失う問題を修正
- Fix: Misskeyプラグインをインストールする際のAiScriptバージョンのチェックが0.14.0以降に対応していない問題を修正
- Fix: 他のサーバーのユーザーへ「メッセージを送信」した時の初期テキストのメンションが間違っている問題を修正

### Server
Expand Down
20 changes: 10 additions & 10 deletions packages/backend/src/core/AccountMoveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IsNull, In, MoreThan, Not } from 'typeorm';

import { bindThis } from '@/decorators.js';
import { DI } from '@/di-symbols.js';
import type { LocalUser, RemoteUser, User } from '@/models/entities/User.js';
import type { MiLocalUser, MiRemoteUser, MiUser } from '@/models/entities/User.js';
import type { BlockingsRepository, FollowingsRepository, InstancesRepository, MutingsRepository, UserListJoiningsRepository, UsersRepository } from '@/models/index.js';
import type { RelationshipJobData, ThinUser } from '@/queue/types.js';

Expand Down Expand Up @@ -71,12 +71,12 @@ export class AccountMoveService {
* After delivering Move activity, its local followers unfollow the old account and then follow the new one.
*/
@bindThis
public async moveFromLocal(src: LocalUser, dst: LocalUser | RemoteUser): Promise<unknown> {
public async moveFromLocal(src: MiLocalUser, dst: MiLocalUser | MiRemoteUser): Promise<unknown> {
const srcUri = this.userEntityService.getUserUri(src);
const dstUri = this.userEntityService.getUserUri(dst);

// add movedToUri to indicate that the user has moved
const update = {} as Partial<LocalUser>;
const update = {} as Partial<MiLocalUser>;
update.alsoKnownAs = src.alsoKnownAs?.includes(dstUri) ? src.alsoKnownAs : src.alsoKnownAs?.concat([dstUri]) ?? [dstUri];
update.movedToUri = dstUri;
update.movedAt = new Date();
Expand Down Expand Up @@ -114,7 +114,7 @@ export class AccountMoveService {
}

@bindThis
public async postMoveProcess(src: User, dst: User): Promise<void> {
public async postMoveProcess(src: MiUser, dst: MiUser): Promise<void> {
// Copy blockings and mutings, and update lists
try {
await Promise.all([
Expand Down Expand Up @@ -213,7 +213,7 @@ export class AccountMoveService {
* @returns Promise<void>
*/
@bindThis
public async updateLists(src: ThinUser, dst: User): Promise<void> {
public async updateLists(src: ThinUser, dst: MiUser): Promise<void> {
// Return if there is no list to be updated.
const oldJoinings = await this.userListJoiningsRepository.find({
where: {
Expand Down Expand Up @@ -260,7 +260,7 @@ export class AccountMoveService {
}

@bindThis
private async adjustFollowingCounts(localFollowerIds: string[], oldAccount: User): Promise<void> {
private async adjustFollowingCounts(localFollowerIds: string[], oldAccount: MiUser): Promise<void> {
if (localFollowerIds.length === 0) return;

// Set the old account's following and followers counts to 0.
Expand Down Expand Up @@ -301,11 +301,11 @@ export class AccountMoveService {
*/
@bindThis
public async validateAlsoKnownAs(
dst: LocalUser | RemoteUser,
check: (oldUser: LocalUser | RemoteUser | null, newUser: LocalUser | RemoteUser) => boolean | Promise<boolean> = () => true,
dst: MiLocalUser | MiRemoteUser,
check: (oldUser: MiLocalUser | MiRemoteUser | null, newUser: MiLocalUser | MiRemoteUser) => boolean | Promise<boolean> = () => true,
instant = false,
): Promise<LocalUser | RemoteUser | null> {
let resultUser: LocalUser | RemoteUser | null = null;
): Promise<MiLocalUser | MiRemoteUser | null> {
let resultUser: MiLocalUser | MiRemoteUser | null = null;

if (this.userEntityService.isRemoteUser(dst)) {
if ((new Date()).getTime() - (dst.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/AccountUpdateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { UsersRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { MiUser } from '@/models/entities/User.js';
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
import { RelayService } from '@/core/RelayService.js';
import { ApDeliverManagerService } from '@/core/activitypub/ApDeliverManagerService.js';
Expand All @@ -27,7 +27,7 @@ export class AccountUpdateService {
}

@bindThis
public async publishToFollowers(userId: User['id']) {
public async publishToFollowers(userId: MiUser['id']) {
const user = await this.usersRepository.findOneBy({ id: userId });
if (user == null) throw new Error('user not found');

Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/AchievementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { Inject, Injectable } from '@nestjs/common';
import type { UserProfilesRepository } from '@/models/index.js';
import type { User } from '@/models/entities/User.js';
import type { MiUser } from '@/models/entities/User.js';
import { DI } from '@/di-symbols.js';
import { bindThis } from '@/decorators.js';
import { NotificationService } from '@/core/NotificationService.js';
Expand Down Expand Up @@ -99,7 +99,7 @@ export class AchievementService {

@bindThis
public async create(
userId: User['id'],
userId: MiUser['id'],
type: typeof ACHIEVEMENT_TYPES[number],
): Promise<void> {
if (!ACHIEVEMENT_TYPES.includes(type)) return;
Expand Down
18 changes: 9 additions & 9 deletions packages/backend/src/core/AnnouncementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import { Inject, Injectable } from '@nestjs/common';
import { Brackets } from 'typeorm';
import { DI } from '@/di-symbols.js';
import type { User } from '@/models/entities/User.js';
import type { AnnouncementReadsRepository, AnnouncementsRepository, Announcement, AnnouncementRead } from '@/models/index.js';
import type { MiUser } from '@/models/entities/User.js';
import type { AnnouncementReadsRepository, AnnouncementsRepository, MiAnnouncement, MiAnnouncementRead } from '@/models/index.js';
import { bindThis } from '@/decorators.js';
import { Packed } from '@/misc/json-schema.js';
import { IdService } from '@/core/IdService.js';
Expand All @@ -28,14 +28,14 @@ export class AnnouncementService {
}

@bindThis
public async getReads(userId: User['id']): Promise<AnnouncementRead[]> {
public async getReads(userId: MiUser['id']): Promise<MiAnnouncementRead[]> {
return this.announcementReadsRepository.findBy({
userId: userId,
});
}

@bindThis
public async getUnreadAnnouncements(user: User): Promise<Announcement[]> {
public async getUnreadAnnouncements(user: MiUser): Promise<MiAnnouncement[]> {
const readsQuery = this.announcementReadsRepository.createQueryBuilder('read')
.select('read.announcementId')
.where('read.userId = :userId', { userId: user.id });
Expand All @@ -58,7 +58,7 @@ export class AnnouncementService {
}

@bindThis
public async create(values: Partial<Announcement>): Promise<{ raw: Announcement; packed: Packed<'Announcement'> }> {
public async create(values: Partial<MiAnnouncement>): Promise<{ raw: MiAnnouncement; packed: Packed<'Announcement'> }> {
const announcement = await this.announcementsRepository.insert({
id: this.idService.genId(),
createdAt: new Date(),
Expand Down Expand Up @@ -92,7 +92,7 @@ export class AnnouncementService {
}

@bindThis
public async read(user: User, announcementId: Announcement['id']): Promise<void> {
public async read(user: MiUser, announcementId: MiAnnouncement['id']): Promise<void> {
try {
await this.announcementReadsRepository.insert({
id: this.idService.genId(),
Expand All @@ -111,10 +111,10 @@ export class AnnouncementService {

@bindThis
public async packMany(
announcements: Announcement[],
me?: { id: User['id'] } | null | undefined,
announcements: MiAnnouncement[],
me?: { id: MiUser['id'] } | null | undefined,
options?: {
reads?: AnnouncementRead[];
reads?: MiAnnouncementRead[];
},
): Promise<Packed<'Announcement'>[]> {
const reads = me ? (options?.reads ?? await this.getReads(me.id)) : [];
Expand Down
12 changes: 6 additions & 6 deletions packages/backend/src/core/AntennaService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { Inject, Injectable } from '@nestjs/common';
import * as Redis from 'ioredis';
import type { Antenna } from '@/models/entities/Antenna.js';
import type { Note } from '@/models/entities/Note.js';
import type { User } from '@/models/entities/User.js';
import type { MiAntenna } from '@/models/entities/Antenna.js';
import type { MiNote } from '@/models/entities/Note.js';
import type { MiUser } from '@/models/entities/User.js';
import { GlobalEventService } from '@/core/GlobalEventService.js';
import * as Acct from '@/misc/acct.js';
import type { Packed } from '@/misc/json-schema.js';
Expand All @@ -21,7 +21,7 @@ import type { OnApplicationShutdown } from '@nestjs/common';
@Injectable()
export class AntennaService implements OnApplicationShutdown {
private antennasFetched: boolean;
private antennas: Antenna[];
private antennas: MiAntenna[];

constructor(
@Inject(DI.redis)
Expand Down Expand Up @@ -76,7 +76,7 @@ export class AntennaService implements OnApplicationShutdown {
}

@bindThis
public async addNoteToAntennas(note: Note, noteUser: { id: User['id']; username: string; host: string | null; }): Promise<void> {
public async addNoteToAntennas(note: MiNote, noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<void> {
const antennas = await this.getAntennas();
const antennasWithMatchResult = await Promise.all(antennas.map(antenna => this.checkHitAntenna(antenna, note, noteUser).then(hit => [antenna, hit] as const)));
const matchedAntennas = antennasWithMatchResult.filter(([, hit]) => hit).map(([antenna]) => antenna);
Expand All @@ -99,7 +99,7 @@ export class AntennaService implements OnApplicationShutdown {
// NOTE: フォローしているユーザーのノート、リストのユーザーのノート、グループのユーザーのノート指定はパフォーマンス上の理由で無効になっている

@bindThis
public async checkHitAntenna(antenna: Antenna, note: (Note | Packed<'Note'>), noteUser: { id: User['id']; username: string; host: string | null; }): Promise<boolean> {
public async checkHitAntenna(antenna: MiAntenna, note: (MiNote | Packed<'Note'>), noteUser: { id: MiUser['id']; username: string; host: string | null; }): Promise<boolean> {
if (note.visibility === 'specified') return false;
if (note.visibility === 'followers') return false;

Expand Down
30 changes: 15 additions & 15 deletions packages/backend/src/core/CacheService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

import { Inject, Injectable } from '@nestjs/common';
import * as Redis from 'ioredis';
import type { BlockingsRepository, ChannelFollowingsRepository, FollowingsRepository, MutingsRepository, RenoteMutingsRepository, UserProfile, UserProfilesRepository, UsersRepository } from '@/models/index.js';
import type { BlockingsRepository, ChannelFollowingsRepository, FollowingsRepository, MutingsRepository, RenoteMutingsRepository, MiUserProfile, UserProfilesRepository, UsersRepository } from '@/models/index.js';
import { MemoryKVCache, RedisKVCache } from '@/misc/cache.js';
import type { LocalUser, User } from '@/models/entities/User.js';
import type { MiLocalUser, MiUser } from '@/models/entities/User.js';
import { DI } from '@/di-symbols.js';
import { UserEntityService } from '@/core/entities/UserEntityService.js';
import { bindThis } from '@/decorators.js';
Expand All @@ -16,11 +16,11 @@ import type { OnApplicationShutdown } from '@nestjs/common';

@Injectable()
export class CacheService implements OnApplicationShutdown {
public userByIdCache: MemoryKVCache<User, User | string>;
public localUserByNativeTokenCache: MemoryKVCache<LocalUser | null, string | null>;
public localUserByIdCache: MemoryKVCache<LocalUser>;
public uriPersonCache: MemoryKVCache<User | null, string | null>;
public userProfileCache: RedisKVCache<UserProfile>;
public userByIdCache: MemoryKVCache<MiUser, MiUser | string>;
public localUserByNativeTokenCache: MemoryKVCache<MiLocalUser | null, string | null>;
public localUserByIdCache: MemoryKVCache<MiLocalUser>;
public uriPersonCache: MemoryKVCache<MiUser | null, string | null>;
public userProfileCache: RedisKVCache<MiUserProfile>;
public userMutingsCache: RedisKVCache<Set<string>>;
public userBlockingCache: RedisKVCache<Set<string>>;
public userBlockedCache: RedisKVCache<Set<string>>; // NOTE: 「被」Blockキャッシュ
Expand Down Expand Up @@ -60,14 +60,14 @@ export class CacheService implements OnApplicationShutdown {
) {
//this.onMessage = this.onMessage.bind(this);

const localUserByIdCache = new MemoryKVCache<LocalUser>(1000 * 60 * 60 * 6 /* 6h */);
const localUserByIdCache = new MemoryKVCache<MiLocalUser>(1000 * 60 * 60 * 6 /* 6h */);
this.localUserByIdCache = localUserByIdCache;

// ローカルユーザーならlocalUserByIdCacheにデータを追加し、こちらにはid(文字列)だけを追加する
const userByIdCache = new MemoryKVCache<User, User | string>(1000 * 60 * 60 * 6 /* 6h */, {
const userByIdCache = new MemoryKVCache<MiUser, MiUser | string>(1000 * 60 * 60 * 6 /* 6h */, {
toMapConverter: user => {
if (user.host === null) {
localUserByIdCache.set(user.id, user as LocalUser);
localUserByIdCache.set(user.id, user as MiLocalUser);
return user.id;
}

Expand All @@ -77,7 +77,7 @@ export class CacheService implements OnApplicationShutdown {
});
this.userByIdCache = userByIdCache;

this.localUserByNativeTokenCache = new MemoryKVCache<LocalUser | null, string | null>(Infinity, {
this.localUserByNativeTokenCache = new MemoryKVCache<MiLocalUser | null, string | null>(Infinity, {
toMapConverter: user => {
if (user === null) return null;

Expand All @@ -86,7 +86,7 @@ export class CacheService implements OnApplicationShutdown {
},
fromMapConverter: id => id === null ? null : localUserByIdCache.get(id),
});
this.uriPersonCache = new MemoryKVCache<User | null, string | null>(Infinity, {
this.uriPersonCache = new MemoryKVCache<MiUser | null, string | null>(Infinity, {
toMapConverter: user => {
if (user === null) return null;

Expand All @@ -96,7 +96,7 @@ export class CacheService implements OnApplicationShutdown {
fromMapConverter: id => id === null ? null : userByIdCache.get(id),
});

this.userProfileCache = new RedisKVCache<UserProfile>(this.redisClient, 'userProfile', {
this.userProfileCache = new RedisKVCache<MiUserProfile>(this.redisClient, 'userProfile', {
lifetime: 1000 * 60 * 30, // 30m
memoryCacheLifetime: 1000 * 60, // 1m
fetcher: (key) => this.userProfilesRepository.findOneByOrFail({ userId: key }),
Expand Down Expand Up @@ -178,7 +178,7 @@ export class CacheService implements OnApplicationShutdown {
break;
}
case 'userTokenRegenerated': {
const user = await this.usersRepository.findOneByOrFail({ id: body.id }) as LocalUser;
const user = await this.usersRepository.findOneByOrFail({ id: body.id }) as MiLocalUser;
this.localUserByNativeTokenCache.delete(body.oldToken);
this.localUserByNativeTokenCache.set(body.newToken, user);
break;
Expand All @@ -197,7 +197,7 @@ export class CacheService implements OnApplicationShutdown {
}

@bindThis
public findUserById(userId: User['id']) {
public findUserById(userId: MiUser['id']) {
return this.userByIdCache.fetch(userId, () => this.usersRepository.findOneByOrFail({ id: userId }));
}

Expand Down
Loading

0 comments on commit 89fb8ac

Please sign in to comment.