Fix WebUI crashing for accounts with null URL (#35651)
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user