Merge branch 'ts-account' into 'develop'
Normalize account "verified" See merge request soapbox-pub/soapbox-fe!1063
This commit is contained in:
commit
db006a1df0
|
@ -0,0 +1,123 @@
|
|||
{
|
||||
"acct": "mk",
|
||||
"avatar": "https://media.spinster.xyz/4043b9fb3f9d468aa48a8d68294f338914d9d54b2816aa1c789f548efe6c6239.jpg",
|
||||
"avatar_static": "https://media.spinster.xyz/4043b9fb3f9d468aa48a8d68294f338914d9d54b2816aa1c789f548efe6c6239.jpg",
|
||||
"bot": false,
|
||||
"created_at": "2019-08-01T22:06:30.000Z",
|
||||
"display_name": "M. K. Fain",
|
||||
"emojis": [
|
||||
{
|
||||
"shortcode": "4w",
|
||||
"static_url": "https://spinster.xyz/emoji/custom/4w.png",
|
||||
"url": "https://spinster.xyz/emoji/custom/4w.png",
|
||||
"visible_in_picker": false
|
||||
},
|
||||
{
|
||||
"shortcode": "spinster",
|
||||
"static_url": "https://spinster.xyz/emoji/custom/spinster.png",
|
||||
"url": "https://spinster.xyz/emoji/custom/spinster.png",
|
||||
"visible_in_picker": false
|
||||
}
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
"name": "Website",
|
||||
"value": "<a href=\"https://marykatefain.com\" rel=\"ugc\">https://marykatefain.com</a>"
|
||||
},
|
||||
{
|
||||
"name": "Twitter",
|
||||
"value": "<a href=\"https://twitter.com/mkay_fain\" rel=\"ugc\">https://twitter.com/mkay_fain</a>"
|
||||
},
|
||||
{
|
||||
"name": "Patreon",
|
||||
"value": "<a href=\"https://www.patreon.com/mkfain\" rel=\"ugc\">https://www.patreon.com/mkfain</a>"
|
||||
},
|
||||
{
|
||||
"name": "Paypal",
|
||||
"value": "<a href=\"https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ\" rel=\"ugc\">https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ</a>"
|
||||
},
|
||||
{
|
||||
"name": "Facebook",
|
||||
"value": "<a href=\"https://www.facebook.com/M-K-Fain-102559968375112\" rel=\"ugc\">https://www.facebook.com/M-K-Fain-102559968375112</a>"
|
||||
},
|
||||
{
|
||||
"name": "Dog Pics",
|
||||
"value": "<a href=\"https://www.instagram.com/mmkaayyy92\" rel=\"ugc\">https://www.instagram.com/mmkaayyy92</a>"
|
||||
},
|
||||
{
|
||||
"name": "$BTC",
|
||||
"value": "bc1q7fp347muhnuxrtu0pft6eswn0e7pldhssdg8py"
|
||||
}
|
||||
],
|
||||
"followers_count": 5687,
|
||||
"following_count": 18017,
|
||||
"fqn": "mk@spinster.xyz",
|
||||
"header": "https://media.spinster.xyz/3a5f9d5ef06940d0c319f8f0135b1153a8a42cefd10eace97378875c0347da71.png",
|
||||
"header_static": "https://media.spinster.xyz/3a5f9d5ef06940d0c319f8f0135b1153a8a42cefd10eace97378875c0347da71.png",
|
||||
"id": "9y4BZYXEDuQ6K1zW9g",
|
||||
"last_status_at": "2022-02-27T01:58:21",
|
||||
"locked": false,
|
||||
"note": ":spinster: Admin of <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"9y4BZYU2PlrsA8UyBM\" href=\"https://spinster.xyz/users/spinster\" rel=\"ugc\">@<span>spinster</span></a></span><br/>:4w: Editor of <span class=\"h-card\"><a class=\"u-url mention\" data-user=\"9y4BxBsU76tt0CCgBE\" href=\"https://spinster.xyz/users/4WPub\" rel=\"ugc\">@<span>4WPub</span></a></span><br/><br/>Sorry I didn't reply to you.<br/><br/>Boost ≠ agree. All opinions my own.",
|
||||
"pleroma": {
|
||||
"accepts_chat_messages": true,
|
||||
"also_known_as": [],
|
||||
"ap_id": "https://spinster.xyz/users/mk",
|
||||
"background_image": null,
|
||||
"favicon": "https://spinster.xyz/favicon.png",
|
||||
"hide_favorites": true,
|
||||
"hide_followers": false,
|
||||
"hide_followers_count": false,
|
||||
"hide_follows": false,
|
||||
"hide_follows_count": false,
|
||||
"is_admin": true,
|
||||
"is_confirmed": true,
|
||||
"is_moderator": false,
|
||||
"is_suggested": true,
|
||||
"relationship": {},
|
||||
"skip_thread_containment": false,
|
||||
"tags": [
|
||||
"verified"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
"fields": [
|
||||
{
|
||||
"name": "Website",
|
||||
"value": "https://marykatefain.com"
|
||||
},
|
||||
{
|
||||
"name": "Twitter",
|
||||
"value": "https://twitter.com/mkay_fain"
|
||||
},
|
||||
{
|
||||
"name": "Patreon",
|
||||
"value": "https://www.patreon.com/mkfain"
|
||||
},
|
||||
{
|
||||
"name": "Paypal",
|
||||
"value": "https://www.paypal.com/donate?hosted_button_id=NYXHYFQ6CRWJJ"
|
||||
},
|
||||
{
|
||||
"name": "Facebook",
|
||||
"value": "https://www.facebook.com/M-K-Fain-102559968375112"
|
||||
},
|
||||
{
|
||||
"name": "Dog Pics",
|
||||
"value": "https://www.instagram.com/mmkaayyy92"
|
||||
},
|
||||
{
|
||||
"name": "$BTC",
|
||||
"value": "bc1q7fp347muhnuxrtu0pft6eswn0e7pldhssdg8py"
|
||||
}
|
||||
],
|
||||
"note": ":spinster: Admin of @spinster\r\n:4w: Editor of @4WPub\r\n\r\nSorry I didn't reply to you.\r\n\r\nBoost ≠ agree. All opinions my own.",
|
||||
"pleroma": {
|
||||
"actor_type": "Person",
|
||||
"discoverable": false
|
||||
},
|
||||
"sensitive": false
|
||||
},
|
||||
"statuses_count": 9580,
|
||||
"url": "https://spinster.xyz/users/mk",
|
||||
"username": "mk"
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"id": "107780257626128497",
|
||||
"username": "realDonaldTrump",
|
||||
"acct": "realDonaldTrump",
|
||||
"display_name": "Donald J. Trump",
|
||||
"locked": false,
|
||||
"bot": false,
|
||||
"discoverable": null,
|
||||
"group": false,
|
||||
"created_at": "2022-02-11T00:00:00.000Z",
|
||||
"note": "<p>45th President of the United States of America</p>",
|
||||
"url": "https://truthsocial.com/@realDonaldTrump",
|
||||
"avatar": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/780/257/626/128/497/original/573cf5cc8281e7e9.jpeg",
|
||||
"avatar_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/avatars/107/780/257/626/128/497/original/573cf5cc8281e7e9.jpeg",
|
||||
"header": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/780/257/626/128/497/original/3c1acf607b065ded.jpeg",
|
||||
"header_static": "https://static-assets.truthsocial.com/tmtg:prime-truth-social-assets/accounts/headers/107/780/257/626/128/497/original/3c1acf607b065ded.jpeg",
|
||||
"followers_count": 51507,
|
||||
"following_count": 1,
|
||||
"statuses_count": 1,
|
||||
"last_status_at": "2022-02-14",
|
||||
"verified": true,
|
||||
"location": "",
|
||||
"website": "",
|
||||
"emojis": [],
|
||||
"fields": []
|
||||
}
|
|
@ -4,7 +4,6 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import HoverRefWrapper from 'soapbox/components/hover_ref_wrapper';
|
||||
import { isVerified } from 'soapbox/utils/accounts';
|
||||
import { displayFqn } from 'soapbox/utils/state';
|
||||
|
||||
import { getAcct } from '../utils/accounts';
|
||||
|
@ -38,7 +37,7 @@ class DisplayName extends React.PureComponent {
|
|||
const { account, displayFqn, others, children, withDate } = this.props;
|
||||
|
||||
let displayName, suffix;
|
||||
const verified = isVerified(account);
|
||||
const verified = account.get('verified');
|
||||
|
||||
const createdAt = account.get('created_at');
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import {
|
|||
isStaff,
|
||||
isAdmin,
|
||||
isModerator,
|
||||
isVerified,
|
||||
isLocal,
|
||||
isRemote,
|
||||
getDomain,
|
||||
|
@ -451,7 +450,7 @@ class Header extends ImmutablePureComponent {
|
|||
}
|
||||
}
|
||||
|
||||
if (isVerified(account)) {
|
||||
if (account.get('verified')) {
|
||||
menu.push({
|
||||
text: intl.formatMessage(messages.unverifyUser, { name: account.get('username') }),
|
||||
action: this.props.onUnverifyUser,
|
||||
|
|
|
@ -6,7 +6,7 @@ import { Link } from 'react-router-dom';
|
|||
|
||||
import StillImage from 'soapbox/components/still_image';
|
||||
import VerificationBadge from 'soapbox/components/verification_badge';
|
||||
import { getAcct, isVerified } from 'soapbox/utils/accounts';
|
||||
import { getAcct } from 'soapbox/utils/accounts';
|
||||
import { displayFqn } from 'soapbox/utils/state';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
|
@ -28,7 +28,7 @@ const ProfilePreview = ({ account, displayFqn }) => (
|
|||
<bdi>
|
||||
<strong className='emojify p-name'>
|
||||
{account.get('display_name')}
|
||||
{isVerified(account) && <VerificationBadge />}
|
||||
{account.get('verified') && <VerificationBadge />}
|
||||
</strong>
|
||||
</bdi>
|
||||
<span>@{getAcct(account, displayFqn)}</span>
|
||||
|
|
|
@ -25,7 +25,6 @@ import {
|
|||
SimpleTextarea,
|
||||
} from 'soapbox/features/forms';
|
||||
import { makeGetAccount } from 'soapbox/selectors';
|
||||
import { isVerified } from 'soapbox/utils/accounts';
|
||||
import { getFeatures } from 'soapbox/utils/features';
|
||||
import resizeImage from 'soapbox/utils/resize_image';
|
||||
|
||||
|
@ -263,7 +262,7 @@ class EditProfile extends ImmutablePureComponent {
|
|||
|
||||
render() {
|
||||
const { intl, maxFields, account, verifiedCanEditName, supportsBirthdays, supportsEmailList } = this.props;
|
||||
const verified = isVerified(account);
|
||||
const verified = account.get('verified');
|
||||
const canEditName = verifiedCanEditName || !verified;
|
||||
|
||||
return (
|
||||
|
|
|
@ -15,7 +15,7 @@ import Icon from 'soapbox/components/icon';
|
|||
import VerificationBadge from 'soapbox/components/verification_badge';
|
||||
import BundleContainer from 'soapbox/features/ui/containers/bundle_container';
|
||||
import { CryptoAddress } from 'soapbox/features/ui/util/async-components';
|
||||
import { getAcct, isAdmin, isModerator, isLocal, isVerified } from 'soapbox/utils/accounts';
|
||||
import { getAcct, isAdmin, isModerator, isLocal } from 'soapbox/utils/accounts';
|
||||
import { displayFqn } from 'soapbox/utils/state';
|
||||
|
||||
import ProfileStats from './profile_stats';
|
||||
|
@ -147,7 +147,7 @@ class ProfileInfoPanel extends ImmutablePureComponent {
|
|||
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 = isVerified(account);
|
||||
const verified = account.get('verified');
|
||||
const badges = this.getBadges();
|
||||
|
||||
return (
|
||||
|
|
|
@ -9,7 +9,7 @@ import { Link } from 'react-router-dom';
|
|||
import Avatar from 'soapbox/components/avatar';
|
||||
import StillImage from 'soapbox/components/still_image';
|
||||
import VerificationBadge from 'soapbox/components/verification_badge';
|
||||
import { getAcct, isVerified } from 'soapbox/utils/accounts';
|
||||
import { getAcct } from 'soapbox/utils/accounts';
|
||||
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
||||
import { displayFqn } from 'soapbox/utils/state';
|
||||
|
||||
|
@ -51,7 +51,7 @@ class UserPanel extends ImmutablePureComponent {
|
|||
<h1>
|
||||
<Link to={`/@${account.get('acct')}`}>
|
||||
<span className='user-panel__account__name' dangerouslySetInnerHTML={displayNameHtml} />
|
||||
{isVerified(account) && <VerificationBadge />}
|
||||
{account.get('verified') && <VerificationBadge />}
|
||||
<small className='user-panel__account__username'>@{getAcct(account, displayFqn)}</small>
|
||||
</Link>
|
||||
</h1>
|
||||
|
|
|
@ -36,4 +36,22 @@ describe('normalizeAccount()', () => {
|
|||
expect(result.getIn(['pleroma', 'is_confirmed'])).toBe(true);
|
||||
expect(result.getIn(['pleroma', 'is_approved'])).toBe(true);
|
||||
});
|
||||
|
||||
it('normalizes a verified Pleroma user', () => {
|
||||
const account = fromJS(require('soapbox/__fixtures__/mk.json'));
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.get('verified')).toBe(true);
|
||||
});
|
||||
|
||||
it('normalizes an unverified Pleroma user', () => {
|
||||
const account = fromJS(require('soapbox/__fixtures__/pleroma-account.json'));
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.get('verified')).toBe(false);
|
||||
});
|
||||
|
||||
it('normalizes a verified Truth Social user', () => {
|
||||
const account = fromJS(require('soapbox/__fixtures__/realDonaldTrump.json'));
|
||||
const result = normalizeAccount(account);
|
||||
expect(result.get('verified')).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Map as ImmutableMap } from 'immutable';
|
||||
import { Map as ImmutableMap, List as ImmutableList } from 'immutable';
|
||||
|
||||
import { mergeDefined } from 'soapbox/utils/normalizers';
|
||||
|
||||
|
@ -28,9 +28,20 @@ const normalizeBirthday = account => {
|
|||
return account.set('birthday', birthday);
|
||||
};
|
||||
|
||||
// Normalize Truth Social/Pleroma verified
|
||||
const normalizeVerified = account => {
|
||||
return account.update('verified', verified => {
|
||||
return [
|
||||
verified === true,
|
||||
account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified'),
|
||||
].some(Boolean);
|
||||
});
|
||||
};
|
||||
|
||||
export const normalizeAccount = account => {
|
||||
return account.withMutations(account => {
|
||||
normalizePleromaLegacyFields(account);
|
||||
normalizeVerified(account);
|
||||
normalizeBirthday(account);
|
||||
});
|
||||
};
|
||||
|
|
|
@ -64,10 +64,6 @@ export const isLocal = account => {
|
|||
|
||||
export const isRemote = account => !isLocal(account);
|
||||
|
||||
export const isVerified = account => (
|
||||
account.getIn(['pleroma', 'tags'], ImmutableList()).includes('verified')
|
||||
);
|
||||
|
||||
export const accountToMention = account => {
|
||||
return ImmutableMap({
|
||||
id: account.get('id'),
|
||||
|
|
Loading…
Reference in New Issue