summaryrefslogtreecommitdiff
path: root/packages/backend/src/server/api/mastodon
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/src/server/api/mastodon
parentmerge: Release/2025.4.5 (!1258) (diff)
downloadsharkey-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/api/mastodon')
-rw-r--r--packages/backend/src/server/api/mastodon/MastodonConverters.ts22
-rw-r--r--packages/backend/src/server/api/mastodon/endpoints/instance.ts2
2 files changed, 12 insertions, 12 deletions
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 || '',