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

This commit is contained in:
Claire 2025-08-04 09:49:12 +02:00
parent 8ee8228d46
commit 6202cf6b65
3 changed files with 6 additions and 5 deletions

View File

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

View File

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

View File

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