kopia lustrzana https://gitlab.com/soapbox-pub/soapbox
Merge branch 'normalize-pleroma-user-fields' into 'develop'
Normalize Pleroma user fields, fixes #549 Closes #549 See merge request soapbox-pub/soapbox-fe!422merge-requests/421/merge
commit
f8fa7007e7
|
@ -224,7 +224,7 @@ class Header extends ImmutablePureComponent {
|
|||
|
||||
const headerMissing = (account.get('header').indexOf('/headers/original/missing.png') > -1);
|
||||
const avatarSize = isSmallScreen ? 90 : 200;
|
||||
const deactivated = account.getIn(['pleroma', 'deactivated'], false);
|
||||
const deactivated = !account.getIn(['pleroma', 'is_active'], true);
|
||||
|
||||
return (
|
||||
<div className={classNames('account__header', { inactive: !!account.get('moved'), deactivated: deactivated })}>
|
||||
|
|
|
@ -59,7 +59,7 @@ class ProfileInfoPanel extends ImmutablePureComponent {
|
|||
const lockedIcon = account.get('locked') ? (<Icon id='lock' title={intl.formatMessage(messages.account_locked)} />) : '';
|
||||
const content = { __html: account.get('note_emojified') };
|
||||
const fields = account.get('fields');
|
||||
const deactivated = account.getIn(['pleroma', 'deactivated'], false);
|
||||
const deactivated = !account.getIn(['pleroma', 'is_active'], true);
|
||||
const displayNameHtml = deactivated ? { __html: intl.formatMessage(messages.deactivated) } : { __html: account.get('display_name_html') };
|
||||
const memberSinceDate = intl.formatDate(account.get('created_at'), { month: 'long', year: 'numeric' });
|
||||
const verified = account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified');
|
||||
|
|
|
@ -7,11 +7,18 @@ import { CHATS_FETCH_SUCCESS, CHAT_FETCH_SUCCESS } from 'soapbox/actions/chats';
|
|||
import { STREAMING_CHAT_UPDATE } from 'soapbox/actions/streaming';
|
||||
import { normalizeAccount as normalizeAccount2 } from 'soapbox/actions/importer/normalizer';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
import { normalizePleromaUserFields } from 'soapbox/utils/pleroma';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
const normalizePleroma = account => {
|
||||
if (!account.pleroma) return account;
|
||||
account.pleroma = normalizePleromaUserFields(account.pleroma);
|
||||
return account;
|
||||
};
|
||||
|
||||
const normalizeAccount = (state, account) => {
|
||||
const normalized = fromJS(account).deleteAll([
|
||||
const normalized = fromJS(normalizePleroma(account)).deleteAll([
|
||||
'followers_count',
|
||||
'following_count',
|
||||
'statuses_count',
|
||||
|
|
|
@ -15,6 +15,7 @@ import {
|
|||
OrderedSet as ImmutableOrderedSet,
|
||||
fromJS,
|
||||
} from 'immutable';
|
||||
import { normalizePleromaUserFields } from 'soapbox/utils/pleroma';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
reports: ImmutableMap(),
|
||||
|
@ -28,7 +29,8 @@ const initialState = ImmutableMap({
|
|||
function importUsers(state, users) {
|
||||
return state.withMutations(state => {
|
||||
users.forEach(user => {
|
||||
if (user.approval_pending) {
|
||||
user = normalizePleromaUserFields(user);
|
||||
if (!user.is_approved) {
|
||||
state.update('awaitingApproval', orderedSet => orderedSet.add(user.nickname));
|
||||
}
|
||||
state.setIn(['users', user.nickname], fromJS(user));
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
// https://gitlab.com/soapbox-pub/soapbox-fe/-/issues/549
|
||||
export const normalizePleromaUserFields = obj => {
|
||||
obj.is_active = obj.is_active === undefined ? !obj.deactivated : obj.is_active;
|
||||
obj.is_confirmed = obj.is_confirmed === undefined ? !obj.confirmation_pending : obj.is_confirmed;
|
||||
obj.is_approved = obj.is_approved === undefined ? !obj.approval_pending : obj.is_approved;
|
||||
delete obj.deactivated;
|
||||
delete obj.confirmation_pending;
|
||||
delete obj.approval_pending;
|
||||
return obj;
|
||||
};
|
Ładowanie…
Reference in New Issue