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

This commit is contained in:
Claire 2025-08-04 09:49:12 +02:00 committed by GitHub
parent 927cfea5ae
commit 3caa318dfe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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

@ -45,7 +45,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: ImmutableList<CustomEmoji>;
fields: ImmutableList<AccountField>;
@ -55,6 +55,7 @@ export interface AccountShape
note_plain: string | null;
hidden: boolean;
moved: string | null;
url: string;
}
export type Account = RecordOf<AccountShape>;
@ -148,8 +149,8 @@ export function createAccountFromServerJSON(serverJSON: ApiAccountJSON) {
note_emojified: emojify(accountNote, emojiMap),
note_plain: unescapeHTML(accountNote),
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