normalizeAccount(): normalize `discoverable` field

next
Alex Gleason 2022-04-29 12:59:13 -05:00
rodzic 5cc962593e
commit e6a797d712
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 7 dodań i 0 usunięć

Wyświetl plik

@ -27,6 +27,7 @@ export const AccountRecord = ImmutableRecord({
birthday: undefined as Date | undefined, birthday: undefined as Date | undefined,
bot: false, bot: false,
created_at: new Date(), created_at: new Date(),
discoverable: false,
display_name: '', display_name: '',
emojis: ImmutableList<Emoji>(), emojis: ImmutableList<Emoji>(),
favicon: '', favicon: '',
@ -255,6 +256,11 @@ const addStaffFields = (account: ImmutableMap<string, any>) => {
}); });
}; };
const normalizeDiscoverable = (account: ImmutableMap<string, any>) => {
const discoverable = Boolean(account.get('discoverable') || account.getIn(['source', 'pleroma', 'discoverable']));
return account.set('discoverable', discoverable);
};
export const normalizeAccount = (account: Record<string, any>) => { export const normalizeAccount = (account: Record<string, any>) => {
return AccountRecord( return AccountRecord(
ImmutableMap(fromJS(account)).withMutations(account => { ImmutableMap(fromJS(account)).withMutations(account => {
@ -269,6 +275,7 @@ export const normalizeAccount = (account: Record<string, any>) => {
normalizeLocation(account); normalizeLocation(account);
normalizeFqn(account); normalizeFqn(account);
normalizeFavicon(account); normalizeFavicon(account);
normalizeDiscoverable(account);
addDomain(account); addDomain(account);
addStaffFields(account); addStaffFields(account);
fixUsername(account); fixUsername(account);