2
0

Fix WebUI crashing for accounts with null URL (#35651)

This commit is contained in:
Claire
2025-08-04 09:49:12 +02:00
parent 208cb8276a
commit cabb33bc49
3 changed files with 6 additions and 5 deletions

View File

@@ -37,7 +37,7 @@ export interface BaseApiAccountJSON {
roles?: ApiAccountJSON[]; roles?: ApiAccountJSON[];
statuses_count: number; statuses_count: number;
uri: string; uri: string;
url: string; url?: string;
username: string; username: string;
moved?: ApiAccountJSON; moved?: ApiAccountJSON;
suspended?: boolean; suspended?: boolean;

View File

@@ -45,7 +45,7 @@ const AccountRoleFactory = ImmutableRecord<AccountRoleShape>({
// Account // Account
export interface AccountShape export interface AccountShape
extends Required< extends Required<
Omit<ApiAccountJSON, 'emojis' | 'fields' | 'roles' | 'moved'> Omit<ApiAccountJSON, 'emojis' | 'fields' | 'roles' | 'moved' | 'url'>
> { > {
emojis: ImmutableList<CustomEmoji>; emojis: ImmutableList<CustomEmoji>;
fields: ImmutableList<AccountField>; fields: ImmutableList<AccountField>;
@@ -55,6 +55,7 @@ export interface AccountShape
note_plain: string | null; note_plain: string | null;
hidden: boolean; hidden: boolean;
moved: string | null; moved: string | null;
url: string;
} }
export type Account = RecordOf<AccountShape>; export type Account = RecordOf<AccountShape>;
@@ -148,8 +149,8 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
note_emojified: emojify(accountNote, emojiMap), note_emojified: emojify(accountNote, emojiMap),
note_plain: unescapeHTML(accountNote), note_plain: unescapeHTML(accountNote),
url: url:
accountJSON.url.startsWith('http://') || accountJSON.url?.startsWith('http://') ||
accountJSON.url.startsWith('https://') accountJSON.url?.startsWith('https://')
? accountJSON.url ? accountJSON.url
: accountJSON.uri, : accountJSON.uri,
}); });

View File

@@ -65,7 +65,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
end end
def url def url
ActivityPub::TagManager.instance.url_for(object) ActivityPub::TagManager.instance.url_for(object) || ActivityPub::TagManager.instance.uri_for(object)
end end
def uri def uri