mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 18:01:05 +00:00
Fix WebUI crashing for accounts with null
URL (#35651)
This commit is contained in:
parent
927cfea5ae
commit
3caa318dfe
|
@ -37,7 +37,7 @@ export interface BaseApiAccountJSON {
|
|||
roles?: ApiAccountJSON[];
|
||||
statuses_count: number;
|
||||
uri: string;
|
||||
url: string;
|
||||
url?: string;
|
||||
username: string;
|
||||
moved?: ApiAccountJSON;
|
||||
suspended?: boolean;
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user