summaryrefslogtreecommitdiff
path: root/packages/backend
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2026-03-02 16:05:12 -0500
committerFreya Murphy <freya@freyacat.org>2026-03-02 18:39:22 -0500
commit24734d408700a72d45c3ff4a679606cab3ec544f (patch)
treed0fee0bcf508f3c631f7c26724bb5cd94dfc88a0 /packages/backend
parentmerge: Release/2025.4.5 (!1258) (diff)
downloadsharkey-24734d408700a72d45c3ff4a679606cab3ec544f.tar.gz
sharkey-24734d408700a72d45c3ff4a679606cab3ec544f.tar.bz2
sharkey-24734d408700a72d45c3ff4a679606cab3ec544f.zip
split url into webUrl and localUrl (like mastodon)stable
Diffstat (limited to 'packages/backend')
-rw-r--r--packages/backend/src/GlobalModule.ts2
-rw-r--r--packages/backend/src/boot/master.ts2
-rw-r--r--packages/backend/src/config.ts55
-rw-r--r--packages/backend/src/core/ChatService.ts2
-rw-r--r--packages/backend/src/core/CustomEmojiService.ts2
-rw-r--r--packages/backend/src/core/EmailService.ts6
-rw-r--r--packages/backend/src/core/GlobalEventService.ts2
-rw-r--r--packages/backend/src/core/InternalStorageService.ts2
-rw-r--r--packages/backend/src/core/MfmService.ts6
-rw-r--r--packages/backend/src/core/NoteDeleteService.ts6
-rw-r--r--packages/backend/src/core/NotePiningService.ts4
-rw-r--r--packages/backend/src/core/PushNotificationService.ts2
-rw-r--r--packages/backend/src/core/RemoteUserResolveService.ts2
-rw-r--r--packages/backend/src/core/UserFollowingService.ts2
-rw-r--r--packages/backend/src/core/UserSearchService.ts2
-rw-r--r--packages/backend/src/core/UtilityService.ts8
-rw-r--r--packages/backend/src/core/WebAuthnService.ts6
-rw-r--r--packages/backend/src/core/activitypub/ApDbResolverService.ts3
-rw-r--r--packages/backend/src/core/activitypub/ApInboxService.ts2
-rw-r--r--packages/backend/src/core/activitypub/ApRendererService.ts66
-rw-r--r--packages/backend/src/core/activitypub/ApRequestService.ts4
-rw-r--r--packages/backend/src/core/activitypub/models/ApPersonService.ts5
-rw-r--r--packages/backend/src/core/entities/DriveFileEntityService.ts2
-rw-r--r--packages/backend/src/core/entities/MetaEntityService.ts2
-rw-r--r--packages/backend/src/core/entities/NoteEntityService.ts2
-rw-r--r--packages/backend/src/core/entities/UserEntityService.ts8
-rw-r--r--packages/backend/src/queue/processors/ExportAccountDataProcessorService.ts22
-rw-r--r--packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts2
-rw-r--r--packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts4
-rw-r--r--packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts4
-rw-r--r--packages/backend/src/server/ActivityPubServerService.ts14
-rw-r--r--packages/backend/src/server/FileServerService.ts6
-rw-r--r--packages/backend/src/server/NodeinfoServerService.ts4
-rw-r--r--packages/backend/src/server/ServerService.ts6
-rw-r--r--packages/backend/src/server/WellKnownServerService.ts16
-rw-r--r--packages/backend/src/server/api/SigninApiService.ts2
-rw-r--r--packages/backend/src/server/api/SigninWithPasskeyApiService.ts2
-rw-r--r--packages/backend/src/server/api/SignupApiService.ts2
-rw-r--r--packages/backend/src/server/api/endpoints/admin/meta.ts2
-rw-r--r--packages/backend/src/server/api/endpoints/i/2fa/register.ts4
-rw-r--r--packages/backend/src/server/api/endpoints/i/update-email.ts2
-rw-r--r--packages/backend/src/server/api/endpoints/i/update.ts4
-rw-r--r--packages/backend/src/server/api/endpoints/request-reset-password.ts2
-rw-r--r--packages/backend/src/server/api/mastodon/MastodonConverters.ts22
-rw-r--r--packages/backend/src/server/api/mastodon/endpoints/instance.ts2
-rw-r--r--packages/backend/src/server/oauth/OAuth2ProviderService.ts12
-rw-r--r--packages/backend/src/server/web/ClientServerService.ts17
-rw-r--r--packages/backend/src/server/web/FeedService.ts6
-rw-r--r--packages/backend/src/server/web/UrlPreviewService.ts2
-rw-r--r--packages/backend/src/server/web/views/announcement.pug2
-rw-r--r--packages/backend/src/server/web/views/base-embed.pug1
-rw-r--r--packages/backend/src/server/web/views/base.pug3
-rw-r--r--packages/backend/src/server/web/views/channel.pug2
-rw-r--r--packages/backend/src/server/web/views/clip.pug2
-rw-r--r--packages/backend/src/server/web/views/flash.pug2
-rw-r--r--packages/backend/src/server/web/views/gallery-post.pug2
-rw-r--r--packages/backend/src/server/web/views/note.pug6
-rw-r--r--packages/backend/src/server/web/views/page.pug2
-rw-r--r--packages/backend/src/server/web/views/reversi-game.pug2
-rw-r--r--packages/backend/src/server/web/views/user.pug4
-rw-r--r--packages/backend/test/e2e/2fa.ts8
-rw-r--r--packages/backend/test/e2e/move.ts2
-rw-r--r--packages/backend/test/unit/activitypub.ts16
-rw-r--r--packages/backend/test/utils.ts4
64 files changed, 220 insertions, 202 deletions
diff --git a/packages/backend/src/GlobalModule.ts b/packages/backend/src/GlobalModule.ts
index 90dbdaf2a6..0f6c0c6cd7 100644
--- a/packages/backend/src/GlobalModule.ts
+++ b/packages/backend/src/GlobalModule.ts
@@ -70,7 +70,7 @@ const $redisForSub: Provider = {
provide: DI.redisForSub,
useFactory: (config: Config) => {
const redis = new Redis.Redis(config.redisForPubsub);
- redis.subscribe(config.host);
+ redis.subscribe(config.webHost);
return redis;
},
inject: [DI.config],
diff --git a/packages/backend/src/boot/master.ts b/packages/backend/src/boot/master.ts
index a90228eabc..234312b06f 100644
--- a/packages/backend/src/boot/master.ts
+++ b/packages/backend/src/boot/master.ts
@@ -143,7 +143,7 @@ export async function masterMain() {
bootLogger.info('Queue started', null, true);
} else {
const addressString = net.isIPv6(config.address) ? `[${config.address}]` : config.address;
- bootLogger.info(config.socket ? `Now listening on socket ${config.socket} on ${config.url}` : `Now listening on ${addressString}:${config.port} on ${config.url}`, null, true);
+ bootLogger.info(config.socket ? `Now listening on socket ${config.socket} on ${config.localUrl}` : `Now listening on ${addressString}:${config.port} on ${config.localUrl}`, null, true);
}
}
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts
index c2e7efd456..06f73fdb21 100644
--- a/packages/backend/src/config.ts
+++ b/packages/backend/src/config.ts
@@ -30,6 +30,8 @@ type RedisOptionsSource = Partial<RedisOptions> & {
*/
type Source = {
url?: string;
+ localUrl?: string;
+ webUrl?: string;
port?: number;
address?: string;
socket?: string;
@@ -214,7 +216,8 @@ function parseIpOrMask(ipOrMask: string): CIDR | null {
}
export type Config = {
- url: string;
+ localUrl: string;
+ webUrl: string;
port: number;
address: string;
socket: string | undefined;
@@ -290,8 +293,10 @@ export type Config = {
version: string;
publishTarballInsteadOfProvideRepositoryUrl: boolean;
setupPassword: string | undefined;
- host: string;
- hostname: string;
+ localHost: string;
+ localHostname: string;
+ webHost: string;
+ webHostname: string;
scheme: string;
wsScheme: string;
apiUrl: string;
@@ -396,11 +401,14 @@ export function loadConfig(): Config {
applyEnvOverrides(config);
- const url = tryCreateUrl(config.url ?? process.env.MISSKEY_URL ?? '');
+ const localUrl = tryCreateUrl(config.url ?? config.localUrl ?? process.env.MISSKEY_URL ?? '');
+ const webUrl = tryCreateUrl(config.webUrl ?? process.env.MISSKEY_WEB_URL ?? localUrl ?? '');
const version = meta.version;
- const host = url.host;
- const hostname = url.hostname;
- const scheme = url.protocol.replace(/:$/, '');
+ const localHost = localUrl.host;
+ const localHostname = localUrl.hostname;
+ const webHost = webUrl.host;
+ const webHostname = webUrl.hostname;
+ const scheme = webUrl.protocol.replace(/:$/, '');
const wsScheme = scheme.replace('http', 'ws');
const dbDb = config.db.db ?? process.env.DATABASE_DB ?? '';
@@ -410,8 +418,8 @@ export function loadConfig(): Config {
const externalMediaProxy = config.mediaProxy ?
config.mediaProxy.endsWith('/') ? config.mediaProxy.substring(0, config.mediaProxy.length - 1) : config.mediaProxy
: null;
- const internalMediaProxy = `${scheme}://${host}/proxy`;
- const redis = convertRedisOptions(config.redis, host);
+ const internalMediaProxy = `${scheme}://${webHost}/proxy`;
+ const redis = convertRedisOptions(config.redis, localHost);
// nullish => 300 (default)
// 0 => undefined (disabled)
@@ -421,31 +429,34 @@ export function loadConfig(): Config {
version,
publishTarballInsteadOfProvideRepositoryUrl: !!config.publishTarballInsteadOfProvideRepositoryUrl,
setupPassword: config.setupPassword,
- url: url.origin,
+ localUrl: localUrl.origin,
+ webUrl: webUrl.origin,
port: config.port ?? parseInt(process.env.PORT ?? '3000', 10),
address: config.address ?? '0.0.0.0',
socket: config.socket,
chmodSocket: config.chmodSocket,
disableHsts: config.disableHsts,
- host,
- hostname,
+ localHost,
+ localHostname,
+ webHost,
+ webHostname,
scheme,
wsScheme,
- wsUrl: `${wsScheme}://${host}`,
- apiUrl: `${scheme}://${host}/api`,
- authUrl: `${scheme}://${host}/auth`,
- driveUrl: `${scheme}://${host}/files`,
+ wsUrl: `${wsScheme}://${webHost}`,
+ apiUrl: `${scheme}://${webHost}/api`,
+ authUrl: `${scheme}://${webHost}/auth`,
+ driveUrl: `${scheme}://${webHost}/files`,
db: { ...config.db, db: dbDb, user: dbUser, pass: dbPass, slowQueryThreshold },
dbReplications: config.dbReplications,
dbSlaves: config.dbSlaves,
fulltextSearch: config.fulltextSearch,
meilisearch: config.meilisearch,
redis,
- redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis,
- redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, host) : redis,
- redisForTimelines: config.redisForTimelines ? convertRedisOptions(config.redisForTimelines, host) : redis,
- redisForReactions: config.redisForReactions ? convertRedisOptions(config.redisForReactions, host) : redis,
- redisForRateLimit: config.redisForRateLimit ? convertRedisOptions(config.redisForRateLimit, host) : redis,
+ redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, webHost) : redis,
+ redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, webHost) : redis,
+ redisForTimelines: config.redisForTimelines ? convertRedisOptions(config.redisForTimelines, webHost) : redis,
+ redisForReactions: config.redisForReactions ? convertRedisOptions(config.redisForReactions, webHost) : redis,
+ redisForRateLimit: config.redisForRateLimit ? convertRedisOptions(config.redisForRateLimit, webHost) : redis,
sentryForBackend: config.sentryForBackend,
sentryForFrontend: config.sentryForFrontend,
id: config.id,
@@ -483,7 +494,7 @@ export function loadConfig(): Config {
videoThumbnailGenerator: config.videoThumbnailGenerator ?
config.videoThumbnailGenerator.endsWith('/') ? config.videoThumbnailGenerator.substring(0, config.videoThumbnailGenerator.length - 1) : config.videoThumbnailGenerator
: null,
- userAgent: `Misskey/${version} (${config.url})`,
+ userAgent: `Misskey/${version} (${config.localUrl})`,
frontendEntry: frontendManifest['src/_boot_.ts'],
frontendManifestExists: frontendManifestExists,
frontendEmbedEntry: frontendEmbedManifest['src/boot.ts'],
diff --git a/packages/backend/src/core/ChatService.ts b/packages/backend/src/core/ChatService.ts
index 9d294a80cb..968419c5e9 100644
--- a/packages/backend/src/core/ChatService.ts
+++ b/packages/backend/src/core/ChatService.ts
@@ -369,7 +369,7 @@ export class ChatService {
if (this.userEntityService.isLocalUser(toUser)) this.globalEventService.publishChatUserStream(message.toUserId, message.fromUserId, 'deleted', message.id);
if (this.userEntityService.isLocalUser(fromUser) && this.userEntityService.isRemoteUser(toUser)) {
- //const activity = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${message.id}`), fromUser));
+ //const activity = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.webUrl}/notes/${message.id}`), fromUser));
//this.queueService.deliver(fromUser, activity, toUser.inbox);
}
} else if (message.toRoomId) {
diff --git a/packages/backend/src/core/CustomEmojiService.ts b/packages/backend/src/core/CustomEmojiService.ts
index 2e4eddf797..3b05a13518 100644
--- a/packages/backend/src/core/CustomEmojiService.ts
+++ b/packages/backend/src/core/CustomEmojiService.ts
@@ -411,7 +411,7 @@ export class CustomEmojiService implements OnApplicationShutdown {
if (name == null) return null;
if (host == null) return null;
- const newHost = host === this.config.host ? null : host;
+ const newHost = host === this.config.localHost ? null : host;
const queryOrNull = async () => (await this.emojisRepository.findOneBy({
name,
diff --git a/packages/backend/src/core/EmailService.ts b/packages/backend/src/core/EmailService.ts
index 45d7ea11e4..fe3b8ef8ef 100644
--- a/packages/backend/src/core/EmailService.ts
+++ b/packages/backend/src/core/EmailService.ts
@@ -42,8 +42,8 @@ export class EmailService {
public async sendEmail(to: string, subject: string, html: string, text: string) {
if (!this.meta.enableEmail) return;
- const iconUrl = `${this.config.url}/static-assets/mi-white.png`;
- const emailSettingUrl = `${this.config.url}/settings/email`;
+ const iconUrl = `${this.config.webUrl}/static-assets/mi-white.png`;
+ const emailSettingUrl = `${this.config.webUrl}/settings/email`;
const enableAuth = this.meta.smtpUser != null && this.meta.smtpUser !== '';
@@ -135,7 +135,7 @@ export class EmailService {
</footer>
</main>
<nav>
- <a href="${ this.config.url }">${ this.config.host }</a>
+ <a href="${ this.config.webUrl }">${ this.config.webHost }</a>
</nav>
</body>
</html>`;
diff --git a/packages/backend/src/core/GlobalEventService.ts b/packages/backend/src/core/GlobalEventService.ts
index c146811331..c35e7243d3 100644
--- a/packages/backend/src/core/GlobalEventService.ts
+++ b/packages/backend/src/core/GlobalEventService.ts
@@ -359,7 +359,7 @@ export class GlobalEventService {
{ type: type, body: null } :
{ type: type, body: value };
- await this.redisForPub.publish(this.config.host, JSON.stringify({
+ await this.redisForPub.publish(this.config.webHost, JSON.stringify({
channel: channel,
message: message,
}));
diff --git a/packages/backend/src/core/InternalStorageService.ts b/packages/backend/src/core/InternalStorageService.ts
index abdbbc61d3..1b4f1880b9 100644
--- a/packages/backend/src/core/InternalStorageService.ts
+++ b/packages/backend/src/core/InternalStorageService.ts
@@ -48,7 +48,7 @@ export class InternalStorageService {
const path = this.resolvePath(key);
await chmod(path, this.config.filePermissionBits);
}
- return `${this.config.url}/files/${key}`;
+ return `${this.config.webUrl}/files/${key}`;
}
@bindThis
diff --git a/packages/backend/src/core/MfmService.ts b/packages/backend/src/core/MfmService.ts
index 839cdf534c..33a009fa50 100644
--- a/packages/backend/src/core/MfmService.ts
+++ b/packages/backend/src/core/MfmService.ts
@@ -491,7 +491,7 @@ export class MfmService {
hashtag: (node) => {
const a = new Element('a', {
- href: `${this.config.url}/tags/${node.props.hashtag}`,
+ href: `${this.config.webUrl}/tags/${node.props.hashtag}`,
rel: 'tag',
});
a.childNodes.push(new Text(`#${node.props.hashtag}`));
@@ -531,7 +531,7 @@ export class MfmService {
const a = new Element('a', {
href: remoteUserInfo
? (remoteUserInfo.url ? remoteUserInfo.url : remoteUserInfo.uri)
- : `${this.config.url}/${acct.endsWith(`@${this.config.url}`) ? acct.substring(0, acct.length - this.config.url.length - 1) : acct}`,
+ : `${this.config.webUrl}/${acct.endsWith(`@${this.config.localUrl}`) ? acct.substring(0, acct.length - this.config.localUrl.length - 1) : acct}`,
class: 'u-url mention',
});
a.childNodes.push(new Text(acct));
@@ -747,7 +747,7 @@ export class MfmService {
hashtag: (node) => {
const a = new Element('a', {
- href: `${this.config.url}/tags/${node.props.hashtag}`,
+ href: `${this.config.webUrl}/tags/${node.props.hashtag}`,
rel: 'tag',
class: 'hashtag',
});
diff --git a/packages/backend/src/core/NoteDeleteService.ts b/packages/backend/src/core/NoteDeleteService.ts
index 9ce8cb6731..1dcfc2cafd 100644
--- a/packages/backend/src/core/NoteDeleteService.ts
+++ b/packages/backend/src/core/NoteDeleteService.ts
@@ -103,8 +103,8 @@ export class NoteDeleteService {
}
const content = this.apRendererService.addContext(renote
- ? this.apRendererService.renderUndo(this.apRendererService.renderAnnounce(renote.uri ?? `${this.config.url}/notes/${renote.id}`, note), user)
- : this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${note.id}`), user));
+ ? this.apRendererService.renderUndo(this.apRendererService.renderAnnounce(renote.uri ?? `${this.config.webUrl}/notes/${renote.id}`, note), user)
+ : this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.webUrl}/notes/${note.id}`), user));
this.deliverToConcerned(user, note, content);
}
@@ -114,7 +114,7 @@ export class NoteDeleteService {
for (const cascadingNote of federatedLocalCascadingNotes) {
if (!cascadingNote.user) continue;
if (!this.userEntityService.isLocalUser(cascadingNote.user)) continue;
- const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.url}/notes/${cascadingNote.id}`), cascadingNote.user));
+ const content = this.apRendererService.addContext(this.apRendererService.renderDelete(this.apRendererService.renderTombstone(`${this.config.webUrl}/notes/${cascadingNote.id}`), cascadingNote.user));
this.deliverToConcerned(cascadingNote.user, cascadingNote, content);
}
//#endregion
diff --git a/packages/backend/src/core/NotePiningService.ts b/packages/backend/src/core/NotePiningService.ts
index a678108189..19bc3186df 100644
--- a/packages/backend/src/core/NotePiningService.ts
+++ b/packages/backend/src/core/NotePiningService.ts
@@ -120,8 +120,8 @@ export class NotePiningService {
public async deliverPinnedChange(user: MiUser, noteId: MiNote['id'], isAddition: boolean) {
if (!this.userEntityService.isLocalUser(user)) return;
- const target = `${this.config.url}/users/${user.id}/collections/featured`;
- const item = `${this.config.url}/notes/${noteId}`;
+ const target = `${this.config.webUrl}/users/${user.id}/collections/featured`;
+ const item = `${this.config.webUrl}/notes/${noteId}`;
const content = this.apRendererService.addContext(isAddition ? this.apRendererService.renderAdd(user, target, item) : this.apRendererService.renderRemove(user, target, item));
await this.apDeliverManagerService.deliverToFollowers(user, content);
diff --git a/packages/backend/src/core/PushNotificationService.ts b/packages/backend/src/core/PushNotificationService.ts
index e3f10d4504..85e22a0547 100644
--- a/packages/backend/src/core/PushNotificationService.ts
+++ b/packages/backend/src/core/PushNotificationService.ts
@@ -76,7 +76,7 @@ export class PushNotificationService implements OnApplicationShutdown {
if (!this.meta.enableServiceWorker || this.meta.swPublicKey == null || this.meta.swPrivateKey == null) return;
// アプリケーションの連絡先と、サーバーサイドの鍵ペアの情報を登録
- push.setVapidDetails(this.config.url,
+ push.setVapidDetails(this.config.webUrl,
this.meta.swPublicKey,
this.meta.swPrivateKey);
diff --git a/packages/backend/src/core/RemoteUserResolveService.ts b/packages/backend/src/core/RemoteUserResolveService.ts
index 4dbc9d6a36..883877b047 100644
--- a/packages/backend/src/core/RemoteUserResolveService.ts
+++ b/packages/backend/src/core/RemoteUserResolveService.ts
@@ -49,7 +49,7 @@ export class RemoteUserResolveService {
host = this.utilityService.toPuny(host);
- if (host === this.utilityService.toPuny(this.config.host)) {
+ if (host === this.utilityService.toPuny(this.config.localHost)) {
return await this.usersRepository.findOneByOrFail({ usernameLower, host: IsNull() }) as MiLocalUser;
}
diff --git a/packages/backend/src/core/UserFollowingService.ts b/packages/backend/src/core/UserFollowingService.ts
index 8470872eac..b1229a353d 100644
--- a/packages/backend/src/core/UserFollowingService.ts
+++ b/packages/backend/src/core/UserFollowingService.ts
@@ -518,7 +518,7 @@ export class UserFollowingService implements OnModuleInit {
}
if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) {
- const content = this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser, requestId ?? `${this.config.url}/follows/${followRequest.id}`));
+ const content = this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser, requestId ?? `${this.config.webUrl}/follows/${followRequest.id}`));
this.queueService.deliver(follower, content, followee.inbox, false);
}
}
diff --git a/packages/backend/src/core/UserSearchService.ts b/packages/backend/src/core/UserSearchService.ts
index 4be7bd9bdb..15245c39b7 100644
--- a/packages/backend/src/core/UserSearchService.ts
+++ b/packages/backend/src/core/UserSearchService.ts
@@ -198,7 +198,7 @@ export class UserSearchService {
}
if (params.host) {
- if (params.host === this.config.hostname || params.host === '.') {
+ if (params.host === this.config.localHostname || params.host === '.') {
userQuery.andWhere('user.host IS NULL');
} else {
userQuery.andWhere('user.host LIKE :host', {
diff --git a/packages/backend/src/core/UtilityService.ts b/packages/backend/src/core/UtilityService.ts
index a90774cf59..c15c587cd7 100644
--- a/packages/backend/src/core/UtilityService.ts
+++ b/packages/backend/src/core/UtilityService.ts
@@ -30,18 +30,20 @@ export class UtilityService {
@bindThis
public getFullApAccount(username: string, host: string | null): string {
- return host ? `${username}@${this.toPuny(host)}` : `${username}@${this.toPuny(this.config.host)}`;
+ return host ? `${username}@${this.toPuny(host)}` : `${username}@${this.toPuny(this.config.localHost)}`;
}
@bindThis
public isSelfHost(host: string | null): boolean {
if (host == null) return true;
- return this.toPuny(this.config.host) === this.toPuny(host);
+ return (this.toPuny(this.config.localHost) === this.toPuny(host)) ||
+ (this.toPuny(this.config.webHost) === this.toPuny(host))
}
@bindThis
public isUriLocal(uri: string): boolean {
- return this.punyHost(uri) === this.toPuny(this.config.host);
+ return (this.punyHost(uri) === this.toPuny(this.config.localHost)) ||
+ (this.punyHost(uri) === this.toPuny(this.config.webHost))
}
// メールアドレスのバリデーションを行う
diff --git a/packages/backend/src/core/WebAuthnService.ts b/packages/backend/src/core/WebAuthnService.ts
index afd1d68ce4..dc9899ff18 100644
--- a/packages/backend/src/core/WebAuthnService.ts
+++ b/packages/backend/src/core/WebAuthnService.ts
@@ -52,9 +52,9 @@ export class WebAuthnService {
@bindThis
public getRelyingParty(): { origin: string; rpId: string; rpName: string; rpIcon?: string; } {
return {
- origin: this.config.url,
- rpId: this.config.hostname,
- rpName: this.meta.name ?? this.config.host,
+ origin: this.config.webUrl,
+ rpId: this.config.webHostname,
+ rpName: this.meta.name ?? this.config.webHost,
rpIcon: this.meta.iconUrl ?? undefined,
};
}
diff --git a/packages/backend/src/core/activitypub/ApDbResolverService.ts b/packages/backend/src/core/activitypub/ApDbResolverService.ts
index e9e0dde9cd..73b81a1226 100644
--- a/packages/backend/src/core/activitypub/ApDbResolverService.ts
+++ b/packages/backend/src/core/activitypub/ApDbResolverService.ts
@@ -64,7 +64,8 @@ export class ApDbResolverService implements OnApplicationShutdown {
const apId = getApId(value);
const uri = new URL(apId);
- if (this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.host)) {
+ if ((this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.localHost)) &&
+ (this.utilityService.toPuny(uri.host) !== this.utilityService.toPuny(this.config.webHost))) {
return { local: false, uri: apId };
}
diff --git a/packages/backend/src/core/activitypub/ApInboxService.ts b/packages/backend/src/core/activitypub/ApInboxService.ts
index 009d4cbd39..a7699c67d6 100644
--- a/packages/backend/src/core/activitypub/ApInboxService.ts
+++ b/packages/backend/src/core/activitypub/ApInboxService.ts
@@ -646,7 +646,7 @@ export class ApInboxService {
const uris = getApIds(activity.object);
const userIds = uris
- .filter(uri => uri.startsWith(this.config.url + '/users/'))
+ .filter(uri => uri.startsWith(this.config.webUrl + '/users/'))
.map(uri => uri.split('/').at(-1))
.filter(x => x != null);
const users = await this.usersRepository.findBy({
diff --git a/packages/backend/src/core/activitypub/ApRendererService.ts b/packages/backend/src/core/activitypub/ApRendererService.ts
index 9f55be11ac..aa014505ee 100644
--- a/packages/backend/src/core/activitypub/ApRendererService.ts
+++ b/packages/backend/src/core/activitypub/ApRendererService.ts
@@ -121,7 +121,7 @@ export class ApRendererService {
}
return {
- id: `${this.config.url}/notes/${note.id}/activity`,
+ id: `${this.config.webUrl}/notes/${note.id}/activity`,
actor: this.userEntityService.genLocalUserUri(note.userId),
type: 'Announce',
published: this.idService.parse(note.id).date.toISOString(),
@@ -144,7 +144,7 @@ export class ApRendererService {
return {
type: 'Block',
- id: `${this.config.url}/blocks/${block.id}`,
+ id: `${this.config.webUrl}/blocks/${block.id}`,
actor: this.userEntityService.genLocalUserUri(block.blockerId),
object: block.blockee.uri,
};
@@ -153,7 +153,7 @@ export class ApRendererService {
@bindThis
public renderCreate(object: IObject, note: MiNote): ICreate {
const activity: ICreate = {
- id: `${this.config.url}/notes/${note.id}/activity`,
+ id: `${this.config.webUrl}/notes/${note.id}/activity`,
actor: this.userEntityService.genLocalUserUri(note.userId),
type: 'Create',
published: this.idService.parse(note.id).date.toISOString(),
@@ -191,7 +191,7 @@ export class ApRendererService {
@bindThis
public renderEmoji(emoji: MiEmoji): IApEmoji {
return {
- id: `${this.config.url}/emojis/${emoji.name}`,
+ id: `${this.config.webUrl}/emojis/${emoji.name}`,
type: 'Emoji',
name: `:${emoji.name}:`,
updated: emoji.updatedAt != null ? emoji.updatedAt.toISOString() : new Date().toISOString(),
@@ -222,7 +222,7 @@ export class ApRendererService {
@bindThis
public renderFollowRelay(relay: MiRelay, relayActor: MiLocalUser): IFollow {
return {
- id: `${this.config.url}/activities/follow-relay/${relay.id}`,
+ id: `${this.config.webUrl}/activities/follow-relay/${relay.id}`,
type: 'Follow',
actor: this.userEntityService.genLocalUserUri(relayActor.id),
object: 'https://www.w3.org/ns/activitystreams#Public',
@@ -246,7 +246,7 @@ export class ApRendererService {
requestId?: string,
): IFollow {
return {
- id: requestId ?? `${this.config.url}/follows/${follower.id}/${followee.id}`,
+ id: requestId ?? `${this.config.webUrl}/follows/${follower.id}/${followee.id}`,
type: 'Follow',
actor: this.userEntityService.getUserUri(follower),
object: this.userEntityService.getUserUri(followee),
@@ -257,7 +257,7 @@ export class ApRendererService {
public renderHashtag(tag: string): IApHashtag {
return {
type: 'Hashtag',
- href: `${this.config.url}/tags/${encodeURIComponent(tag)}`,
+ href: `${this.config.webUrl}/tags/${encodeURIComponent(tag)}`,
name: `#${tag}`,
};
}
@@ -318,7 +318,7 @@ export class ApRendererService {
@bindThis
public renderKey(user: MiLocalUser, key: MiUserKeypair, postfix?: string): IKey {
return {
- id: `${this.config.url}/users/${user.id}${postfix ?? '/publickey'}`,
+ id: `${this.config.webUrl}/users/${user.id}${postfix ?? '/publickey'}`,
type: 'Key',
owner: this.userEntityService.genLocalUserUri(user.id),
publicKeyPem: createPublicKey(key.publicKey).export({
@@ -348,9 +348,9 @@ export class ApRendererService {
const object: ILike = {
type: 'Like',
- id: `${this.config.url}/likes/${noteReaction.id}`,
- actor: `${this.config.url}/users/${noteReaction.userId}`,
- object: note.uri ? note.uri : `${this.config.url}/notes/${noteReaction.noteId}`,
+ id: `${this.config.webUrl}/likes/${noteReaction.id}`,
+ actor: `${this.config.webUrl}/users/${noteReaction.userId}`,
+ object: note.uri ? note.uri : `${this.config.webUrl}/notes/${noteReaction.noteId}`,
content: isMastodon ? undefined : reaction,
_misskey_reaction: isMastodon ? undefined : reaction,
};
@@ -382,7 +382,7 @@ export class ApRendererService {
const actor = this.userEntityService.getUserUri(src);
const target = this.userEntityService.getUserUri(dst);
return {
- id: `${this.config.url}/moves/${src.id}/${dst.id}`,
+ id: `${this.config.webUrl}/moves/${src.id}/${dst.id}`,
actor,
type: 'Move',
object: actor,
@@ -414,7 +414,7 @@ export class ApRendererService {
if (dive) {
inReplyTo = await this.renderNote(inReplyToNote, inReplyToUser, false);
} else {
- inReplyTo = `${this.config.url}/notes/${inReplyToNote.id}`;
+ inReplyTo = `${this.config.webUrl}/notes/${inReplyToNote.id}`;
}
}
}
@@ -429,7 +429,7 @@ export class ApRendererService {
const renote = await this.notesRepository.findOneBy({ id: note.renoteId });
if (renote) {
- quote = renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`;
+ quote = renote.uri ? renote.uri : `${this.config.webUrl}/notes/${renote.id}`;
}
}
@@ -540,7 +540,7 @@ export class ApRendererService {
const replies = isPublic ? await this.renderRepliesCollection(note.id) : undefined;
return {
- id: `${this.config.url}/notes/${note.id}`,
+ id: `${this.config.webUrl}/notes/${note.id}`,
type: 'Note',
attributedTo,
summary: summary ?? undefined,
@@ -608,9 +608,9 @@ export class ApRendererService {
followers: `${id}/followers`,
following: `${id}/following`,
featured: `${id}/collections/featured`,
- sharedInbox: `${this.config.url}/inbox`,
- endpoints: { sharedInbox: `${this.config.url}/inbox` },
- url: `${this.config.url}/@${user.username}`,
+ sharedInbox: `${this.config.webUrl}/inbox`,
+ endpoints: { sharedInbox: `${this.config.webUrl}/inbox` },
+ url: `${this.config.webUrl}/@${user.username}`,
preferredUsername: user.username,
name: user.name,
summary: profile.description ? this.mfmService.toHtml(mfm.parse(profile.description)) : null,
@@ -672,9 +672,9 @@ export class ApRendererService {
id,
inbox: `${id}/inbox`,
outbox: `${id}/outbox`,
- sharedInbox: `${this.config.url}/inbox`,
- endpoints: { sharedInbox: `${this.config.url}/inbox` },
- url: `${this.config.url}/@${user.username}`,
+ sharedInbox: `${this.config.webUrl}/inbox`,
+ endpoints: { sharedInbox: `${this.config.webUrl}/inbox` },
+ url: `${this.config.webUrl}/@${user.username}`,
preferredUsername: user.username,
publicKey: this.renderKey(user, keypair, '#main-key'),
@@ -695,7 +695,7 @@ export class ApRendererService {
public renderQuestion(user: { id: MiUser['id'] }, note: MiNote, poll: MiPoll): IQuestion {
return {
type: 'Question',
- id: `${this.config.url}/questions/${note.id}`,
+ id: `${this.config.webUrl}/questions/${note.id}`,
actor: this.userEntityService.genLocalUserUri(user.id),
content: note.text ?? '',
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
@@ -752,7 +752,7 @@ export class ApRendererService {
@bindThis
public renderUpdate(object: string | IObject, user: { id: MiUser['id'] }): IUpdate {
return {
- id: `${this.config.url}/users/${user.id}#updates/${new Date().getTime()}`,
+ id: `${this.config.webUrl}/users/${user.id}#updates/${new Date().getTime()}`,
actor: this.userEntityService.genLocalUserUri(user.id),
type: 'Update',
to: ['https://www.w3.org/ns/activitystreams#Public'],
@@ -764,13 +764,13 @@ export class ApRendererService {
@bindThis
public renderVote(user: { id: MiUser['id'] }, vote: MiPollVote, note: MiNote, poll: MiPoll, pollOwner: MiRemoteUser): ICreate {
return {
- id: `${this.config.url}/users/${user.id}#votes/${vote.id}/activity`,
+ id: `${this.config.webUrl}/users/${user.id}#votes/${vote.id}/activity`,
actor: this.userEntityService.genLocalUserUri(user.id),
type: 'Create',
to: [pollOwner.uri],
published: new Date().toISOString(),
object: {
- id: `${this.config.url}/users/${user.id}#votes/${vote.id}`,
+ id: `${this.config.webUrl}/users/${user.id}#votes/${vote.id}`,
type: 'Note',
attributedTo: this.userEntityService.genLocalUserUri(user.id),
to: [pollOwner.uri],
@@ -783,7 +783,7 @@ export class ApRendererService {
@bindThis
public addContext<T extends IObject>(x: T): T & { '@context': any; id: string; } {
if (typeof x === 'object' && x.id == null) {
- x.id = `${this.config.url}/${randomUUID()}`;
+ x.id = `${this.config.webUrl}/${randomUUID()}`;
}
return Object.assign({ '@context': CONTEXT }, x as T & { id: string });
@@ -800,7 +800,7 @@ export class ApRendererService {
const keypair = await this.userKeypairService.getUserKeypair(user.id);
- activity = await this.jsonLdService.signRsaSignature2017(activity, keypair.privateKey, `${this.config.url}/users/${user.id}#main-key`);
+ activity = await this.jsonLdService.signRsaSignature2017(activity, keypair.privateKey, `${this.config.webUrl}/users/${user.id}#main-key`);
return activity;
}
@@ -867,8 +867,8 @@ export class ApRendererService {
return {
type: 'OrderedCollection',
- id: `${this.config.url}/notes/${noteId}/replies`,
- first: `${this.config.url}/notes/${noteId}/replies?page=true`,
+ id: `${this.config.webUrl}/notes/${noteId}/replies`,
+ first: `${this.config.webUrl}/notes/${noteId}/replies?page=true`,
totalItems: replyCount,
};
}
@@ -898,18 +898,18 @@ export class ApRendererService {
.getRawMany<{ note_id: string, note_uri: string | null }>();
const hasNextPage = results.length >= limit;
- const baseId = `${this.config.url}/notes/${noteId}/replies?page=true`;
+ const baseId = `${this.config.webUrl}/notes/${noteId}/replies?page=true`;
return {
type: 'OrderedCollectionPage',
id: untilId == null ? baseId : `${baseId}&until_id=${untilId}`,
- partOf: `${this.config.url}/notes/${noteId}/replies`,
+ partOf: `${this.config.webUrl}/notes/${noteId}/replies`,
first: baseId,
next: hasNextPage ? `${baseId}&until_id=${results.at(-1)?.note_id}` : undefined,
totalItems: replyCount,
orderedItems: results.map(r => {
// Remote notes have a URI, local have just an ID.
- return r.note_uri ?? `${this.config.url}/notes/${r.note_id}`;
+ return r.note_uri ?? `${this.config.webUrl}/notes/${r.note_id}`;
}),
};
}
@@ -920,7 +920,7 @@ export class ApRendererService {
if (isPureRenote(note)) {
const renote = hint?.renote ?? note.renote ?? await this.notesRepository.findOneByOrFail({ id: note.renoteId });
- const apAnnounce = this.renderAnnounce(renote.uri ?? `${this.config.url}/notes/${renote.id}`, note);
+ const apAnnounce = this.renderAnnounce(renote.uri ?? `${this.config.webUrl}/notes/${renote.id}`, note);
return this.addContext(apAnnounce);
}
diff --git a/packages/backend/src/core/activitypub/ApRequestService.ts b/packages/backend/src/core/activitypub/ApRequestService.ts
index 7669ce9669..cd92adc549 100644
--- a/packages/backend/src/core/activitypub/ApRequestService.ts
+++ b/packages/backend/src/core/activitypub/ApRequestService.ts
@@ -164,7 +164,7 @@ export class ApRequestService {
const req = ApRequestCreator.createSignedPost({
key: {
privateKeyPem: keypair.privateKey,
- keyId: `${this.config.url}/users/${user.id}#main-key`,
+ keyId: `${this.config.webUrl}/users/${user.id}#main-key`,
},
url,
body,
@@ -195,7 +195,7 @@ export class ApRequestService {
const req = ApRequestCreator.createSignedGet({
key: {
privateKeyPem: keypair.privateKey,
- keyId: `${this.config.url}/users/${user.id}#main-key`,
+ keyId: `${this.config.webUrl}/users/${user.id}#main-key`,
},
url,
additionalHeaders: {
diff --git a/packages/backend/src/core/activitypub/models/ApPersonService.ts b/packages/backend/src/core/activitypub/models/ApPersonService.ts
index f1a2522c04..8870395a1b 100644
--- a/packages/backend/src/core/activitypub/models/ApPersonService.ts
+++ b/packages/backend/src/core/activitypub/models/ApPersonService.ts
@@ -252,7 +252,7 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
if (cached) return cached;
// URIがこのサーバーを指しているならデータベースからフェッチ
- if (uri.startsWith(`${this.config.url}/`)) {
+ if (uri.startsWith(`${this.config.webUrl}/`) || uri.startsWith(`${this.config.localUrl}/`)) {
const id = uri.split('/').pop();
const u = await this.usersRepository.findOneBy({ id }) as MiLocalUser | null;
if (u) this.cacheService.uriPersonCache.set(uri, u);
@@ -327,7 +327,8 @@ export class ApPersonService implements OnModuleInit, OnApplicationShutdown {
if (typeof uri !== 'string') throw new UnrecoverableError(`failed to create user ${uri}: input is not string`);
const host = this.utilityService.punyHost(uri);
- if (host === this.utilityService.toPuny(this.config.host)) {
+ if ((host === this.utilityService.toPuny(this.config.localHost)) ||
+ (host === this.utilityService.toPuny(this.config.webHost))) {
throw new UnrecoverableError(`failed to create user ${uri}: URI is local`);
}
diff --git a/packages/backend/src/core/entities/DriveFileEntityService.ts b/packages/backend/src/core/entities/DriveFileEntityService.ts
index c485555f90..06b20928a1 100644
--- a/packages/backend/src/core/entities/DriveFileEntityService.ts
+++ b/packages/backend/src/core/entities/DriveFileEntityService.ts
@@ -119,7 +119,7 @@ export class DriveFileEntityService {
const key = file.webpublicAccessKey;
if (key && !key.match('/')) { // 古いものはここにオブジェクトストレージキーが入ってるので除外
- const url = `${this.config.url}/files/${key}`;
+ const url = `${this.config.webUrl}/files/${key}`;
if (mode === 'avatar') return this.getProxiedUrl(file.uri, 'avatar');
return url;
}
diff --git a/packages/backend/src/core/entities/MetaEntityService.ts b/packages/backend/src/core/entities/MetaEntityService.ts
index 294187feba..79e9c90528 100644
--- a/packages/backend/src/core/entities/MetaEntityService.ts
+++ b/packages/backend/src/core/entities/MetaEntityService.ts
@@ -73,7 +73,7 @@ export class MetaEntityService {
name: instance.name,
shortName: instance.shortName,
- uri: this.config.url,
+ uri: this.config.webUrl,
description: instance.description,
langs: instance.langs,
tosUrl: instance.termsOfServiceUrl,
diff --git a/packages/backend/src/core/entities/NoteEntityService.ts b/packages/backend/src/core/entities/NoteEntityService.ts
index 4248fde77f..03f7ced909 100644
--- a/packages/backend/src/core/entities/NoteEntityService.ts
+++ b/packages/backend/src/core/entities/NoteEntityService.ts
@@ -833,6 +833,6 @@ export class NoteEntityService implements OnModuleInit {
@bindThis
public genLocalNoteUri(noteId: string): string {
- return `${this.config.url}/notes/${noteId}`;
+ return `${this.config.webUrl}/notes/${noteId}`;
}
}
diff --git a/packages/backend/src/core/entities/UserEntityService.ts b/packages/backend/src/core/entities/UserEntityService.ts
index 638eaac16f..c88632b856 100644
--- a/packages/backend/src/core/entities/UserEntityService.ts
+++ b/packages/backend/src/core/entities/UserEntityService.ts
@@ -400,10 +400,10 @@ export class UserEntityService implements OnModuleInit {
@bindThis
public getIdenticonUrl(user: MiUser): string {
- if ((user.host == null || user.host === this.config.host) && user.username.includes('.') && this.meta.iconUrl) { // ローカルのシステムアカウントの場合
+ if ((user.host == null || user.host === this.config.localHost) && user.username.includes('.') && this.meta.iconUrl) { // ローカルのシステムアカウントの場合
return this.meta.iconUrl;
} else {
- return `${this.config.url}/identicon/${user.username.toLowerCase()}@${user.host ?? this.config.host}`;
+ return `${this.config.webUrl}/identicon/${user.username.toLowerCase()}@${user.host ?? this.config.localHost}`;
}
}
@@ -415,7 +415,7 @@ export class UserEntityService implements OnModuleInit {
@bindThis
public genLocalUserUri(userId: string): string {
- return `${this.config.url}/users/${userId}`;
+ return `${this.config.webUrl}/users/${userId}`;
}
public async pack<S extends 'MeDetailed' | 'UserDetailedNotMe' | 'UserDetailed' | 'UserLite' = 'UserLite'>(
@@ -531,7 +531,7 @@ export class UserEntityService implements OnModuleInit {
...announcement,
})) : null;
- const checkHost = user.host == null ? this.config.host : user.host;
+ const checkHost = user.host == null ? this.config.localHost : user.host;
const notificationsInfo = isMe && isDetailed ? await this.getNotificationsInfo(user.id) : null;
let fetchPoliciesPromise: Promise<RolePolicies> | null = null;
diff --git a/packages/backend/src/queue/processors/ExportAccountDataProcessorService.ts b/packages/backend/src/queue/processors/ExportAccountDataProcessorService.ts
index 58d542635f..1410874f02 100644
--- a/packages/backend/src/queue/processors/ExportAccountDataProcessorService.ts
+++ b/packages/backend/src/queue/processors/ExportAccountDataProcessorService.ts
@@ -125,7 +125,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeUser(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","user":[`);
+ await writeUser(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","user":[`);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { host, uri, sharedInbox, followersUri, lastFetchedAt, inbox, ...userTrimmed } = user;
@@ -160,7 +160,7 @@ export class ExportAccountDataProcessorService {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { emailVerifyCode, twoFactorBackupSecret, twoFactorSecret, password, twoFactorTempSecret, userHost, ...profileTrimmed } = profile;
- await writeProfile(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","profile":[`);
+ await writeProfile(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","profile":[`);
await writeProfile(JSON.stringify(profileTrimmed));
@@ -191,7 +191,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeIPs(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","ips":[`);
+ await writeIPs(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","ips":[`);
for (const signin of signins) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -226,7 +226,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeNotes(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","notes":[`);
+ await writeNotes(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","notes":[`);
let noteCursor: MiNote['id'] | null = null;
let exportedNotesCount = 0;
@@ -287,7 +287,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeFollowing(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","followings":[`);
+ await writeFollowing(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","followings":[`);
let followingsCursor: MiFollowing['id'] | null = null;
let exportedFollowingsCount = 0;
@@ -357,7 +357,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeFollowers(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","followers":[`);
+ await writeFollowers(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","followers":[`);
let followersCursor: MiFollowing['id'] | null = null;
let exportedFollowersCount = 0;
@@ -420,7 +420,7 @@ export class ExportAccountDataProcessorService {
fs.mkdirSync(`${path}/files`);
- await writeDrive(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","drive":[`);
+ await writeDrive(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","drive":[`);
const driveFiles = await this.driveFilesRepository.find({ where: { userId: user.id } });
@@ -476,7 +476,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeMuting(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","mutings":[`);
+ await writeMuting(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","mutings":[`);
let exportedMutingCount = 0;
let mutingCursor: MiMuting['id'] | null = null;
@@ -539,7 +539,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeBlocking(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","blockings":[`);
+ await writeBlocking(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","blockings":[`);
let exportedBlockingCount = 0;
let blockingCursor: MiBlocking['id'] | null = null;
@@ -601,7 +601,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeFavorite(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","favorites":[`);
+ await writeFavorite(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","favorites":[`);
let exportedFavoritesCount = 0;
let favoriteCursor: MiNoteFavorite['id'] | null = null;
@@ -662,7 +662,7 @@ export class ExportAccountDataProcessorService {
});
};
- await writeAntenna(`{"metaVersion":1,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","antennas":[`);
+ await writeAntenna(`{"metaVersion":1,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","antennas":[`);
const antennas = await this.antennasRepository.findBy({ userId: user.id });
diff --git a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
index b8f208bbfc..d3edc7890b 100644
--- a/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
+++ b/packages/backend/src/queue/processors/ExportCustomEmojisProcessorService.ts
@@ -76,7 +76,7 @@ export class ExportCustomEmojisProcessorService {
});
};
- await writeMeta(`{"metaVersion":2,"host":"${this.config.host}","exportedAt":"${new Date().toString()}","emojis":[`);
+ await writeMeta(`{"metaVersion":2,"host":"${this.config.webHost}","exportedAt":"${new Date().toString()}","emojis":[`);
const customEmojis = await this.emojisRepository.find({
where: {
diff --git a/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts b/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts
index f9fcd1e928..a3c0c47162 100644
--- a/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts
+++ b/packages/backend/src/queue/processors/SystemWebhookDeliverProcessorService.ts
@@ -42,13 +42,13 @@ export class SystemWebhookDeliverProcessorService {
method: 'POST',
headers: {
'User-Agent': 'Misskey-Hooks',
- 'X-Misskey-Host': this.config.host,
+ 'X-Misskey-Host': this.config.webHost,
'X-Misskey-Hook-Id': job.data.webhookId,
'X-Misskey-Hook-Secret': job.data.secret,
'Content-Type': 'application/json',
},
body: JSON.stringify({
- server: this.config.url,
+ server: this.config.webUrl,
hookId: job.data.webhookId,
eventId: job.data.eventId,
createdAt: job.data.createdAt,
diff --git a/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts b/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts
index 0208ce6038..411f6023a8 100644
--- a/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts
+++ b/packages/backend/src/queue/processors/UserWebhookDeliverProcessorService.ts
@@ -41,13 +41,13 @@ export class UserWebhookDeliverProcessorService {
method: 'POST',
headers: {
'User-Agent': 'Misskey-Hooks',
- 'X-Misskey-Host': this.config.host,
+ 'X-Misskey-Host': this.config.webHost,
'X-Misskey-Hook-Id': job.data.webhookId,
'X-Misskey-Hook-Secret': job.data.secret,
'Content-Type': 'application/json',
},
body: JSON.stringify({
- server: this.config.url,
+ server: this.config.webUrl,
hookId: job.data.webhookId,
userId: job.data.userId,
eventId: job.data.eventId,
diff --git a/packages/backend/src/server/ActivityPubServerService.ts b/packages/backend/src/server/ActivityPubServerService.ts
index 27d25d2152..9a8309b41c 100644
--- a/packages/backend/src/server/ActivityPubServerService.ts
+++ b/packages/backend/src/server/ActivityPubServerService.ts
@@ -114,7 +114,7 @@ export class ActivityPubServerService {
private async packActivity(note: MiNote, author: MiUser): Promise<ICreate | IAnnounce> {
if (isRenote(note) && !isQuote(note)) {
const renote = await this.notesRepository.findOneByOrFail({ id: note.renoteId });
- return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`, note);
+ return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.webUrl}/notes/${renote.id}`, note);
}
return this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, author, false), note);
@@ -196,7 +196,7 @@ export class ActivityPubServerService {
const logPrefix = `${request.id} ${request.url} (by ${request.headers['user-agent']}) claims to be from ${keyHost}:`;
- if (signature.params.headers.indexOf('host') === -1 || request.headers.host !== this.config.host) {
+ if (signature.params.headers.indexOf('host') === -1 || (request.headers.host !== this.config.localHost && request.headers.host !== this.config.webHost)) {
// no destination host, or not us: refuse
return `${logPrefix} no destination host, or not us: refuse`;
}
@@ -292,7 +292,7 @@ export class ActivityPubServerService {
}
if (signature.params.headers.indexOf('host') === -1
- || request.headers.host !== this.config.host) {
+ || (request.headers.host !== this.config.localHost && request.headers.host !== this.config.webHost)) {
// Host not specified or not match.
reply.code(401);
return;
@@ -394,7 +394,7 @@ export class ActivityPubServerService {
//#endregion
const limit = 10;
- const partOf = `${this.config.url}/users/${userId}/followers`;
+ const partOf = `${this.config.webUrl}/users/${userId}/followers`;
if (page) {
const query = {
@@ -491,7 +491,7 @@ export class ActivityPubServerService {
//#endregion
const limit = 10;
- const partOf = `${this.config.url}/users/${userId}/following`;
+ const partOf = `${this.config.webUrl}/users/${userId}/following`;
if (page) {
const query = {
@@ -576,7 +576,7 @@ export class ActivityPubServerService {
const renderedNotes = await Promise.all(pinnedNotes.map(note => this.apRendererService.renderNote(note, user)));
const rendered = this.apRendererService.renderOrderedCollection(
- `${this.config.url}/users/${userId}/collections/featured`,
+ `${this.config.webUrl}/users/${userId}/collections/featured`,
renderedNotes.length,
undefined,
undefined,
@@ -635,7 +635,7 @@ export class ActivityPubServerService {
}
const limit = 20;
- const partOf = `${this.config.url}/users/${userId}/outbox`;
+ const partOf = `${this.config.webUrl}/users/${userId}/outbox`;
if (page) {
const notes = this.meta.enableFanoutTimeline ? await this.fanoutTimelineEndpointService.getMiNotes({
diff --git a/packages/backend/src/server/FileServerService.ts b/packages/backend/src/server/FileServerService.ts
index 0910c0d36b..2931c785f4 100644
--- a/packages/backend/src/server/FileServerService.ts
+++ b/packages/backend/src/server/FileServerService.ts
@@ -93,7 +93,7 @@ export class FileServerService {
.catch(err => this.errorHandler(request, reply, err));
});
fastify.get<{ Params: { key: string; } }>('/files/:key/*', async (request, reply) => {
- return await reply.redirect(`${this.config.url}/files/${request.params.key}`, 301);
+ return await reply.redirect(`${this.config.webUrl}/files/${request.params.key}`, 301);
});
done();
});
@@ -524,8 +524,8 @@ export class FileServerService {
| '404'
| '204'
> {
- if (url.startsWith(`${this.config.url}/files/`)) {
- const key = url.replace(`${this.config.url}/files/`, '').split('/').shift();
+ if (url.startsWith(`${this.config.webUrl}/files/`)) {
+ const key = url.replace(`${this.config.webUrl}/files/`, '').split('/').shift();
if (!key) throw new StatusError(`Invalid file URL ${url}`, 400, 'Invalid file url');
return await this.getFileFromKey(key);
diff --git a/packages/backend/src/server/NodeinfoServerService.ts b/packages/backend/src/server/NodeinfoServerService.ts
index 55e8827696..7210d824ce 100644
--- a/packages/backend/src/server/NodeinfoServerService.ts
+++ b/packages/backend/src/server/NodeinfoServerService.ts
@@ -37,10 +37,10 @@ export class NodeinfoServerService {
public getLinks() {
return [{
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.1',
- href: this.config.url + nodeinfo2_1path,
+ href: this.config.webUrl + nodeinfo2_1path,
}, {
rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0',
- href: this.config.url + nodeinfo2_0path,
+ href: this.config.webUrl + nodeinfo2_0path,
}];
}
diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts
index 77b4519570..0d8fc9adbe 100644
--- a/packages/backend/src/server/ServerService.ts
+++ b/packages/backend/src/server/ServerService.ts
@@ -85,7 +85,7 @@ export class ServerService implements OnApplicationShutdown {
// HSTS
// 6months (15552000sec)
- if (this.config.url.startsWith('https') && !this.config.disableHsts) {
+ if (this.config.webUrl.startsWith('https') && !this.config.disableHsts) {
fastify.addHook('onRequest', (request, reply, done) => {
reply.header('strict-transport-security', 'max-age=15552000; preload');
done();
@@ -126,7 +126,7 @@ export class ServerService implements OnApplicationShutdown {
}
const effectiveLocation = process.env.NODE_ENV === 'production' ? location : location.replace(/^http:\/\//, 'https://');
- if (effectiveLocation.startsWith(`https://${this.config.host}/`)) {
+ if (effectiveLocation.startsWith(`https://${this.config.webHost}/`)) {
done();
return;
}
@@ -216,7 +216,7 @@ export class ServerService implements OnApplicationShutdown {
const user = await this.usersRepository.findOne({
where: {
usernameLower: username.toLowerCase(),
- host: (host == null) || (host === this.config.host) ? IsNull() : host,
+ host: (host == null) || (host === this.config.localHost) ? IsNull() : host,
isSuspended: false,
},
});
diff --git a/packages/backend/src/server/WellKnownServerService.ts b/packages/backend/src/server/WellKnownServerService.ts
index f48310c50f..fa6e095fd2 100644
--- a/packages/backend/src/server/WellKnownServerService.ts
+++ b/packages/backend/src/server/WellKnownServerService.ts
@@ -78,7 +78,7 @@ export class WellKnownServerService {
return XRD({ element: 'Link', attributes: {
rel: 'lrdd',
type: xrd,
- template: `${this.config.url}${webFingerPath}?resource={uri}`,
+ template: `${this.config.webUrl}${webFingerPath}?resource={uri}`,
} });
});
@@ -93,7 +93,7 @@ export class WellKnownServerService {
links: [{
rel: 'lrdd',
type: jrd,
- template: `${this.config.url}${webFingerPath}?resource={uri}`,
+ template: `${this.config.webUrl}${webFingerPath}?resource={uri}`,
}],
};
});
@@ -129,15 +129,15 @@ fastify.get('/.well-known/change-password', async (request, reply) => {
});
const generateQuery = (resource: string): FindOptionsWhere<MiUser> | number =>
- resource.startsWith(`${this.config.url.toLowerCase()}/users/`) ?
+ resource.startsWith(`${this.config.webUrl.toLowerCase()}/users/`) ?
fromId(resource.split('/').pop()!) :
fromAcct(Acct.parse(
- resource.startsWith(`${this.config.url.toLowerCase()}/@`) ? resource.split('/').pop()! :
+ resource.startsWith(`${this.config.localUrl.toLowerCase()}/@`) ? resource.split('/').pop()! :
resource.startsWith('acct:') ? resource.slice('acct:'.length) :
resource));
const fromAcct = (acct: Acct.Acct): FindOptionsWhere<MiUser> | number =>
- !acct.host || acct.host === this.config.host.toLowerCase() ? {
+ !acct.host || acct.host === this.config.localHost.toLowerCase() || acct.host === this.config.webHost.toLowerCase() ? {
usernameLower: acct.username.toLowerCase(),
host: IsNull(),
isSuspended: false,
@@ -162,8 +162,8 @@ fastify.get('/.well-known/change-password', async (request, reply) => {
return;
}
- const subject = `acct:${user.username}@${this.config.host}`;
- const profileLink = `${this.config.url}/@${user.username}`;
+ const subject = `acct:${user.username}@${this.config.localHost}`;
+ const profileLink = `${this.config.webUrl}/@${user.username}`;
const self = {
rel: 'self',
type: 'application/activity+json',
@@ -176,7 +176,7 @@ fastify.get('/.well-known/change-password', async (request, reply) => {
};
const subscribe = {
rel: 'http://ostatus.org/schema/1.0/subscribe',
- template: `${this.config.url}/authorize-follow?acct={uri}`,
+ template: `${this.config.webUrl}/authorize-follow?acct={uri}`,
};
vary(reply.raw, 'Accept');
diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts
index a53fec88d0..e6c918d6f4 100644
--- a/packages/backend/src/server/api/SigninApiService.ts
+++ b/packages/backend/src/server/api/SigninApiService.ts
@@ -88,7 +88,7 @@ export class SigninApiService {
}>,
reply: FastifyReply,
) {
- reply.header('Access-Control-Allow-Origin', this.config.url);
+ reply.header('Access-Control-Allow-Origin', this.config.webUrl);
reply.header('Access-Control-Allow-Credentials', 'true');
const body = request.body;
diff --git a/packages/backend/src/server/api/SigninWithPasskeyApiService.ts b/packages/backend/src/server/api/SigninWithPasskeyApiService.ts
index 38886f8876..a2e0a43c15 100644
--- a/packages/backend/src/server/api/SigninWithPasskeyApiService.ts
+++ b/packages/backend/src/server/api/SigninWithPasskeyApiService.ts
@@ -62,7 +62,7 @@ export class SigninWithPasskeyApiService {
}>,
reply: FastifyReply,
) {
- reply.header('Access-Control-Allow-Origin', this.config.url);
+ reply.header('Access-Control-Allow-Origin', this.config.webUrl);
reply.header('Access-Control-Allow-Credentials', 'true');
const body = request.body;
diff --git a/packages/backend/src/server/api/SignupApiService.ts b/packages/backend/src/server/api/SignupApiService.ts
index 81e3a5b706..3d2b003796 100644
--- a/packages/backend/src/server/api/SignupApiService.ts
+++ b/packages/backend/src/server/api/SignupApiService.ts
@@ -215,7 +215,7 @@ export class SignupApiService {
reason: reason,
});
- const link = `${this.config.url}/signup-complete/${code}`;
+ const link = `${this.config.webUrl}/signup-complete/${code}`;
this.emailService.sendEmail(emailAddress!, 'Signup',
`To complete signup, please click this link:<br><a href="${link}">${link}</a>`,
diff --git a/packages/backend/src/server/api/endpoints/admin/meta.ts b/packages/backend/src/server/api/endpoints/admin/meta.ts
index fe8ca012b2..4f9187f8ca 100644
--- a/packages/backend/src/server/api/endpoints/admin/meta.ts
+++ b/packages/backend/src/server/api/endpoints/admin/meta.ts
@@ -644,7 +644,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
version: this.config.version,
name: instance.name,
shortName: instance.shortName,
- uri: this.config.url,
+ uri: this.config.webUrl,
description: instance.description,
langs: instance.langs,
tosUrl: instance.termsOfServiceUrl,
diff --git a/packages/backend/src/server/api/endpoints/i/2fa/register.ts b/packages/backend/src/server/api/endpoints/i/2fa/register.ts
index 6fde3a90a7..0d47269c1c 100644
--- a/packages/backend/src/server/api/endpoints/i/2fa/register.ts
+++ b/packages/backend/src/server/api/endpoints/i/2fa/register.ts
@@ -101,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
secret,
digits: 6,
label: me.username,
- issuer: this.config.host,
+ issuer: this.config.webHost,
});
const url = totp.toString();
const qr = await QRCode.toDataURL(url);
@@ -111,7 +111,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
url,
secret: secret.base32,
label: me.username,
- issuer: this.config.host,
+ issuer: this.config.webHost,
};
});
}
diff --git a/packages/backend/src/server/api/endpoints/i/update-email.ts b/packages/backend/src/server/api/endpoints/i/update-email.ts
index dc07556760..46bfa662d6 100644
--- a/packages/backend/src/server/api/endpoints/i/update-email.ts
+++ b/packages/backend/src/server/api/endpoints/i/update-email.ts
@@ -131,7 +131,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
emailVerifyCode: code,
});
- const link = `${this.config.url}/verify-email/${code}`;
+ const link = `${this.config.webUrl}/verify-email/${code}`;
this.emailService.sendEmail(ps.email, 'Email verification',
`To verify email, please click this link:<br><a href="${link}">${link}</a>`,
diff --git a/packages/backend/src/server/api/endpoints/i/update.ts b/packages/backend/src/server/api/endpoints/i/update.ts
index 65dcf6301f..fa417b5fa0 100644
--- a/packages/backend/src/server/api/endpoints/i/update.ts
+++ b/packages/backend/src/server/api/endpoints/i/update.ts
@@ -605,7 +605,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const profileUrls = [
this.userEntityService.genLocalUserUri(user.id),
- `${this.config.url}/@${user.username}`,
+ `${this.config.webUrl}/@${user.username}`,
];
const verifiedLinks = await verifyFieldLinks(newFields, profileUrls, this.httpRequestService);
@@ -651,7 +651,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const { window } = new JSDOM(html);
const doc: Document = window.document;
- const myLink = `${this.config.url}/@${user.username}`;
+ const myLink = `${this.config.webUrl}/@${user.username}`;
const aEls = Array.from(doc.getElementsByTagName('a'));
const linkEls = Array.from(doc.getElementsByTagName('link'));
diff --git a/packages/backend/src/server/api/endpoints/request-reset-password.ts b/packages/backend/src/server/api/endpoints/request-reset-password.ts
index 86fe6a2e6e..9f4acec44e 100644
--- a/packages/backend/src/server/api/endpoints/request-reset-password.ts
+++ b/packages/backend/src/server/api/endpoints/request-reset-password.ts
@@ -89,7 +89,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
token,
});
- const link = `${this.config.url}/reset-password/${token}`;
+ const link = `${this.config.webUrl}/reset-password/${token}`;
this.emailService.sendEmail(ps.email, 'Password reset requested',
`To reset password, please click this link:<br><a href="${link}">${link}</a>`,
diff --git a/packages/backend/src/server/api/mastodon/MastodonConverters.ts b/packages/backend/src/server/api/mastodon/MastodonConverters.ts
index df8d68042a..02fa9ac85e 100644
--- a/packages/backend/src/server/api/mastodon/MastodonConverters.ts
+++ b/packages/backend/src/server/api/mastodon/MastodonConverters.ts
@@ -72,7 +72,7 @@ export class MastodonConverters {
private encode(u: MiUser, m: IMentionedRemoteUsers): MastodonEntity.Mention {
let acct = u.username;
- let acctUrl = `https://${u.host || this.config.host}/@${u.username}`;
+ let acctUrl = `https://${u.host || this.config.webHost}/@${u.username}`;
let url: string | null = null;
if (u.host) {
const info = m.find(r => r.username === u.username && r.host === u.host);
@@ -150,7 +150,7 @@ export class MastodonConverters {
public async convertAccount(account: Entity.Account | MiUser): Promise<MastodonEntity.Account> {
const user = await this.getUser(account.id);
const profile = await this.userProfilesRepository.findOneBy({ userId: user.id });
- const emojis = await this.customEmojiService.populateEmojis(user.emojis, user.host ? user.host : this.config.host);
+ const emojis = await this.customEmojiService.populateEmojis(user.emojis, user.host ? user.host : this.config.localHost);
const emoji: Entity.Emoji[] = [];
Object.entries(emojis).forEach(entry => {
const [key, value] = entry;
@@ -162,10 +162,10 @@ export class MastodonConverters {
category: undefined,
});
});
- const fqn = `${user.username}@${user.host ?? this.config.hostname}`;
+ const fqn = `${user.username}@${user.host ?? this.config.localHostname}`;
let acct = user.username;
- let acctUrl = `https://${user.host || this.config.host}/@${user.username}`;
- const acctUri = `https://${this.config.host}/users/${user.id}`;
+ let acctUrl = `https://${user.host || this.config.webHost}/@${user.username}`;
+ const acctUri = `https://${this.config.webHost}/users/${user.id}`;
if (user.host) {
acct = `${user.username}@${user.host}`;
acctUrl = `https://${user.host}/@${user.username}`;
@@ -228,7 +228,7 @@ export class MastodonConverters {
const isQuote = renote && (edit.cw || edit.newText || edit.fileIds.length > 0 || note.replyId);
const quoteUri = isQuote
- ? renote.url ?? renote.uri ?? `${this.config.url}/notes/${renote.id}`
+ ? renote.url ?? renote.uri ?? `${this.config.webUrl}/notes/${renote.id}`
: null;
const item = {
@@ -258,7 +258,7 @@ export class MastodonConverters {
const noteUser = hints?.user ?? note.user ?? await this.getUser(status.account.id);
const mentionedRemoteUsers = JSON.parse(note.mentionedRemoteUsers);
- const emojis = await this.customEmojiService.populateEmojis(note.emojis, noteUser.host ? noteUser.host : this.config.host);
+ const emojis = await this.customEmojiService.populateEmojis(note.emojis, noteUser.host ? noteUser.host : this.config.localHost);
const emoji: Entity.Emoji[] = [];
Object.entries(emojis).forEach(entry => {
const [key, value] = entry;
@@ -280,7 +280,7 @@ export class MastodonConverters {
const tags = note.tags.map(tag => {
return {
name: tag,
- url: `${this.config.url}/tags/${tag}`,
+ url: `${this.config.webUrl}/tags/${tag}`,
} as Entity.Tag;
});
@@ -291,7 +291,7 @@ export class MastodonConverters {
const quoteUri = Promise.resolve(renote).then(renote => {
if (!renote || !isQuote) return null;
- return renote.url ?? renote.uri ?? `${this.config.url}/notes/${renote.id}`;
+ return renote.url ?? renote.uri ?? `${this.config.webUrl}/notes/${renote.id}`;
});
const text = note.text;
@@ -306,8 +306,8 @@ export class MastodonConverters {
// noinspection ES6MissingAwait
return await awaitAll({
id: note.id,
- uri: note.uri ?? `https://${this.config.host}/notes/${note.id}`,
- url: note.url ?? note.uri ?? `https://${this.config.host}/notes/${note.id}`,
+ uri: note.uri ?? `https://${this.config.webHost}/notes/${note.id}`,
+ url: note.url ?? note.uri ?? `https://${this.config.webHost}/notes/${note.id}`,
account: convertedAccount,
in_reply_to_id: note.replyId,
in_reply_to_account_id: note.replyUserId,
diff --git a/packages/backend/src/server/api/mastodon/endpoints/instance.ts b/packages/backend/src/server/api/mastodon/endpoints/instance.ts
index cfca5b1350..178ecc91e8 100644
--- a/packages/backend/src/server/api/mastodon/endpoints/instance.ts
+++ b/packages/backend/src/server/api/mastodon/endpoints/instance.ts
@@ -39,7 +39,7 @@ export class ApiInstanceMastodon {
const instance = data.data;
const response: MastodonEntity.Instance = {
- uri: this.config.host,
+ uri: this.config.webHost,
title: this.meta.name || 'Sharkey',
description: this.meta.description || 'This is a vanilla Sharkey Instance. It doesn\'t seem to have a description.',
email: instance.email || '',
diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts
index 01ee451297..45d24686de 100644
--- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts
+++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts
@@ -62,9 +62,9 @@ export class OAuth2ProviderService {
// https://indieauth.spec.indieweb.org/#indieauth-server-metadata
public generateRFC8414() {
return {
- issuer: this.config.url,
- authorization_endpoint: new URL('/oauth/authorize', this.config.url),
- token_endpoint: new URL('/oauth/token', this.config.url),
+ issuer: this.config.webUrl,
+ authorization_endpoint: new URL('/oauth/authorize', this.config.webUrl),
+ token_endpoint: new URL('/oauth/token', this.config.webUrl),
scopes_supported: kinds,
response_types_supported: ['code'],
grant_types_supported: ['authorization_code'],
@@ -80,9 +80,9 @@ export class OAuth2ProviderService {
// https://indieauth.spec.indieweb.org/#indieauth-server-metadata
/* fastify.get('/.well-known/oauth-authorization-server', async (_request, reply) => {
reply.send({
- issuer: this.config.url,
- authorization_endpoint: new URL('/oauth/authorize', this.config.url),
- token_endpoint: new URL('/oauth/token', this.config.url),
+ issuer: this.config.webUrl,
+ authorization_endpoint: new URL('/oauth/authorize', this.config.webUrl),
+ token_endpoint: new URL('/oauth/token', this.config.webUrl),
scopes_supported: kinds,
response_types_supported: ['code'],
grant_types_supported: ['authorization_code'],
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index c40d042fa4..2df92e4607 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -150,10 +150,10 @@ export class ClientServerService {
let manifest = {
// 空文字列の場合右辺を使いたいため
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- 'short_name': this.meta.shortName || this.meta.name || this.config.host,
+ 'short_name': this.meta.shortName || this.meta.name || this.config.webHost,
// 空文字列の場合右辺を使いたいため
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
- 'name': this.meta.name || this.config.host,
+ 'name': this.meta.name || this.config.webHost,
'start_url': '/',
'display': 'standalone',
'background_color': '#313a42',
@@ -213,7 +213,8 @@ export class ClientServerService {
serverErrorImageUrl: meta.serverErrorImageUrl ?? '/client-assets/status/error.png',
infoImageUrl: meta.infoImageUrl ?? '/client-assets/status/nothinghere.png',
notFoundImageUrl: meta.notFoundImageUrl ?? '/client-assets/status/missingpage.webp',
- instanceUrl: this.config.url,
+ instanceUrl: this.config.webUrl,
+ localUrl: this.config.localUrl,
randomMOTD: this.config.customMOTD ? this.config.customMOTD[Math.floor(Math.random() * this.config.customMOTD.length)] : undefined,
metaJson: htmlSafeJsonStringify(await this.metaEntityService.packDetailed(meta)),
now: Date.now(),
@@ -441,8 +442,8 @@ export class ClientServerService {
content += `<ShortName>${name}</ShortName>`;
content += `<Description>${name} Search</Description>`;
content += '<InputEncoding>UTF-8</InputEncoding>';
- content += `<Image width="16" height="16" type="image/x-icon">${this.config.url}/favicon.ico</Image>`;
- content += `<Url type="text/html" template="${this.config.url}/search?q={searchTerms}"/>`;
+ content += `<Image width="16" height="16" type="image/x-icon">${this.config.webUrl}/favicon.ico</Image>`;
+ content += `<Url type="text/html" template="${this.config.webUrl}/search?q={searchTerms}"/>`;
content += '</OpenSearchDescription>';
reply.header('Content-Type', 'application/opensearchdescription+xml');
@@ -455,7 +456,7 @@ export class ClientServerService {
reply.header('Cache-Control', 'public, max-age=30');
return await reply.view('base', {
img: this.meta.bannerUrl,
- url: this.config.url,
+ url: this.config.webUrl,
title: this.meta.name ?? 'Sharkey',
desc: this.meta.description,
customHead: this.config.customHtml.head,
@@ -889,8 +890,8 @@ export class ClientServerService {
return await reply.view('info-card', {
version: this.config.version,
- host: this.config.host,
- url: this.config.url,
+ host: this.config.webHost,
+ url: this.config.webUrl,
meta: this.meta,
originalUsersCount: await this.usersRepository.countBy({ host: IsNull() }),
originalNotesCount: await this.notesRepository.countBy({ userHost: IsNull() }),
diff --git a/packages/backend/src/server/web/FeedService.ts b/packages/backend/src/server/web/FeedService.ts
index a622ae7e34..e005a96732 100644
--- a/packages/backend/src/server/web/FeedService.ts
+++ b/packages/backend/src/server/web/FeedService.ts
@@ -42,7 +42,7 @@ export class FeedService {
@bindThis
public async packFeed(user: MiUser) {
const author = {
- link: `${this.config.url}/@${user.username}`,
+ link: `${this.config.webUrl}/@${user.username}`,
name: user.name ?? user.username,
};
@@ -60,7 +60,7 @@ export class FeedService {
const feed = new Feed({
id: author.link,
- title: `${author.name} (@${user.username}@${this.config.host})`,
+ title: `${author.name} (@${user.username}@${this.config.localHost})`,
updated: notes.length !== 0 ? this.idService.parse(notes[0].id).date : undefined,
generator: 'Sharkey',
description: `${user.notesCount} Notes, ${profile.followingVisibility === 'public' ? user.followingCount : '?'} Following, ${profile.followersVisibility === 'public' ? user.followersCount : '?'} Followers${profile.description ? ` · ${profile.description}` : ''}`,
@@ -92,7 +92,7 @@ export class FeedService {
feed.addItem({
title: `New note by ${author.name}`,
- link: `${this.config.url}/notes/${note.id}`,
+ link: `${this.config.webUrl}/notes/${note.id}`,
date: this.idService.parse(note.id).date,
description: note.cw ?? undefined,
content: text ? this.mfmService.toHtml(mfmParse(text), JSON.parse(note.mentionedRemoteUsers)) ?? undefined : undefined,
diff --git a/packages/backend/src/server/web/UrlPreviewService.ts b/packages/backend/src/server/web/UrlPreviewService.ts
index 71a142fc6f..6168fb3602 100644
--- a/packages/backend/src/server/web/UrlPreviewService.ts
+++ b/packages/backend/src/server/web/UrlPreviewService.ts
@@ -477,7 +477,7 @@ export class UrlPreviewService {
const url = URL.parse(summary.url);
const acct = Acct.parse(summary.fediverseCreator);
- if (acct.host?.toLowerCase() === this.config.host) {
+ if (acct.host?.toLowerCase() === this.config.localHost) {
acct.host = null;
}
try {
diff --git a/packages/backend/src/server/web/views/announcement.pug b/packages/backend/src/server/web/views/announcement.pug
index 7a4052e8a4..2b35480c63 100644
--- a/packages/backend/src/server/web/views/announcement.pug
+++ b/packages/backend/src/server/web/views/announcement.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const title = announcement.title;
- const description = announcement.text.length > 100 ? announcement.text.slice(0, 100) + '…' : announcement.text;
- - const url = `${config.url}/announcements/${announcement.id}`;
+ - const url = `${config.webUrl}/announcements/${announcement.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/base-embed.pug b/packages/backend/src/server/web/views/base-embed.pug
index 6ef9281b8f..ef7d02e42a 100644
--- a/packages/backend/src/server/web/views/base-embed.pug
+++ b/packages/backend/src/server/web/views/base-embed.pug
@@ -15,6 +15,7 @@ html(class='embed')
meta(name='theme-color-orig' content= themeColor || '#86b300')
meta(property='og:site_name' content= instanceName || 'Sharkey')
meta(property='instance_url' content= instanceUrl)
+ meta(property='local_url' content= localUrl)
meta(name='viewport' content='width=device-width, initial-scale=1')
meta(name='format-detection' content='telephone=no,date=no,address=no,email=no,url=no')
link(rel='icon' href= icon || '/favicon.ico')
diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug
index d9d750281d..0bd6788a8d 100644
--- a/packages/backend/src/server/web/views/base.pug
+++ b/packages/backend/src/server/web/views/base.pug
@@ -2,7 +2,7 @@ block vars
block loadClientEntry
- const entry = config.frontendEntry;
- - const baseUrl = config.url;
+ - const baseUrl = config.webUrl;
doctype html
@@ -32,6 +32,7 @@ html
meta(name='theme-color-orig' content= themeColor || '#86b300')
meta(property='og:site_name' content= instanceName || 'Sharkey')
meta(property='instance_url' content= instanceUrl)
+ meta(property='local_url' content= localUrl)
meta(name='viewport' content='width=device-width, initial-scale=1')
meta(name='format-detection' content='telephone=no,date=no,address=no,email=no,url=no')
link(rel='icon' href= icon || '/favicon.ico')
diff --git a/packages/backend/src/server/web/views/channel.pug b/packages/backend/src/server/web/views/channel.pug
index c514025e0b..530d56b51f 100644
--- a/packages/backend/src/server/web/views/channel.pug
+++ b/packages/backend/src/server/web/views/channel.pug
@@ -2,7 +2,7 @@ extends ./base
block vars
- const title = channel.name;
- - const url = `${config.url}/channels/${channel.id}`;
+ - const url = `${config.webUrl}/channels/${channel.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/clip.pug b/packages/backend/src/server/web/views/clip.pug
index 5a0018803a..b6f2b02599 100644
--- a/packages/backend/src/server/web/views/clip.pug
+++ b/packages/backend/src/server/web/views/clip.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const user = clip.user;
- const title = clip.name;
- - const url = `${config.url}/clips/${clip.id}`;
+ - const url = `${config.webUrl}/clips/${clip.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/flash.pug b/packages/backend/src/server/web/views/flash.pug
index 1549aa7906..22961c6dcd 100644
--- a/packages/backend/src/server/web/views/flash.pug
+++ b/packages/backend/src/server/web/views/flash.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const user = flash.user;
- const title = flash.title;
- - const url = `${config.url}/play/${flash.id}`;
+ - const url = `${config.webUrl}/play/${flash.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/gallery-post.pug b/packages/backend/src/server/web/views/gallery-post.pug
index 9ae25d9ac8..4ed44d0a4b 100644
--- a/packages/backend/src/server/web/views/gallery-post.pug
+++ b/packages/backend/src/server/web/views/gallery-post.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const user = post.user;
- const title = post.title;
- - const url = `${config.url}/gallery/${post.id}`;
+ - const url = `${config.webUrl}/gallery/${post.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/note.pug b/packages/backend/src/server/web/views/note.pug
index 53cff6bcd3..9b755f60a2 100644
--- a/packages/backend/src/server/web/views/note.pug
+++ b/packages/backend/src/server/web/views/note.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const user = note.user;
- const title = user.name ? `${user.name} (@${user.username}${user.host ? `@${user.host}` : ''})` : `@${user.username}${user.host ? `@${user.host}` : ''}`;
- - const url = `${config.url}/notes/${note.id}`;
+ - const url = `${config.webUrl}/notes/${note.id}`;
- const isRenote = note.renote && note.text == null && note.fileIds.length == 0 && note.poll == null;
- const images = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('image/') && !file.isSensitive)
- const videos = note.cw ? [] : (note.files || []).filter(file => file.type.startsWith('video/') && !file.isSensitive)
@@ -52,9 +52,9 @@ block meta
meta(name='twitter:creator' content=`@${user.twitter.screenName}`)
if note.prev
- link(rel='prev' href=`${config.url}/notes/${note.prev}`)
+ link(rel='prev' href=`${config.webUrl}/notes/${note.prev}`)
if note.next
- link(rel='next' href=`${config.url}/notes/${note.next}`)
+ link(rel='next' href=`${config.webUrl}/notes/${note.next}`)
if !user.host
link(rel='alternate' href=url type='application/activity+json')
diff --git a/packages/backend/src/server/web/views/page.pug b/packages/backend/src/server/web/views/page.pug
index 03c50eca8a..fcd54fd05c 100644
--- a/packages/backend/src/server/web/views/page.pug
+++ b/packages/backend/src/server/web/views/page.pug
@@ -3,7 +3,7 @@ extends ./base
block vars
- const user = page.user;
- const title = page.title;
- - const url = `${config.url}/@${user.username}/pages/${page.name}`;
+ - const url = `${config.webUrl}/@${user.username}/pages/${page.name}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/reversi-game.pug b/packages/backend/src/server/web/views/reversi-game.pug
index 0b5ffb2bb0..6e0cd32e7f 100644
--- a/packages/backend/src/server/web/views/reversi-game.pug
+++ b/packages/backend/src/server/web/views/reversi-game.pug
@@ -4,7 +4,7 @@ block vars
- const user1 = game.user1;
- const user2 = game.user2;
- const title = `${user1.username} vs ${user2.username}`;
- - const url = `${config.url}/reversi/g/${game.id}`;
+ - const url = `${config.webUrl}/reversi/g/${game.id}`;
block title
= `${title} | ${instanceName}`
diff --git a/packages/backend/src/server/web/views/user.pug b/packages/backend/src/server/web/views/user.pug
index 2b0a7bab5c..7a023e255e 100644
--- a/packages/backend/src/server/web/views/user.pug
+++ b/packages/backend/src/server/web/views/user.pug
@@ -2,7 +2,7 @@ extends ./base
block vars
- const title = user.name ? `${user.name} (@${user.username}${user.host ? `@${user.host}` : ''})` : `@${user.username}${user.host ? `@${user.host}` : ''}`;
- - const url = `${config.url}/@${(user.host ? `${user.username}@${user.host}` : user.username)}`;
+ - const url = `${config.webUrl}/@${(user.host ? `${user.username}@${user.host}` : user.username)}`;
block title
= `${title} | ${instanceName}`
@@ -33,7 +33,7 @@ block meta
if !sub
if !user.host
- link(rel='alternate' href=`${config.url}/users/${user.id}` type='application/activity+json')
+ link(rel='alternate' href=`${config.webUrl}/users/${user.id}` type='application/activity+json')
if user.uri
link(rel='alternate' href=user.uri type='application/activity+json')
if profile.url
diff --git a/packages/backend/test/e2e/2fa.ts b/packages/backend/test/e2e/2fa.ts
index 289359a2ce..756a720652 100644
--- a/packages/backend/test/e2e/2fa.ts
+++ b/packages/backend/test/e2e/2fa.ts
@@ -53,7 +53,7 @@ describe('2要素認証', () => {
const rpIdHash = (): Buffer => {
return crypto.createHash('sha256')
- .update(Buffer.from(config.host, 'utf-8'))
+ .update(Buffer.from(config.webHost, 'utf-8'))
.digest();
};
@@ -103,7 +103,7 @@ describe('2要素認証', () => {
clientDataJSON: Buffer.from(JSON.stringify({
type: 'webauthn.create',
challenge: param.creationOptions.challenge,
- origin: config.scheme + '://' + config.host,
+ origin: config.scheme + '://' + config.webHost,
androidPackageName: 'org.mozilla.firefox',
}), 'utf-8').toString('base64url'),
attestationObject: cbor.encode({
@@ -149,7 +149,7 @@ describe('2要素認証', () => {
const clientDataJSONBuffer = Buffer.from(JSON.stringify({
type: 'webauthn.get',
challenge: param.requestOptions.challenge,
- origin: config.scheme + '://' + config.host,
+ origin: config.scheme + '://' + config.webHost,
androidPackageName: 'org.mozilla.firefox',
}), 'utf-8');
const hashedclientDataJSON = crypto.createHash('sha256')
@@ -191,7 +191,7 @@ describe('2要素認証', () => {
assert.notEqual(registerResponse.body.url, undefined);
assert.notEqual(registerResponse.body.secret, undefined);
assert.strictEqual(registerResponse.body.label, username);
- assert.strictEqual(registerResponse.body.issuer, config.host);
+ assert.strictEqual(registerResponse.body.issuer, config.webHost);
const doneResponse = await api('i/2fa/done', {
token: otpToken(registerResponse.body.secret),
diff --git a/packages/backend/test/e2e/move.ts b/packages/backend/test/e2e/move.ts
index fd798bdb25..b873570a9b 100644
--- a/packages/backend/test/e2e/move.ts
+++ b/packages/backend/test/e2e/move.ts
@@ -34,7 +34,7 @@ describe('Account Move', () => {
jq = await jobQueue();
const config = loadConfig();
- url = new URL(config.url);
+ url = new URL(config.webUrl);
const connection = await initTestDb(false);
root = await signup({ username: 'root' });
alice = await signup({ username: 'alice' });
diff --git a/packages/backend/test/unit/activitypub.ts b/packages/backend/test/unit/activitypub.ts
index ff93e1be07..8575159606 100644
--- a/packages/backend/test/unit/activitypub.ts
+++ b/packages/backend/test/unit/activitypub.ts
@@ -713,13 +713,13 @@ describe('ActivityPub', () => {
it('should include id', async () => {
const collection = await rendererService.renderRepliesCollection(note.id);
- expect(collection.id).toBe(`${config.url}/notes/${note.id}/replies`);
+ expect(collection.id).toBe(`${config.webUrl}/notes/${note.id}/replies`);
});
it('should include first', async () => {
const collection = await rendererService.renderRepliesCollection(note.id);
- expect(collection.first).toBe(`${config.url}/notes/${note.id}/replies?page=true`);
+ expect(collection.first).toBe(`${config.webUrl}/notes/${note.id}/replies?page=true`);
});
it('should include totalItems', async () => {
@@ -740,19 +740,19 @@ describe('ActivityPub', () => {
it('should include id', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, 'abc123');
- expect(collection.id).toBe(`${config.url}/notes/${note.id}/replies?page=true&until_id=abc123`);
+ expect(collection.id).toBe(`${config.webUrl}/notes/${note.id}/replies?page=true&until_id=abc123`);
});
it('should include partOf', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, 'abc123');
- expect(collection.partOf).toBe(`${config.url}/notes/${note.id}/replies`);
+ expect(collection.partOf).toBe(`${config.webUrl}/notes/${note.id}/replies`);
});
it('should include first', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, 'abc123');
- expect(collection.first).toBe(`${config.url}/notes/${note.id}/replies?page=true`);
+ expect(collection.first).toBe(`${config.webUrl}/notes/${note.id}/replies?page=true`);
});
it('should include totalItems', async () => {
@@ -778,19 +778,19 @@ describe('ActivityPub', () => {
it('should include id', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, undefined);
- expect(collection.id).toBe(`${config.url}/notes/${note.id}/replies?page=true`);
+ expect(collection.id).toBe(`${config.webUrl}/notes/${note.id}/replies?page=true`);
});
it('should include partOf', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, undefined);
- expect(collection.partOf).toBe(`${config.url}/notes/${note.id}/replies`);
+ expect(collection.partOf).toBe(`${config.webUrl}/notes/${note.id}/replies`);
});
it('should include first', async () => {
const collection = await rendererService.renderRepliesCollectionPage(note.id, undefined);
- expect(collection.first).toBe(`${config.url}/notes/${note.id}/replies?page=true`);
+ expect(collection.first).toBe(`${config.webUrl}/notes/${note.id}/replies?page=true`);
});
it('should include totalItems', async () => {
diff --git a/packages/backend/test/utils.ts b/packages/backend/test/utils.ts
index 52cfb8ac93..742f9fe97c 100644
--- a/packages/backend/test/utils.ts
+++ b/packages/backend/test/utils.ts
@@ -40,8 +40,8 @@ export type SystemWebhookPayload = {
const config = loadConfig();
export const port = config.port;
-export const origin = config.url;
-export const host = new URL(config.url).host;
+export const origin = config.webUrl;
+export const host = new URL(config.webUrl).host;
export const WEBHOOK_HOST = 'http://localhost:15080';
export const WEBHOOK_PORT = 15080;