diff options
Diffstat (limited to 'packages/backend/src/core')
23 files changed, 75 insertions, 71 deletions
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; |