Skip to content

Commit

Permalink
Merge pull request #863 from update-host
Browse files Browse the repository at this point in the history
Update host
  • Loading branch information
u1-liquid authored Dec 28, 2024
2 parents 920944c + 18b501f commit 0554ce4
Show file tree
Hide file tree
Showing 44 changed files with 593 additions and 508 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "2024.5.0-host.5c",
"version": "2024.5.0-host.5d",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
37 changes: 19 additions & 18 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
"generate-api-json": "pnpm build && node ./scripts/generate_api_json.js"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "1.10.1",
"@swc/core-darwin-x64": "1.10.1",
"@swc/core-linux-arm-gnueabihf": "1.10.1",
"@swc/core-linux-arm64-gnu": "1.10.1",
"@swc/core-linux-arm64-musl": "1.10.1",
"@swc/core-linux-x64-gnu": "1.10.1",
"@swc/core-linux-x64-musl": "1.10.1",
"@swc/core-win32-arm64-msvc": "1.10.1",
"@swc/core-win32-ia32-msvc": "1.10.1",
"@swc/core-win32-x64-msvc": "1.10.1",
"@swc/core-darwin-arm64": "1.10.3",
"@swc/core-darwin-x64": "1.10.3",
"@swc/core-linux-arm-gnueabihf": "1.10.3",
"@swc/core-linux-arm64-gnu": "1.10.3",
"@swc/core-linux-arm64-musl": "1.10.3",
"@swc/core-linux-x64-gnu": "1.10.3",
"@swc/core-linux-x64-musl": "1.10.3",
"@swc/core-win32-arm64-msvc": "1.10.3",
"@swc/core-win32-ia32-msvc": "1.10.3",
"@swc/core-win32-x64-msvc": "1.10.3",
"@tensorflow/tfjs": "4.22.0",
"@tensorflow/tfjs-node": "4.22.0",
"bufferutil": "4.0.8",
"bufferutil": "4.0.9",
"slacc-android-arm-eabi": "0.0.10",
"slacc-android-arm64": "0.0.10",
"slacc-darwin-arm64": "0.0.10",
Expand All @@ -65,9 +65,9 @@
"@authenio/samlify-node-xmllint": "2.0.0",
"@aws-sdk/client-s3": "3.717.0",
"@aws-sdk/lib-storage": "3.717.0",
"@bull-board/api": "6.5.3",
"@bull-board/fastify": "6.5.3",
"@bull-board/ui": "6.5.3",
"@bull-board/api": "6.5.4",
"@bull-board/fastify": "6.5.4",
"@bull-board/ui": "6.5.4",
"@discordapp/twemoji": "15.1.0",
"@elastic/elasticsearch": "8.17.0",
"@fastify/accepts": "5.0.2",
Expand All @@ -90,7 +90,7 @@
"@sinonjs/fake-timers": "11.3.1",
"@smithy/node-http-handler": "3.3.3",
"@swc/cli": "0.5.2",
"@swc/core": "1.10.1",
"@swc/core": "1.10.3",
"@twemoji/parser": "15.1.1",
"accepts": "1.3.8",
"ajv": "8.17.1",
Expand All @@ -99,7 +99,7 @@
"bcryptjs": "2.4.3",
"blurhash": "2.0.5",
"body-parser": "1.20.3",
"bullmq": "5.34.4",
"bullmq": "5.34.5",
"cacheable-lookup": "7.0.0",
"cbor": "10.0.3",
"chalk": "5.4.1",
Expand All @@ -118,7 +118,6 @@
"fluent-ffmpeg": "2.1.3",
"form-data": "4.0.1",
"got": "14.4.5",
"happy-dom": "15.11.7",
"hpagent": "1.2.0",
"htmlescape": "1.1.1",
"http-link-header": "1.1.3",
Expand Down Expand Up @@ -157,6 +156,7 @@
"pkce-challenge": "4.1.0",
"probe-image-size": "7.2.3",
"promise-limit": "2.7.0",
"psl": "1.15.0",
"pug": "3.0.3",
"punycode.js": "2.3.1",
"qrcode": "1.5.4",
Expand All @@ -175,7 +175,7 @@
"slacc": "0.0.10",
"strict-event-emitter-types": "2.0.0",
"stringz": "2.1.0",
"systeminformation": "5.23.21",
"systeminformation": "5.23.23",
"tinycolor2": "1.6.0",
"tmp": "0.2.3",
"tsc-alias": "1.8.10",
Expand Down Expand Up @@ -217,6 +217,7 @@
"@types/oauth2orize": "1.11.5",
"@types/oauth2orize-pkce": "0.1.2",
"@types/pg": "8.11.10",
"@types/psl": "1.1.3",
"@types/pug": "2.0.10",
"@types/punycode.js": "npm:@types/[email protected]",
"@types/qrcode": "1.5.5",
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/CustomEmojiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
: this.utilityService.isSelfHost(src) ? null // 自ホスト指定
: (src || noteUserHost); // 指定されたホスト || ノートなどの所有者のホスト (こっちがリアクションにマッチすることはない)

host = this.utilityService.toPunyNullable(host);
host = host ? this.utilityService.normalizeHost(host) : null;

return host;
}
Expand All @@ -324,7 +324,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
const name = match[1];

// ホスト正規化
const host = this.utilityService.toPunyNullable(this.normalizeHost(match[2], noteUserHost));
const host = this.normalizeHost(match[2], noteUserHost);

return { name, host };
}
Expand Down
4 changes: 2 additions & 2 deletions packages/backend/src/core/EmailService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class EmailService {
}

const emailDomain: string = emailAddress.split('@')[1];
const isBanned = this.utilityService.isBlockedHost(meta.bannedEmailDomains, emailDomain);
const isBanned = this.utilityService.isItemListedIn(emailDomain, meta.bannedEmailDomains);

if (isBanned) {
return {
Expand Down Expand Up @@ -304,7 +304,7 @@ export class EmailService {
reason: 'mx',
};
}
if (json.mx_host?.some(host => this.utilityService.isBlockedHost(meta.bannedEmailDomains, host))) {
if (json.mx_host?.some(host => this.utilityService.isItemListedIn(host, meta.bannedEmailDomains))) {
return {
valid: false,
reason: 'mx',
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/FederatedInstanceService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class FederatedInstanceService implements OnApplicationShutdown {

@bindThis
public async fetch(host: string): Promise<MiInstance> {
host = this.utilityService.toPuny(host);
host = this.utilityService.normalizeHost(host);

const cached = await this.federatedInstanceCache.get(host);
if (cached) return cached;
Expand Down
6 changes: 4 additions & 2 deletions packages/backend/src/core/HttpRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import { HttpProxyAgent, HttpsProxyAgent } from 'hpagent';
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js';
import { UtilityService } from '@/core/UtilityService.js';
import { StatusError } from '@/misc/status-error.js';
import { bindThis } from '@/decorators.js';
import { validateContentTypeSetAsActivityPub } from '@/core/activitypub/misc/validator.js';
import { assertActivityMatchesUrls } from '@/core/activitypub/misc/check-against-url.js';
import type { IObject } from '@/core/activitypub/type.js';
import type { Response } from 'node-fetch';
import type { URL } from 'node:url';
Expand Down Expand Up @@ -145,6 +145,8 @@ export class HttpRequestService {
constructor(
@Inject(DI.config)
private config: Config,

private utilityService: UtilityService,
) {
const cache = new CacheableLookup({
maxTtl: 3600, // 1hours
Expand Down Expand Up @@ -232,7 +234,7 @@ export class HttpRequestService {
const finalUrl = res.url; // redirects may have been involved
const activity = await res.json() as IObject;

assertActivityMatchesUrls(activity, [finalUrl]);
this.utilityService.assertActivityRelatedToUrl(activity, finalUrl);

return activity;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/NoteCreateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class NoteCreateService implements OnApplicationShutdown {
throw new IdentifiableError('689ee33f-f97c-479a-ac49-1b9f8140af99', 'Notes including prohibited words are not allowed.');
}

const inSilencedInstance = this.utilityService.isSilencedHost(meta.silencedHosts, user.host);
const inSilencedInstance = this.utilityService.isItemListedIn(user.host, meta.silencedHosts);

if (data.visibility === 'public' && inSilencedInstance && user.host !== null) {
data.visibility = 'home';
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/ReactionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export class ReactionService {
} else if (_reaction) {
const custom = reaction.match(isCustomEmojiRegexp);
if (custom) {
const reacterHost = this.utilityService.toPunyNullable(user.host);
const reacterHost = user.host ? this.utilityService.normalizeHost(user.host) : null;

const name = custom[1];
const emoji = reacterHost == null
Expand Down
6 changes: 3 additions & 3 deletions packages/backend/src/core/RemoteUserResolveService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ export class RemoteUserResolveService {
}) as MiLocalUser;
}

host = this.utilityService.toPuny(host);

if (host === this.utilityService.toPuny(this.config.host)) {
if (this.utilityService.isSelfHost(host)) {
this.logger.info(`return local user: ${usernameLower}`);
return await this.usersRepository.findOneBy({ usernameLower, host: IsNull() }).then(u => {
if (u == null) {
Expand All @@ -67,6 +65,8 @@ export class RemoteUserResolveService {
}) as MiLocalUser;
}

host = this.utilityService.normalizeHost(host);

const user = await this.usersRepository.findOneBy({ usernameLower, host }) as MiRemoteUser | null;

const acctLower = `${usernameLower}@${host}`;
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/SignupService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export class SignupService {
id: this.idService.gen(),
username: username,
usernameLower: username.toLowerCase(),
host: this.utilityService.toPunyNullable(host),
host: host ? this.utilityService.normalizeHost(host) : null,
token: secret,
isRoot: isTheFirstUser,
}));
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/core/UserFollowingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export class UserFollowingService implements OnModuleInit {
followee.isLocked ||
(followeeProfile.carefulBot && follower.isBot) ||
(this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') ||
(this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && this.utilityService.isSilencedHost((await this.metaService.fetch()).silencedHosts, follower.host))
(this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && this.utilityService.isItemListedIn(follower.host, (await this.metaService.fetch()).silencedHosts))
) {
let autoAccept = false;

Expand Down
Loading

0 comments on commit 0554ce4

Please sign in to comment.