diff --git a/app/soapbox/normalizers/account.ts b/app/soapbox/normalizers/account.ts index 61db66915..def1b497e 100644 --- a/app/soapbox/normalizers/account.ts +++ b/app/soapbox/normalizers/account.ts @@ -1,45 +1,8 @@ import { Map as ImmutableMap, List as ImmutableList, Record } from 'immutable'; +import { IAccount } from 'soapbox/types'; import { mergeDefined } from 'soapbox/utils/normalizers'; -interface Account { - acct: string; - avatar: string; - avatar_static: string; - birthday: Date | undefined; - bot: boolean; - created_at: Date; - display_name: string; - emojis: ImmutableList; - fields: ImmutableList; - followers_count: number; - following_count: number; - fqn: string; - header: string; - header_static: string; - id: string; - last_status_at: Date; - location: string; - locked: boolean; - moved: null; - note: string; - pleroma: ImmutableMap; - source: ImmutableMap; - statuses_count: number; - uri: string; - url: string; - username: string; - verified: boolean; - - // Internal fields - display_name_html: string; - note_emojified: string; - note_plain: string; - patron: ImmutableMap; - relationship: ImmutableList; - should_refetch: boolean; -} - const AccountRecord = Record({ acct: '', avatar: '', @@ -130,7 +93,7 @@ const normalizeLocation = (account: ImmutableMap) => { }); }; -export const normalizeAccount = (account: ImmutableMap): Account => { +export const normalizeAccount = (account: ImmutableMap): IAccount => { return AccountRecord( account.withMutations(account => { normalizePleromaLegacyFields(account); diff --git a/app/soapbox/types/account.ts b/app/soapbox/types/account.ts new file mode 100644 index 000000000..b17935c35 --- /dev/null +++ b/app/soapbox/types/account.ts @@ -0,0 +1,44 @@ +/** + * Account entity. + * https://docs.joinmastodon.org/entities/account/ + **/ + +interface IAccount { + acct: string; + avatar: string; + avatar_static: string; + birthday: Date | undefined; + bot: boolean; + created_at: Date; + display_name: string; + emojis: Iterable; + fields: Iterable; + followers_count: number; + following_count: number; + fqn: string; + header: string; + header_static: string; + id: string; + last_status_at: Date; + location: string; + locked: boolean; + moved: null; + note: string; + pleroma: Record; + source: Record; + statuses_count: number; + uri: string; + url: string; + username: string; + verified: boolean; + + // Internal fields + display_name_html: string; + note_emojified: string; + note_plain: string; + patron: Record; + relationship: Iterable; + should_refetch: boolean; +} + +export { IAccount }; diff --git a/app/soapbox/types/index.ts b/app/soapbox/types/index.ts new file mode 100644 index 000000000..bc8cbd94e --- /dev/null +++ b/app/soapbox/types/index.ts @@ -0,0 +1,3 @@ +import { IAccount } from './account'; + +export { IAccount };