From e731f4b724c5ac69a31412c1d0f48e21aa256560 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 19 Oct 2023 16:13:22 +0200 Subject: [PATCH] Fix sitemap URL for accounts and channels --- server/core/controllers/sitemap.ts | 8 ++------ server/core/models/account/account.ts | 6 ++---- server/core/models/video/video-channel.ts | 3 +-- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/server/core/controllers/sitemap.ts b/server/core/controllers/sitemap.ts index 69aea6167..42fb54f7c 100644 --- a/server/core/controllers/sitemap.ts +++ b/server/core/controllers/sitemap.ts @@ -61,17 +61,13 @@ async function getSitemap (req: express.Request, res: express.Response) { async function getSitemapVideoChannelUrls () { const rows = await VideoChannelModel.listLocalsForSitemap('createdAt') - return rows.map(channel => ({ - url: WEBSERVER.URL + '/video-channels/' + channel.Actor.preferredUsername - })) + return rows.map(channel => ({ url: channel.getClientUrl() })) } async function getSitemapAccountUrls () { const rows = await AccountModel.listLocalsForSitemap('createdAt') - return rows.map(channel => ({ - url: WEBSERVER.URL + '/accounts/' + channel.Actor.preferredUsername - })) + return rows.map(account => ({ url: account.getClientUrl() })) } async function getSitemapLocalVideoUrls () { diff --git a/server/core/models/account/account.ts b/server/core/models/account/account.ts index 7c2660c40..6d1b204e4 100644 --- a/server/core/models/account/account.ts +++ b/server/core/models/account/account.ts @@ -23,9 +23,7 @@ import { isAccountDescriptionValid } from '../../helpers/custom-validators/accou import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants.js' import { sendDeleteActor } from '../../lib/activitypub/send/send-delete.js' import { - MAccount, - MAccountActor, - MAccountAP, + MAccount, MAccountAP, MAccountDefault, MAccountFormattable, MAccountHost, @@ -390,7 +388,7 @@ export class AccountModel extends Model>> { return AccountModel.findOne(query) } - static listLocalsForSitemap (sort: string): Promise { + static listLocalsForSitemap (sort: string): Promise { const query = { attributes: [ ], offset: 0, diff --git a/server/core/models/video/video-channel.ts b/server/core/models/video/video-channel.ts index 5a13fee24..5a6e1b384 100644 --- a/server/core/models/video/video-channel.ts +++ b/server/core/models/video/video-channel.ts @@ -34,7 +34,6 @@ import { import { CONSTRAINTS_FIELDS, WEBSERVER } from '../../initializers/constants.js' import { sendDeleteActor } from '../../lib/activitypub/send/index.js' import { - MChannelActor, MChannelAP, MChannelBannerAccountDefault, MChannelFormattable, @@ -500,7 +499,7 @@ export class VideoChannelModel extends Model { + static listLocalsForSitemap (sort: string): Promise { const query = { attributes: [ ], offset: 0,