diff options
| author | Freya Murphy <freya@freyacat.org> | 2026-03-02 16:05:12 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2026-03-02 18:39:22 -0500 |
| commit | 24734d408700a72d45c3ff4a679606cab3ec544f (patch) | |
| tree | d0fee0bcf508f3c631f7c26724bb5cd94dfc88a0 /packages/backend/src/server | |
| parent | merge: Release/2025.4.5 (!1258) (diff) | |
| download | sharkey-stable.tar.gz sharkey-stable.tar.bz2 sharkey-stable.zip | |
split url into webUrl and localUrl (like mastodon)stable
Diffstat (limited to 'packages/backend/src/server')
30 files changed, 79 insertions, 76 deletions
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 |